ffmpeg - transform mp4 to same high-quality avi

April 2, 2018 - Reading time: ~1 minute
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


ffmpeg - transform mp4 to same high-quality avi

August 13, 2017 - Reading time: ~1 minute
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


ffmpeg - convert flv to mp4 without losing quality

June 15, 2017 - Reading time: ~1 minute
ffmpeg -i filename.flv -c:v libx264 -crf 19 -strict experimental filename.mp4

This command only changes container without reencoding:

ffmpeg -i input.flv -codec copy output.mp4

According to this guide, the proper command to convert FLV to MP4 without any AV recoding is this:
ffmpeg -i input.flv -c copy -copyts output.mp4

It worked perfectly for me in all cases with AVC video and AAC or MP3 audio.