Skip to content

Instantly share code, notes, and snippets.

@stonly
Created March 25, 2025 14:43
Show Gist options
  • Save stonly/9d7dccdd7ca11d4bee35f984d17629f4 to your computer and use it in GitHub Desktop.
Save stonly/9d7dccdd7ca11d4bee35f984d17629f4 to your computer and use it in GitHub Desktop.
working with movie clips from the command line (Mac OSX)

Get info on an mp4 file

ffprobe -v quiet -print_format json -show_format -show_streams -print_format json "file.mp4"

convert a MP4 file to a format that MacOSX understands

ffmpeg -i file.mp4 -c:v libx264 -crf 23 -preset medium -c:a copy file_fixed.mp4

create transcript

Use MacWhisper

create ASS file based on SRT transcript

ffmpeg -sub_charenc ISO-8859-1 -i file.srt file.ass

Add subtitles based on transcript ASS file

ffmpeg -i "file.mp4" -vf "ass='file.ass'" -crf 18 -c:a copy "hardsubbed.mp4"

remove certain clips based on timestamps

ffmpeg -i hardsubbed.mp4 -filter_complex " [0:v]trim=start=0.06:end=3.66,setpts=PTS-STARTPTS[v0]; [0:a]atrim=start=0.06:end=3.66,asetpts=PTS-STARTPTS[a0]; [0:v]trim=start=4.41:end=10.02,setpts=PTS-STARTPTS[v1]; [0:a]atrim=start=4.41:end=10.02,asetpts=PTS-STARTPTS[a1]; [0:v]trim=start=11.76:end=22.52,setpts=PTS-STARTPTS[v2]; [0:a]atrim=start=11.76:end=22.52,asetpts=PTS-STARTPTS[a2]; [0:v]trim=start=23.70:end=27.88,setpts=PTS-STARTPTS[v3]; [0:a]atrim=start=23.70:end=27.88,asetpts=PTS-STARTPTS[a3]; [0:v]trim=start=29.42:end=35.52,setpts=PTS-STARTPTS[v4]; [0:a]atrim=start=29.42:end=35.52,asetpts=PTS-STARTPTS[a4]; [0:v]trim=start=36.13:end=53.08,setpts=PTS-STARTPTS[v5]; [0:a]atrim=start=36.13:end=53.08,asetpts=PTS-STARTPTS[a5]; [0:v]trim=start=54.38:end=61.50,setpts=PTS-STARTPTS[v6]; [0:a]atrim=start=54.38:end=61.50,asetpts=PTS-STARTPTS[a6]; [v0][a0][v1][a1][v2][a2][v3][a3][v4][a4][v5][a5][v6][a6]concat=n=7:v=1:a=1 [v][a] " -map "[v]" -map "[a]" trimmed.mp4

@stonly
Copy link
Author

stonly commented Mar 25, 2025

use an LLM to analyze the transcript for the timestamps to use for removing clips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment