My most used ffmpeg commands

Video conversion

Selectively extract streams in video file

ffmpeg -i input.mkv -acodec copy -vcodec copy -scodec copy -map 0:a:2 -map 0:v:0 -map 0:s:1 output.mkv

Basically -map 0:a:2 = third audio track. -map 0:v:0 = first video track and -map 0:s:1 means second subtitle track.

Convert FLV to MP4

The FLV might already be encoded with H264, in which case you anly need to use:

ffmpeg -i input.flv -c:v copy output.mp4

If you need to reencode the video to H264 you can use:

ffmpeg -i input.flv -c:v libx264 -crf 18 output.mp4

Convert DVD VOB to H264 MP4

ffmpeg -i input -vf yadif=0:1:0 -framerate 25 -codec:v libx264 -profile:v high444 -preset veryslow -threads 0 -codec:a libmp3lame -b:a 256k -crf 17 output.mp4

Audio

Convert video to audio

ffmpeg -i input.ext -vn -acodec copy output.ext

Convert 5.1 Surround audio to stereo

ffmpeg -i input.ext -vn -acodec copy -c:a aac -ac 2 -af "pan=stereo|FL=FC+0.30*FL+0.30*BL|FR=FC+0.30*FR+0.30*BR" output.ext

Misc

ffmpeg command for multiple files

for %%A IN (*.YOUR_FILE_FORMAT) DO ffmpeg -i "%%A" ALL_FLAGS_AND_VARIABLES_GOES_HERE "%%A.YOURFILEFORMAT"
pause

Subtitles

Remove subtitles (copy file without subtitles)

ffmpeg -i input.ext -vcodec copy -acodec copy -sn output.ext