ffmpeg

combine segments

$ cat mylist.txt
file '/path/to/file1'
file '/path/to/file2'
file '/path/to/file3'
    
$ ffmpeg -f concat -safe 0 -i mylist.txt -c copy output.mp4

add optional subtitles

ffmpeg -i infile.mp4 -i infile.srt -c copy -c:s mov_text outfile.mp4

time-shift subtitle file

ffmpeg -itsoffset 0.7 -i original.vtt adjusted.srt

combine video and audio without reencoding

ffmpeg -i video.mp4 -i audio.wav -c:v copy -c:a copy output.mp4

convert losslessly (v fast)

ffmpeg -i example.mkv -c copy example.mp4

convert flac to mp3. High quality

ffmpeg -i $f -b:a 320K $f.mp3

make file streamable

ffmpeg -i INPUT.mp4 -c copy -movflags faststart STREAMABLE_OUTPUT.mp4

or

ffmpeg -i  -c:v libx264 -crf 23 -c:a aac -movflags faststart output.mp4

remove a specific audio stream track

ffmpeg -i input -map 0 -map -0:a:2 -c copy output
     * -map 0 selects all streams from the input.
     * -map -0:a:2 then deselects audio stream 3. The stream index starts counting from 0, so audio stream 10 would be 0:a:9.

video not displaying in browser (only audio). Fix:

ffmpeg -i input.mp4 -c:v libx264 -preset slow -crf 20 -c:a aac -b:a 160k -vf format=yuv420p -movflags +faststart output.mp4

progress output only

ffmpeg -loglevel 0 -stats -i input.mp4 output.mp4

limit speed

-readrate 1

Where 1 appears as "speed=1x" on the stats output. It's worth checking first what speed your system achieves by default (10x in my current case) and choosing a relatively limited value (-readrate 6 in my current case) to keep the system cool and quiet.

trim first 5 seconds from video

ffmpeg -i input.mp4 -ss 5 -vcodec copy -acodec copy output.mp4
Proxy Information
Original URL
gemini://nuacht.flounder.online/gemlog/2022-09-13-ffmpeg.gmi
Status Code
Success (20)
Meta
text/gemini; charset=utf-8
Capsule Response Time
725.114147 milliseconds
Gemini-to-HTML Time
0.972614 milliseconds

This content has been proxied by September (ba2dc).