🍡 Concatenate consecutive video parts using MKVToolNix:
mkvmerge -o output.mkv input1.mkv \+ input2.mkv \+ input3.mkv
mkvmerge -o full.mkv part1.avi \+ part2.avi
mkvmerge -o abc.mp4 a.mp4 \+ b.mp4 \+ c.mp4
📐 Apply geometric transformations to a video with relative values using FFmpeg:
ffmpeg -i $input -vf "rotate=PI,crop=2/3*in_w:3/4*in_h:0:1/4*in_h" $output
# rotate by 180 degrees and crop as follows:
# horizontal position: 0
# vertical position: 1/4 of original height
# new width: 2/3 of original width
# new height: 3/4 of original height
🎁 Change media container type without reencoding using FFmpeg:
ffmpeg -i video.mov -codec copy video.mp4
ffmpeg -i video.mp4 -codec copy video.mkv
...
🌀 Set orientation of MOV, MP4 and 3GP video files without reencoding using FFmpeg:
ffmpeg -i input.$EXT -c copy -metadata:s:v:0 rotate=$ANGLE output.$EXT
# EXT: mov, mp4, 3gp
# ANGLE: 0, 90, 180, 270 (degrees)
🔊 Extract the audio track of a video using FFmpeg:
# for editing purpose: audio is encoded uncompressed in WAVE format
ffmpeg -i video.mp4 audio.wav
# for storage purpose: audio is extracted losslessly and is supposed to be AAC encoded
ffmpeg -i video.mp4 -vn -c:a copy audio.m4a
🎼 Replace the audio track of a video using FFmpeg:
ffmpeg -i video.mp4 -i audio.wav -c:v copy -map 0:v -map 1:a video-with-new-audio.mp4
# video is not reencoded, audio is encoded in AAC
🔳 Extract a specific frame/image from a video as a PNG/JPEG file using FFmpeg:
# save frame as a lossless PNG file
ffmpeg -ss 00:00:05.01 -i video.ext -frames:v 1 -qscale:v 2 image.png
# save frame as lossy but high quality JPEG file
ffmpeg -ss 00:00:05.06 -i video.ext -frames:v 1 -qscale:v 2 image.jpg
➰ Save an M3U8 based HTTP Live Streaming to an MP4 file using FFmpeg:
ffmpeg -protocol_whitelist file,http,https,tcp,tls,crypto -i index.m3u8 -c copy -bsf:a aac_adtstoasc stream.mp4