Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I like mencoder for converting video files because it shows me how much time is remaining to the end of the conversion (in opposite to ffmpeg).

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 is sameq option. Is there similar option for mencoder 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

share|improve this question
    
It might be helpful if you supplied the mencoder command and switches you're using now. –  Sorpigal Nov 18 '11 at 18:29
    
see question edit –  xralf Nov 18 '11 at 18:39
1  
I've never gotten ffmpeg's -sameq flag to do anything. –  amphetamachine Nov 18 '11 at 23:58
1  
About mencoder's verbosity level, you can try to increase it with ffmpeg (with -v or -loglevel options). Also remember that ffmpeg is based on libavcodec now, which is under heavy development, in opposite of mencoder. Mplayer2 distribution doesn't include mencoder in that state as it is in original Mplayer distribution. –  Eir Nym Nov 19 '11 at 14:49
1  
You use very outdated ffmpeg, try to update it. My ffmpeg's version is 0.8.5.git-38a444e,` –  Eir Nym Nov 19 '11 at 15:15

2 Answers 2

up vote 8 down vote accepted
+50

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:

  1. 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
    
  2. 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:

  1. 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)
  2. 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

share|improve this answer
    
The last conversion ends with this. The file was converted but the quality is worse (there are visible squares) –  xralf Nov 24 '11 at 12:17
    
can you post the first part of the conversion process ? that's the important bit where it identifies the codec bit rate etc. –  led42 Nov 24 '11 at 12:28
    
Botched the syntax for mencoder, it's fixed in the answer. –  led42 Nov 24 '11 at 12:52
1  
add -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. –  led42 Nov 24 '11 at 13:59
1  
Humm 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. –  led42 Nov 24 '11 at 16:52

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"
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.