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.

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?

share|improve this question
    
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 Jun 8 '12 at 15:35
    
When I try this I get: Unknown decoder 'copy'. –  sid_com Jun 8 '12 at 15:46
1  
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 Jun 8 '12 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 Jun 8 '12 at 16:43
    
Thx! Now with -codec copy on the right place is works. –  sid_com Jun 8 '12 at 17:53

2 Answers 2

up vote 8 down vote accepted

(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.)

share|improve this answer
    
Your solution works for me. I see that avconv is now recommended in place of ffmpeg and in fact is what I used. –  Faheem Mitha Sep 29 '13 at 11:44

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
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.