Skip to content

Instantly share code, notes, and snippets.

@jrue
Last active July 10, 2019 01:07
Show Gist options
  • Select an option

  • Save jrue/7d4709857dad0eba07f5d3aa38866200 to your computer and use it in GitHub Desktop.

Select an option

Save jrue/7d4709857dad0eba07f5d3aa38866200 to your computer and use it in GitHub Desktop.
Attach captions to .mp4 container using ffmpeg
# Helpful links:
# https://en.wikibooks.org/wiki/FFMPEG_An_Intermediate_Guide/subtitle_options
# https://gist.github.com/scottopell/5764a12aa488eb68e730b627c0ae06ef
# https://otranscribe.com/
### Adding captions to mp4 movie stream for availibity in a number of programs.
# input_video (mp4 format only)
# captions.srt (captions in SRT format: https://en.wikipedia.org/wiki/SubRip )
# mov_text requred. This refers to the format specific to mp4s, it has nothing to do with naming
ffmpeg -i input_video.mp4 -f srt -i captions.srt -map 0:v -map 0:a -c copy -map 1 -c:s:0 mov_text -metadata:s:s:0 language=eng output.mp4
# To force subtitles if needed because audio stream is in a different language...
# First language=jpn is for the language of the audio stream, and second is the language=eng is for captions
# Subtitles will turn on automatically based on user's region.
# Language codes here: http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
ffmpeg -i input_video.mp4 -f srt -i captions.srt -c:v copy -c:a copy -metadata:s:a:0 language=jpn -c:s mov_text -metadata:s:s:0 language=eng -disposition:s:s:0 forced output.mp4
#Autosub
#https://github.com/agermanidis/autosub
autosub -o output.srt -F srt -S en -D en -C 4 source-video.mp4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment