Skip to content

Instantly share code, notes, and snippets.

@HugoGresse
Last active March 19, 2024 18:57
Show Gist options
  • Save HugoGresse/92829cefb155d4ed0b6b61178af797ec to your computer and use it in GitHub Desktop.
Save HugoGresse/92829cefb155d4ed0b6b61178af797ec to your computer and use it in GitHub Desktop.
FFMPEG personal list to cut & normalize video

Setup

brew install ffmpeg

Normalize audio in place (easiest solution) EBU R128

pip install ffmpeg-normalize
ffmpeg-normalize input.mp4 -o output.mp4 -c:a aac -b:a 192k --progress

Normalize audio (without another lib)

ffmpeg -i Commentary.m4a -filter:a loudnorm Commentary2.m4a

Extract audio

ffmpeg -i video.mov -map 0:1 -c copy audio.m4a

Merge audio & video

ffmpeg -i Segment_0001.mp4 -i Commentary2.m4a -c copy  -map 0:v:0 -map 1:a:0 meetup.mp4

Cut (whitout rencoding)

The Beginning

ffmpeg -i meetup.mp4 -ss 00:00:08 -c copy meetup1.mp4

Start with total duration

ffmpeg -i in.mp4 -ss [start] -t [duration] -c copy out.mp4

missing keyframes? use -async 1 in place of -c copy to reencode the video. Longer but add missing keyframes alternative for missing keyframes: -c copy -copyinkf it doesn't reencode but does not work great

Concat (without recencoding)

cat list.txt
    file ./1.mov
    file ./2.mov

ffmpeg -safe 0 -f concat -i list.txt  -vcodec copy -acodec copy merged.mov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment