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.


ffmpeg - changing frame rate

March 5, 2017 - Reading time: ~1 minute
With re-encoding:
ffmpeg -y -i seeing_noaudio.mp4 -vf "setpts=1.25*PTS" -r 24 seeing.mp4

Without re-encoding:

First step - extract video to raw bitstream

ffmpeg -y -i seeing_noaudio.mp4 -c copy -f h264 seeing_noaudio.h264

Remux with new framerate

ffmpeg -y -r 24 -i seeing_noaudio.h264 -c copy seeing.mp4