FFmpeg
Just some useful FFmpeg commands I sometimes use.
Show file information
ffmpeg -i input.mp4
Lists (among other things) the streams contained in the file, like Stream #0:0: Video: h264.. or Stream #0:1: Audio: aac...
Extract Audio
Extract as WAV:
ffmpeg -i input.mp4 -map a output.wav
Extract without re-encoding (-c(odec) copy, container format depends on what the original audio encoding is):
ffmpeg -i input.mp4 -map a -c copy output.aac
If there's more than one audio track you can select a certain stream in the file (in this example the 3rd track in the first file):
ffmpeg -i input.mp4 -map 0:2 -c copy output.aac
Exchange Audio
Use several input files and select which streams you want to have in there:
ffmpeg -i input.mp4 -i audio.aac -map 0:0 -map 1:0 -c copy output.mp4
In this example, it's using the first stream from the first file (-map 0:0) and the first stream from the second file (-map 1:0). And it's still just making a copy of the streams instead of encoding them (-c copy).
Mute Audio
To mute part of the audio of a video, you can use the following:
ffmpeg -i input.mp4 -af "volume=enable='between(t,10,30)':volume=0" -c:v copy output.mp4
The audio filter mutes the audio between 10 and 30 seconds into the video. The -c:v copy directly copies the video only, the audio has to be re-encoded. You can also mute more than one section:
ffmpeg -i input.mp4 -af "volume=enable='between(t,10,30)':volume=0, volume=enable='between(t,120,180)':volume=0" -c:v copy output.mp4
This would mute the parts between 10 and 30 seconds and between 2 and 3 minutes into the video.
Cut
To cut out part of a video (without re-encoding), for example starting at 12 minutes to 12 minutes 10 seconds, all of the following are equivalent:
ffmpeg -i input.mp4 -c copy -ss 0:12:00 -t 0:00:10 output.mp4
ffmpeg -i input.mp4 -c copy -ss 12:00 -t 0:10 output.mp4
ffmpeg -i input.mp4 -c copy -ss 0:12:00 -to 0:12:10 output.mp4
-ss starttime offset
-to endtime offset
-t duration
cut.bat
To make things a bit easier the following very simple .bat-file can be used:
ffmpeg -i %1 -ss %2 -to %3 -c copy output.mp4
Usage:
cut.bat IN_FILE.mp4 10:00 1:05:00
Put together video parts
This is useful when a video is in several parts and you want to put it together without re-encoding (e.g. old Twitch VOD parts). Create a text file called e.g. concat.txt, containing the lines:
file 'live_user_joshimuz_1408262284.flv'
file 'live_user_joshimuz_1408263805.flv'
file 'live_user_joshimuz_1408265325.flv'
Then use the command:
ffmpeg -f concat -i concat.txt -c copy output.mp4