usunyu   Stay hungry. Stay foolish.

FFmpeg Useful Commands

Download and install ffmpeg

Merging audio and video

1. In case of MP4 format (all, except 1440p 60fps & 2160p 60fps):
$ ffmpeg -i video.mp4 -i audio.m4a -c:v copy -c:a copy output.mp4
2. In case of WebM format (1440p 60fps and 2160p 60fps):
$ ffmpeg -i videoplayback.webm -i videoplayback.m4a -c:v copy -c:a copy output.mkv

Split video with specific timestamp

$ ffmpeg -i output.mp4 -ss 0 -t 60 first-60-sec.mp4

Replace old audio stream with target audio stream

$ ffmpeg -i video.mp4 -i audio.mp3 -c:v copy -c:a aac -strict experimental -map 0:v:0 -map 1:a:0 output.mp4

Concatenate multipe video files

$ cat concat.txt
file '/path/to/video1.mp4'
file '/path/to/video2.mp4'
file '/path/to/video3.mp4'

$ ffmpeg -f concat -i concat.txt -c copy output.mp4