2

right now, I want to add the filename of a video as text in the video itself. So if the video is in the file 'video2.mp4', there should be 'video2' written in the center of the video. How can I do this with drawtext?

Niklas Wünsche
  • 101
  • 1
  • 8

1 Answers1

5

enter image description here
Example of file named smptebars.mp4.

Using Bash parameter expansion:

video=yourvideo.mp4; ffmpeg -i "$video" -filter_complex "drawtext=text='${video%.*}':x=(w-text_w)/2:y=(h-text_h)/2:box=1:boxborderw=2:fontsize=18" -c:a copy outdir/"$video"
  • You didn't mention your OS, so I assumed it can use Bash.
  • The example will output to a directory named outdir.
llogan
  • 121,796
  • 28
  • 232
  • 243
  • How can i deal with the video list? – Jim Aug 20 '17 at 06:10
  • like this https://stackoverflow.com/questions/34803506/how-to-push-a-video-list-to-rtmp-server-and-keep-connect – Jim Aug 22 '17 at 03:56
  • 1
    @Jim You have several options. 1) Adapt the command in the answer then use concat demuxer to join them. 2) Or use the concat demuxer with drawtext filter using `enable` option and provide the times for each title. 3) Or use subtitles filter with SRT or ASS subtitles. – llogan Aug 22 '17 at 05:24