User Tools

Site Tools


ffmpeg:subtitles:add_subtitles_from_a_srt_file

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
ffmpeg:subtitles:add_subtitles_from_a_srt_file [2024/12/30 20:52] peterffmpeg:subtitles:add_subtitles_from_a_srt_file [2024/12/30 22:10] (current) peter
Line 5: Line 5:
 <code bash> <code bash>
 ffmpeg -i input.mp4 -i subtitle.srt -c copy -c:s mov_text -metadata:s:s:0 language=eng output.mp4 ffmpeg -i input.mp4 -i subtitle.srt -c copy -c:s mov_text -metadata:s:s:0 language=eng output.mp4
 +
 +ffmpeg -i input.mp4 -i subtitle.srt -c copy -c:s srt -metadata:s:s:0 language=eng output.mkv
 </code> </code>
  
-**NOTE:**+<WRAP info> 
 +**NOTE:** Different syntax is used for MP4 and MKV. 
  
   * **-c** copy specifies that the video is not to be re-encoded.   * **-c** copy specifies that the video is not to be re-encoded.
   * **-c:s mov_text** sets the SRT file to MOV_TEXT format.   * **-c:s mov_text** sets the SRT file to MOV_TEXT format.
 +  * **-c:s srt** sets the SRT file to SRT format for MKV.
   * **-metadata:s:s:0** means to set the metadata for Stream:Subtitle:Number of stream, starting with 0.   * **-metadata:s:s:0** means to set the metadata for Stream:Subtitle:Number of stream, starting with 0.
   * **language=eng** sets the subtitle language to English.   * **language=eng** sets the subtitle language to English.
     * The value for this option uses the [[https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes|ISO 639]] language code which consists of 3 letters for every language.     * The value for this option uses the [[https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes|ISO 639]] language code which consists of 3 letters for every language.
 +
 +</WRAP>
  
 ---- ----
Line 29: Line 35:
   * **subtitles=subtitle.srt** is the name of the filter followed by the name of the SRT subtitle file.   * **subtitles=subtitle.srt** is the name of the filter followed by the name of the SRT subtitle file.
  
 +</WRAP>
 +
 +----
 +
 +===== Adding Soft Subtitles with additional formatting =====
 +
 +Use a SRT subtitle file and change the size of the font by putting ASS style format **KEY=VALUE** pairs separated by a comma.
 +
 +<code bash>
 +ffmpeg -i input.mp4 -vf subtitles=sub.srt:force_style='FontName=DejaVu Serif,FontSize=24' -vcodec libx264 -acodec copy -q:v 0 -q:a 0 output.mp4
 +</code>
 +
 +<WRAP info>
 +**NOTE:**  This will put the subtitles with DejaVu font and size 24 while keeps the quality of the video.
 </WRAP> </WRAP>
  
ffmpeg/subtitles/add_subtitles_from_a_srt_file.1735591928.txt.gz · Last modified: 2024/12/30 20:52 by peter

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki