Skip to content

Instantly share code, notes, and snippets.

@Bobronium
Last active May 29, 2022 21:45
Show Gist options
  • Save Bobronium/ff572f25332dbcf41e922ad632259a08 to your computer and use it in GitHub Desktop.
Save Bobronium/ff572f25332dbcf41e922ad632259a08 to your computer and use it in GitHub Desktop.
Cut out fragment of a video with burned subtitles for Telegram
input_file=in.mp4
output_file="${input_file%%.*}"-fragment."${input_file##*.}"
subs_file= # can be srt file or mkv container with subtitles
start_from=
stop_at=
duration=
# delete lines below that contain empty optional variables from above before use
# if duration is specified, '-to' or 'stop_at' is ignored
ffmpeg \
-ss "$start_from" -copyts \
-i "$input_file" \
-ss "$start_from" \
-to "$stop_at" \
-t "$duration" \
-vf subtitles="$subs_file" \
-c:v libx264 \
-crf 26 \
-ac 2 \
"$output_file"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment