AVI to MP4
ffmpeg -i input.avi -c:v libx264 -crf 19 -preset slow -c:a libfaac -b:a 192k -ac 2 out.mp4
if libfaac isn't available, use this:
ffmpeg -i input.avi -c:v libx264 -crf 19 -preset slow -c:a aac -strict experimental -b:a 192k -ac 2 out.mp4
wmv to MP4
ffmpeg -i input.wmv -c:v libx264 -crf 19 -preset slow -c:a aac -strict experimental -b:a 192k -ac 2 out.mp4
FLV to MP4
ffmpeg -i filename.flv -c:v libx264 -crf 19 -strict experimental filename.mp4
MOV to MP4
if MOV has h.264 already:
ffmpeg -i input.mov -vcodec copy -acodec copy output.mp4
if not:
ffmpeg -i {input}.mov -vcodec h264 -acodec aac -strict -2 {output}.mp4
For ripping DVDs, use makemkv to rip the VOB files to MKV files. Then use ffmpeg to convert to mp4
MKV
ffmpeg -i input.mkv -c:v libx264 -crf 19 -preset slow -acodec aac -b:a 192k -ac 2 out.mp4 #straight output
ffmpeg -i input.mkv -vf yadif -c:v libx264 -crf 19 -preset slow -acodec aac -b:a 192k -ac 2 out.mp4 #deinterlaced
ffmpeg -i input.mkv -c:v libx264 -flags +ildct+ilme -crf 19 -preset slow -acodec aac -b:a 192k -ac 2 out.mp4 #interlaced
ffmpeg -i input.mkv -c:v libx264 -flags +ildct+ilme -crf 19 -preset slow -acodec aac -b:a 192k -ac 2 -c:s mov_text out.mp4 #interlaced and subtitles included
Join Webm video and m4a audio:
ffmpeg -i input_video.webm -i input_audio.m4a -vcodec h264 -acodec aac -strict -2 output_video.mp4
How to trim a video:
ffmpeg -ss 00:01:00 -i input.mp4 -to 00:02:00 -c copy output.mp4
How to increase/decrease volume:
To increase the volume of the first audio track for 10dB use:
ffmpeg -i inputfile -vcodec copy -af "volume=10dB" outputfile
To decrease the volume of the first audio track for 5dB use:
ffmpeg -i inputfile -vcodec copy -af "volume=-5dB" outputfile
Concatenation of files with same codecs
There are two methods within ffmpeg that can be used to concatenate files of the same type: the concat ''demuxer'' and the concat ''protocol''. The demuxer is more flexible - it requires the same codecs, but different container formats can be used; and it can be used with any container formats, while the protocol only works with a select few containers. However, the concat protocol is available in older versions of ffmpeg, where the demuxer isn't.
Concat demuxer
The concat demuxer was added to FFmpeg 1.1. You can read about it in the documentation.
Instructions
Create a file mylist.txt with all the files you want to have concatenated in the following form (lines starting with a # are ignored):
# this is a comment file '/path/to/file1' file '/path/to/file2' file '/path/to/file3'
Note that these can be either relative or absolute paths. Then you can stream copy or re-encode your files:
ffmpeg -f concat -i mylist.txt -c copy output
It is possible to generate this list file with a bash for loop, or using printf. Either of the following would generate a list file containing every *.wav in the working directory:
# with a bash for loop for f in ./*.wav; do echo "file '$f'" >> mylist.txt; done # or with printf printf "file '%s'\n" ./*.wav > mylist.txt
On Windows Command-line:
(for %i in (*.wav) do @echo file '%i') > mylist.txt