Skip to content

Instantly share code, notes, and snippets.

@yamachu
Last active November 24, 2021 13:15
Show Gist options
  • Save yamachu/5500db0266293ecc066030f49c2d7477 to your computer and use it in GitHub Desktop.
Save yamachu/5500db0266293ecc066030f49c2d7477 to your computer and use it in GitHub Desktop.

setup required tools

brew install gstreamer gst-plugins-base gst-plugins-good gst-plugins-bad gst-plugins-ugly ffmpeg

convert vtt to srt (if using vtt)

in: sub.vtt
out: sub.srt

ffmpeg -i sub.vtt sub.srt

mix video(exclude audio...) and sub

in: original.mp4
in: sub.srt
out: video.mp4

gst-launch-1.0 -v \
  filesrc location=sub.srt ! subparse ! txt. \
  filesrc location=original.mp4 ! decodebin ! textoverlay name=txt shaded-background=yes draw-outline=yes ! x264enc ! mp4mux ! filesink location=video.mp4

extract audio track

in: original.mp4
out: audio.aac (codec dependent?)

ffmpeg -i original.mp4 -vn -acodec copy audio.aac

mix audio and video into mp4 file

in: video.mp4
in: audio.aac
out: output.mp4

ffmpeg -i video.mp4 -i audio.aac -c:v copy -c:a copy output.mp4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment