13

When I use this, the quality doesn't look bad.

ffmpeg -same_quant -i video.mp4 video.avi

In the ffmpeg documentation is written: "Note that this is NOT SAME QUALITY. Do not use this option unless you know you need it."

Do I get with -same_quant the best quality or is there an option that gives the same quality as the input and is more recommended?

9
  • Depending on the codecs used (some codecs are incompatible with some containers), you could always simply copy the streams (-codec copy). That is the best way to avoid quality changes, as you're not reencoding the streams, just repackaging those in a different container.
    – njsg
    Commented Jun 8, 2012 at 15:35
  • When I try this I get: Unknown decoder 'copy'.
    – sid_com
    Commented Jun 8, 2012 at 15:46
  • 4
    It seems -codec copy must go after -i video.mp4 -- can you try ffmpeg -i video.mp4 -codec copy video.avi? (-same_quant works here too, but will do nothing, as this just copies the streams)
    – njsg
    Commented Jun 8, 2012 at 16:12
  • Regarding the placement of ffmpeg's command-line options, see ffmpeg Documentation - 2 Description: Here is an excerpt: As a general rule, options are applied to the next specified file. Therefore, order is important, ...
    – Peter.O
    Commented Jun 8, 2012 at 16:43
  • Thx! Now with -codec copy on the right place is works.
    – sid_com
    Commented Jun 8, 2012 at 17:53

2 Answers 2

16

(adapted from comments above)

Depending on the codecs used (some codecs are incompatible with some containers), you could always simply copy the streams (-codec copy). That is the best way to avoid quality changes, as you're not reencoding the streams, just repackaging those in a different container.

When dealing with audio/video files, it is important to keep in mind that containers are mostly independent from the used codecs. It is common to see people referring to files as "AVI video" or "MP4 video", but those are containers and tell us little about whether a player will be able to play the streams, as, apart from technical limitations (for example, AVI may have issues with h264 and Ogg Vorbis), you could use any codec.

-same_quant seems to be a way to tell ffmpeg to try to achieve a similar quality, but as soon as you reencode the video (at least with lossy codecs), you have no way to get the same quality. If you're concerned with quality, a good rule of thumb is to avoid reencoding the streams when possible.

So, in order to copy the streams with ffmpeg, you'd do:

ffmpeg -i video.mp4 -codec copy video.avi

(As @Peter.O mentioned, option order is important, so that's where -codec copy must go. You could still keep -same_quant, but it won't have any effect as you're not reencoding the streams.)

1
  • Your solution works for me. I see that avconv is now recommended in place of ffmpeg and in fact is what I used. Commented Sep 29, 2013 at 11:44
4

Under FreeBSD 8. 2, I tried -codec copy but I got message unknown decoded as well. After trial and error I found the one that working is under FreeBSD:

ffmpeg -i video.mp4 -vcodec copy video.avi

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .