2

I am trying to burn (hardcode) an SRT file and a timecode value to a MP4 file, but to no avail.

I am currently burning the srt and timecode using the below commands:

Burn SRT

ffmpeg -i input.mp4 -vf subtitles=subs.srt out.mp4

Burn Timecode

ffmpeg -i input.mp4  -filter_complex "drawtext=fontfile=/Windows/Fonts/arial.ttf:x=320:y=main_h-50:fontsize=32:fontcolor='white':timecode='00\:00\:00\:00':rate=29.97" -y output.mp4

However, I am not able to combine the two into a single command as ffmpeg does not allow usage of -vf and -filter_complex together.

Is there a workaround?

Rahul Prasad
  • 21
  • 1
  • 3

2 Answers2

1

You can chain together filters in a series. This creates a filterchain. A series of connected filterchains is a filtergraph.

ffmpeg -i input.mp4 -vf "drawtext,subtitles" -c:a copy output.mp4
  • -vf is used for simple (video) filtergraphs which consists one input and one output.

  • -filter_complex is used for complex filtergraphs which consists of one or more inputs and/or one or more outputs. However, I don't think using -filter_complex for simple filtergraphs would cause any issues.

  • Because your input and output are MP4, I added -c:a copy to stream copy any audio since you probably don't need or want to re-encode it.

  • For potentially more accuracy consider using rate=ntsc or rate=30000/1001 instead of rate=29.97.

llogan
  • 121,796
  • 28
  • 232
  • 243
1

just for anyone who comes across this qs. You can do it with .srt file the same way I am doing it for .ass file the only difference is .ass files give us more control over font color and other things. I cant find the .srt one so I will share the .ass one which is working for me, I am using the hls output but you can again use mp4 one:

ffmpeg  -i INPUT_VIDEO_FILE.mp4 -profile:v baseline -level 4.0 -vf "scale=-2:360,subtitles='dynamic_subtitle.ass':force_style='FontName=Aaargh/Aaargh.ttf,PrimaryColour=&H664c4c4c"  -start_number 0 -hls_time 10 -hls_list_size 0 -f hls /s3_temp/video_360.m3u8
Aameer
  • 1,366
  • 1
  • 11
  • 30