use ffmpeg to transform mp4 to same high-quality avi file?
You always lose a little quality whenever you transcode from one codec to another, video or audio, but perhaps you can avoid it if you only want to change from MP4 container type to an AVI container. codec:copy
may be helpful if you don't have a reason to transcode (and it should be faster).
If you must transcode because you need to use a particular video codec
I hope you can use zetah's suggestion above in his comment and use the -sameq
switch. Alternatively, you may want to use the qscale
option to set the quality manually. The lower the number the better the quality, but the more space your file will take.
The last time I transcoded video I used qscale=8.0
, but I'd suggest that you experiment to find the optimum to match the quality of your input.
Marty Jay helpfully mentions that sameq means same quantizer as in the input, which may not result in the same quality. The article he quotes mentions using multi-pass conversion, which is a good way to achieve better compression without sacrificing quality.
My solution:
ffmpeg -i filename.mp4 -vcodec copy -acodec copy filename.avi
Enjoy!!
Here is my 2-pass (Advanced Simple Profile) I use now and then.
pass 1:
ffmpeg -i file.mp4 -vcodec mpeg4 -vtag XVID -b 990k -bf 2 -g 300 -s 640x360 -pass 1 -an -threads 0 -f rawvideo -y /dev/null
pass 2:
ffmpeg -i file.mp4 -vcodec mpeg4 -vtag XVID -b 990k -bf 2 -g 300 -s 640x360 -acodec libmp3lame -ab 128k -ar 48000 -ac 2 -pass 2 -threads 0 -f avi file.avi