Skip to content

Instantly share code, notes, and snippets.

@johnchristopher
Last active January 17, 2023 04:15
  • Star 11 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save johnchristopher/387fd3134b84d5476b7d to your computer and use it in GitHub Desktop.
FFmpeg subtitles commands
ffmpeg -i input.mp4 \
-map 0:1 \
-c:a copy \
-y output.m4a
for files in *flac ; \
do ffmpeg -i "$files" \
-map 0:0 \
-strict experimental \
-c:a aac \
-b:a 224k \
-y "./m4a/$files.m4a" ; \
done

Overlay

ffmpeg -i input.mp4 \
       -vf "movie=overlay.png [watermark]; [in][watermark] overlay=main_w-overlay_w-10:10 [out]"
       -c:v h264
       -c:a copy
       output-overlay.mp4

Burned subs

ffmpeg -i output-overlay.mp4 \
       -vf "subtitles=input.srt" \
       -c:v h264 \
       -c:a copy \
       output-overlay-subs.mp4

Overlay et burned subs via filter_complex

ffmpeg -i input.mp4 \
	   -i input.png \
	   -filter_complex "[0:0][1:0]overlay=main_w-overlay_w-10:10,subtitles=input.srt" \
	   -c:v h264 \
	   -c:a copy \
	   output.mp4

Non-burned subs

ffmpeg -i input.mp4 \
	   -sub_charenc UTF-8 \
	   -i input.srt \
	   -vcodec copy \
	   -acodec copy \
	   -scodec mov_text \
	   -metadata:s:s:0 language=fre output.mp4

Scaling

ffmpeg -i input.mp4 \
	   -vf scale=1024:-1 \
	   -c:a copy \
	   output.mp4

Scaling

ffmpeg -i input.mp4 \
	   -s 1024/576 \
	   -c:a copy \
	   output.mp4
@amir7700
Copy link

how can i get .srt file frome berned video

@johnchristopher
Copy link
Author

Most of the time you can't. And not with ffmpeg

Now maybe you could train a model to extract letters from frames, I suppose we now have the tools to apply ML to that (but I don't have the skills to do it).

@dhxmo
Copy link

dhxmo commented Jan 17, 2023

is it possible to display subtitles vertically down rather than horizontally across with ffmpeg?

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