1

I have a directory full of *.jpg images which I want to concatenate to a video. This works fine with the concat-video filter:

ffmpeg -f concat -safe 0 -i files.txt -c:v libx264 -pix_fmt yuv420p out.mp4

The file.txt contains the list of absolute pathnames of the images. This list is created by the find-command on linux bash.

Now I want to add a text overlay, where every image shows a text representing the creation date.

I found the drawtext video-filter like in this answer: Text on video ffmpeg

However, I think I cannot set a video-filter per file when using the concat filter; I understand I can only set one filter for the whole ffmpeg-call.

Is there any other way to concatenate the files to a video and add text individually to each image?

EDIT: A trivial solution is to add the text to the images first by iterting the images. This would either irreversably change the images or create copies and thus double the disk space requirement even temporarily. It would be preferable to add the text on-the-fly for each frame so that there is no additional disk space required.

Hauke
  • 134
  • 10
  • You'll need to loop through the images: `ffmpeg -i image.jpg -vf drawtext=text='$filename' image.png` and then concat the PNGs like you did with JPGs. – Gyan Apr 16 '18 at 06:18
  • 1
    ok, this would result in a temporary copy of each input file. With restricted space on a multi-GB-set of input files this could be a problem. I'll edit the question to make clear that it would be preferred to do this in one iteration. – Hauke Apr 16 '18 at 06:46
  • 1
    Then you'll need a subtitles file, which you'll have to manually create. Sample file seen [here](https://matroska.org/technical/specs/subtitles/srt.html). For simplicity's sake, you can ingest the frames as 1 fps and then retime as 25 fps: `ffmpeg -f concat -r 1 -safe 0 -i files.txt -vf subtitles=file.srt,setpts=N/25/TB -r 25 -c:v libx264 -pix_fmt yuv420p out.mp4`. Because the stream is still 1 fps at the stage of drawing subtitles, your timings for each subtitle entry can be simple: `00:00:05,000 --> 00:00:06,000` – Gyan Apr 16 '18 at 07:00
  • Thanks, that's a very good hint, I'll give it a try. – Hauke Apr 17 '18 at 09:37
  • I am not an expert but you can use cache directory if you are worried about storage. – Shubham AgaRwal Jul 23 '18 at 10:14

0 Answers0