3

I have two time lapse videos with a rate of 1 fps. The camera took 1 Image every minute. Unfortunately it was missed to set the camera to burn/print on every image the time and date. I am trying to burn the time and date afterwards into the video.

I decoded with ffmpeg the two .avi files into ~7000 single images each and wrote a R script that renamed the files into their "creation" date (the time and date the pictures where taken). Then i used exiftoolto write those information "into" the file, into their exif data or meta data or whatever this is called.

The final images in the folder are looking like this:

2018-03-12 17_36_40.png

2018-03-12 17_35_40.png

2018-03-12 17_34_40.png

...

Is it possible to create a Video from these images again with ffmpeg or similiar with a "timestamp" in the video so you can see while watching a time and date stamp in the video?

Community
  • 1
  • 1
m4D_guY
  • 166
  • 1
  • 11

2 Answers2

2

I think this can be done in two steps.

  1. First you create a mp4 file with the timestamp for every picture. This is a batch file which creates such video files.
    @echo off
    set "INPUT=C:\t\video"
    for %%a in ("%INPUT%\*.png") do (
      ffmpeg -i "%%~a" -vf "drawtext=text=%%~na:x=50:y=100:fontfile=/Windows/Fonts/arial.ttf:fontsize=25:fontcolor=white" -c:v libx264 -pix_fmt yuv420p "output/%%~na.mp4"
    )

This will create mp4 for every png picture in the directory output/.

Explaining

For cycle is there loop via all *.png files and create *.mp4 files

The text is added via text overlay. It adds the filename without suffix via batch %%~na.

  • The text added here is the filename without the .png suffix.
  • Font used is arial.ttf (feel free to place any you want)
  • Next have x and y coordinates where you want to place the text
  • libx264 what x264 is used to encode
  • -pix_fmt yuv420p is for crappy players to be able to play it
  1. Second step is to concate h.264 together using concat demuxer:

You need to create a file list like file_list.txt

    file '2018-03-12 17_34_40.mp4'
    duration 10
    file '2018-03-12 17_35_40.mp4' 
    duration 10
    file '2018-03-12 17_36_40.mp4'
    duration 10
 ... 

Examples can be found here.

Then you simply concat all the *.mp4 files - run in the output subdirectory:

ffmpeg -safe 0 -f concat -i file_list.txt -c copy output.mp4

Which will create one concat output.mp4 file.

tukan
  • 17,050
  • 1
  • 20
  • 48
  • 1
    Thank you for your time, this is definitely one option, I've been doing a bit more digging and found a few more options, for others coming here: https://www.reddit.com/r/ffmpeg/comments/mye9h1/timestamp_from_metadata_on_image_timelapse/ – Mint Oct 23 '21 at 01:51
  • 1
    @Mint you are welcome. I'm sure there are more ways to do it. This came into my mind. – tukan Oct 23 '21 at 13:41
0

If I understand correctly, you have some number of YUV frames and its information saved separately.

For example: Let's say you originally have 10seconds video at 24 frames per seconds (constant, not variable). So you have 240 yuv frames. In this case or similar, you can generate a video file via ffmpeg with a container format like mp4, with the resolution and frame rate information. So you will not need any metadata to make it back to video or to play, it will play normally in any decent player.

If you have only KEY FRAMES with different frame timing between them, yes you will need the metadata information and I'm not sure how can you do that.

Since you have the source, you can extract every single frame (24 frames in this example) per second and you are good to go. Similar answers already given for these, just look around.

Hope that helps.

the kamilz
  • 1,860
  • 1
  • 15
  • 19
  • 1
    Hey, sorry i maybe i wrote my post confusing i will edit it. I meant that i 1 fps in the video and the time lapse camera took i picture every minute. Unfortunately it was missed to set the camera to print or burn in every image the time and date when it was taken. I am trying to reconstruct this now... – m4D_guY Mar 16 '18 at 10:30