Mencoder with same quality output
Solution 1
Ok, first things first...
ffmpeg's sameq option doesn't mean same quality, and in many cases will not do anything relevant.
This is from the ffmpeg man page:
-sameq
Use same quantizer as source (implies VBR).
This is actually from the ffmpeg online documentation
‘-same_quant’
Use same quantizer as source (implies VBR).
Note that this is NOT SAME QUALITY. Do not use this option unless you know you need it.
You can check it here http://ffmpeg.org/ffmpeg.html, search for same_quant (it's the same as sameq).
Ok, now that's out of the way,
I don't know exactly what you are trying to achieve with your conversion, but there are 2 possibilities, which I will enumerate and try to help:
-
You are only trying to change the Container and not the codec of the video. The container is the bit of data that's there to tell the software that's trying to play the video how things are organized, It has the info on the FPS, video codec, audio codecs, how the data is stored. If your video was water the container could be a glass bottle a cartoon, or plastic bottle. In this case containers are wmv, avi, mp4, mov, etc. Containers are important because not all of them support all codecs, and not all software supports all containers. Keep in mind that you could still get the container right, but if the video inside is the wrong codec you're still out of luck. So if you only want to change containers you can use:
mencoder file.wmv -ofps 23.976 -ovc copy -oac copy -o file.avi
You're trying to change the Codec. The Codec is the algorithm or set of specs that actually says how a video is encoded, different codecs have different quality outputs, sizes, parameters, etc. Now things get a bit tricky, while changing the container you can actually copy the video and not lose any quality (because you only change the container) when changing codecs you will most certainly lose some quality, but most times if both codecs are good and the right parameters are configured you wouldn't notice much after just one conversion (this is inherent of the way codecs compress video ).
The different quality between ffmpeg and mencoder I can only guess, but one of two things must be happening:
- You only need to change containers, and ffmpeg is detecting that and only copying the video. (if this is the case use -ovc copy on mencoder)
-
You need to change codecs and ffmpeg is choosing better codecs/parameters to recompress the video. In this case try to check what codec ffmpeg is using (if you can't post them here and I will take a look) or try a diferent code with mencoder (right now you're not specifying anything) for example:
mencoder file.wmv -ofps 23.976 -ovc lavc -lavcopts vcodec=mpeg4 -oac copy -o file.avi
This would make use the ISO standard MPEG-4 (DivX 5, XVID compatible), of course you could still need to change the bitrate that reconversion is using, looking at the source bitrate would be a good indicator.
Also mencoder supports a lot of different libs, some are multi codec like lavc, others not, try
mencoder -ovc help
to get a list of supported codecs, in mine I got:
MEncoder SVN-r33094-4.5.3 (C) 2000-2011 MPlayer Team
Available codecs:
copy - frame copy, without re-encoding. Doesn't work with filters.
frameno - special audio-only file for 3-pass encoding, see DOCS.
raw - uncompressed video. Use fourcc option to set format explicitly.
nuv - nuppel video
lavc - libavcodec codecs - best quality!
libdv - DV encoding with libdv v0.9.5
xvid - XviD encoding
x264 - H.264 encoding
So I could do:
mencoder file.wmv -ofps 23.976 -ovc xvid -oac copy -o file.avi
or
mencoder file.wmv -ofps 23.976 -ovc x264 -oac copy -o file.avi
For a smaller file size and looooonger compress time
Solution 2
I think you didn't answer his question, especially when speaking of ffmpeg.
This will have mencoder produce a nice divx encoding with about the same bitrate, quality and filesize as the source.
n=filename=positional parameter of the script
You can use it as a Nautilus script to right-click the file icon to convert it.
You tune the output parameters up to your taste.
#!/bin/bash -x
if [ ! -t 1 ]; then gnome-terminal -x "$0" "$@"; exit; fi
n="$@"
bitrate=`mediainfo --Inform="Video;%BitRate%" "$n"`<br>
nice mencoder -ovc xvid -xvidencopts max_key_interval=50:bitrate=$bitrate -mc 0 -vf harddup -oac mp3lame -lameopts cbr:aq=0:br=64 -o "${n%.*}.new.avi" "$n"
Related videos on Youtube
xralf
Updated on September 18, 2022Comments
-
xralf almost 2 years
I like
mencoder
for converting video files because it shows me how much time is remaining to the end of the conversion (in opposite toffmpeg
).mencoder file.wmv -ofps 23.976 -ovc lavc -oac copy -o file.avi
The problem is that the resulting file is not the same quality as the input file. With
ffmpeg
there issameq
option. Is there similar option formencoder
to achieve the same quality?Is this only my feeling or is mencoder faster than ffmpeg when I will achieve the same quality?
thank you
-
Sorpigal over 12 yearsIt might be helpful if you supplied the mencoder command and switches you're using now.
-
xralf over 12 yearssee question edit
-
amphetamachine over 12 yearsI've never gotten ffmpeg's
-sameq
flag to do anything. -
Eir Nym over 12 yearsAbout
mencoder's
verbosity level, you can try to increase it withffmpeg
(with-v
or-loglevel
options). Also remember thatffmpeg
is based on libavcodec now, which is under heavy development, in opposite ofmencoder
. Mplayer2 distribution doesn't include mencoder in that state as it is in original Mplayer distribution. -
xralf over 12 years@EirNym Verbosity level of
mencoder
is OK for me but it does not give same quality output. -
Eir Nym over 12 years@xralf I speak of verbosity level of
ffmpeg
. I know it's different answer than you expect. -
xralf over 12 years@EirNym But my
ffmpeg
does not have-v
or-loglevel
option. -
Eir Nym over 12 yearsYou use very outdated
ffmpeg
, try to update it. Myffmpeg
's version is0.8.5.git-38a444e
,`
-
-
xralf over 12 yearsThe last conversion ends with this. The file was converted but the quality is worse (there are visible squares)
-
led42 over 12 yearscan you post the first part of the conversion process ? that's the important bit where it identifies the codec bit rate etc.
-
led42 over 12 yearsBotched the syntax for mencoder, it's fixed in the answer.
-
xralf over 12 yearsHere is the error output of the new command.
-
led42 over 12 yearsadd -xvidencopts bitrate=4608, after the -ovc xvid, but this is specific for the video from the output, you have to adapt, or update your libs, mencoder is complaining about that, and probably can't read all the info it needs to convert correctly.
-
xralf over 12 yearsThis helped, only it took approx. 2 hours (with the worse quality it was abou 20 minutes). Which libs should I update? I have fresh install of Ubuntu 11.10.
-
led42 over 12 yearsHumm well mencoder complains of two things, one there's a symbol mismatch between ffmpeg and mencoder, so the versions you have are not matching exactly (probably minor), second mencoder can and will use windows libs, to have better all around support for windows only codecs and the like, and that's what it's complaining, says to go to mplayerhq.hu/dload.html and download the codecs package, i'm guessing they should go in /usr/lib/codecs/, because that were the failing lib is installed. Anyway, glad it helped.