Skip to content

Instantly share code, notes, and snippets.

@vitalyford
Last active December 23, 2023 03:12
Show Gist options
  • Save vitalyford/e5e95b3782d1adb45e35fcacfa514396 to your computer and use it in GitHub Desktop.
Save vitalyford/e5e95b3782d1adb45e35fcacfa514396 to your computer and use it in GitHub Desktop.
Convert mov to mp4 with scale and padding using ffmpeg. Crop and pad video.
ffmpeg -i v.MOV -vcodec h264 -aspect 16:9 -vf "scale=608x1080,pad=1920:1080:656:0:black" v-out.mp4
ffmpeg -i v.mp4 -vf "crop=1280:640:0:0,pad=1280:720:0:0" v-out.mp4
for i in *.mkv; do ffmpeg -i "$i" "${i%.*}.mp4"; done
# get audio
for i in *.mkv; do ffmpeg -i "$i" -q:a 0 -map a "${i%.*}.mp3"; done
# normalize audio
ffmpeg-normalize input.mp4 -o output.mp4 -c:a aac -b:a 192k
# increase volume
ffmpeg -i input.mp4 -filter:a "volume=1.5" output.mp4
# cut parts out and stitch them together
ffmpeg -i boxcast.mp4 -filter_complex \
"[0:v]trim=start=443:end=5846,setpts=PTS-STARTPTS[av]; \
[0:a]atrim=start=443:end=5846,asetpts=PTS-STARTPTS[aa]; \
[0:v]trim=start=5902:end=6751,setpts=PTS-STARTPTS[bv]; \
[0:a]atrim=start=5902:end=6751,asetpts=PTS-STARTPTS[ba]; \
[av][bv]concat[outv];[aa][ba]concat=v=0:a=1[outa]" -map [outv] -map [outa] out.mp4
# concat 2 videos
ffmpeg -i no_audio_slide_video.mp4 -i main_video.mp4 -filter_complex "[0:v][0:a][1:v][1:a]concat=n=2:v=1:a=1" -vsync vfr output.mp4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment