VideoHelp Forum

+ Reply to Thread
Results 1 to 7 of 7
Thread
  1. Member hydra3333's Avatar
    Join Date
    Oct 2009
    Location
    Australia
    Search Comp PM
    Hello. I am seeking a bit of help to encode a "creation date/time" text overlay onto a video.

    I have a sequence of .jpeg images from a motion-detection config on a raspberry pi.

    Each jpeg has metadata in it, ie the time an image was captured (10 fps image captures when motion is detected, so there's lots of jpegs). There is, of course, large time-gaps between the series of images.

    I currently use the following commandline in a windows .bat file to convert the sequence of images to an .mp4 (the percent is doubled so it "works" in a .bat file).
    (no creation time displayed) ...
    Code:
    "ffmpeg.exe" -framerate 10 -start_number 1 -i "!prefix!_%%06d.jpg" -c:v h264 -preset slow -profile:v high -level 4.1 -crf 16 -coder 0 -movflags +faststart -vf "fps=10,format=yuv420p,drawtext=fontfile='C\:\\Windows\\Fonts\\arial.ttf': fontsize=20: text='Created %%{metadata\:creation_time} Video %%{pts\:hms}': r=10: x=(w-(tw*1.05)): y=main_h-(text_h*1.2): fontcolor=white@0.5: box=1: boxcolor=0x00000000@"0.5 -coder 0 -y "000-out.mp4"
    My question is, is it possible to overlay the timestamp from each image's metadata onto each matching video frame ? I need the capture timestamp, not that of the timepoint in the video.
    Quote Quote  
  2. Member Budman1's Avatar
    Join Date
    Jul 2012
    Location
    NORTHWEST ILLINOIS, USA
    Search Comp PM
    It seems like you would have to use a program such as exif to obtain the times and the a second process to list them as such as subtitles and then a third process to create the video from your images.

    Testing at 1/5 frame per second yielding a 5 second video of each image was doable but whether 10-15 fps you mention is possible would be difficult.

    Is this for use in high volume or just a short term need?
    Quote Quote  
  3. Member hydra3333's Avatar
    Join Date
    Oct 2009
    Location
    Australia
    Search Comp PM
    low volume ongoing (raspberry pi as a motion detector "home security")
    exif, ok will google that and try that as a variation of this which used the image filenames...
    Code:
    @echo on
    REM renames all of the .jpg files in the current folder to a sequence of image filenames which ffmpeg likes
    
    setlocal EnableDelayedExpansion
    
    set newpath=.\working\
    set prefix=Image
    
    MD  "%newpath%"
    DEL  "%newpath%*.png"
    
    set i=0
    for %%a in (*.jpg) do (
        set /a i+=1
        set nnn=000000000!i!
        set ooo=!nnn:~-6!
        set bbb=%%~na
        set fpre=!bbb:~0,3!
        set fyyyy=!bbb:~3,4!
        set fmo=!bbb:~7,2!
        set fdd=!bbb:~9,2!
        set fhh=!bbb:~11,2!
        set fmm=!bbb:~13,2!
        set fss=!bbb:~15,2!
        set fpost=!bbb:~17,3!
        set fstamp=!fpre!!fyyyy!.!fmo!.!fdd!-!fhh!.!fmm!.!fss!!fpost!
        set fname=!newpath!!prefix!_!ooo!.png
        "C:\SOFTWARE\ffmpeg\0-latest-x64\bin\ffmpeg.exe" -i "%%~a" -vf "format=yuv420p,drawtext=fontfile='C\:\\Windows\\Fonts\\arial.ttf': fontsize=20: text='Created %%{metadata\:creation_time} !fstamp!': x=(w-(tw*1.05)): y=main_h-(text_h*1.2): fontcolor=white@0.5: box=1: boxcolor=0x00000000@0.5" -y "!fname!"
    )
    
    REM note the double percentage sign which DOS converts into one 
    "C:\SOFTWARE\ffmpeg\ffmpeg.exe" -framerate 10 -start_number 1 -i "!newpath!!prefix!_%%06d.png" -c:v h264 -preset slow -profile:v high -level 4.1 -crf 16 -coder 0 -movflags +faststart -vf "fps=10,format=yuv420p" -coder 0 -y ".\000-out.mp4"
    
    pause
    exit
    Quote Quote  
  4. Member Budman1's Avatar
    Join Date
    Jul 2012
    Location
    NORTHWEST ILLINOIS, USA
    Search Comp PM
    The tool is exiftool and you can use the 'exiftool.exe -filename -createdate -datetimeoriginal "path\filename" ' as the entry. Then after I renamed images as you did, I created a subtitle file and used ffmpeg to add it as it created the video from images.

    I'm not at home at the moment but will try putting all together in one program if the rate thing proves doable.
    Quote Quote  
  5. Member hydra3333's Avatar
    Join Date
    Oct 2009
    Location
    Australia
    Search Comp PM
    Hello.
    It seems that the image exif data does not contain a snapshot date, when I dump it with mediainfo or exiftool.
    Quote Quote  
  6. Member Budman1's Avatar
    Join Date
    Jul 2012
    Location
    NORTHWEST ILLINOIS, USA
    Search Comp PM
    hydra3333, There is always a Created date but there is actually 2 of them. The camera may encode an ISO dtae/time and the file itself has an created date. In the 2 examples below, One has both dates and one does not. I usually used both -CreateDate and -FileCreateDate in my Exiftool request. I am currently working on a program to accomplish this task but the automation of it is the problem at the moment. Shown below are 2 different photos, one from the camera and one I had made from a camera original and converted to Jpg:

    C:\Users\Bud\Desktop\exiftool.exe -createdate -filecreatedate C:\Users\Bud\Pictures\Hass_Farm\Farm_11200509.JPG
    Create Date : 2013:05:07 10:14:28
    File Creation Date/Time : 2013:05:08 22:54:33-05:00

    C:\Users\Bud\Desktop\exiftool.exe -createdate -filecreatedate "C:\Users\Bud\Desktop\Card SizePc250019.jpg"
    File Creation Date/Time : 2013:05:06 19:08:18-05:00

    File Name : Farm_11200509.JPG
    Directory : C:/Users/Bud/Pictures/Hass_Farm
    File Size : 202 kB
    File Modification Date/Time : 2005:07:10 15:50:10-05:00
    File Access Date/Time : 2014:12:20 15:26:01-06:00
    File Creation Date/Time : 2013:05:08 22:54:33-05:00
    File Permissions : rw-rw-rw-
    File Type : JPEG
    MIME Type : image/jpeg
    Exif Byte Order : Little-endian (Intel, II)
    Image Description : OLYMPUS DIGITAL CAMERA
    Make : OLYMPUS OPTICAL CO.,LTD
    Camera Model Name : C960Z,D460Z
    Orientation : Horizontal (normal)
    X Resolution : 72
    Y Resolution : 72
    Resolution Unit : inches
    Software : v874u-74
    Modify Date : 0000:00:00 00:00:00
    Y Cb Cr Positioning : Co-sited
    Exposure Time : 1/193
    F Number : 10.9
    Exposure Program : Program AE
    ISO : 125
    Exif Version : 0210
    Date/Time Original : 0000:00:00 00:00:00
    Create Date : 2013:05:07 10:14:28
    Components Configuration : Y, Cb, Cr, -
    Quote Quote  
  7. Member hydra3333's Avatar
    Join Date
    Oct 2009
    Location
    Australia
    Search Comp PM
    Thanks for your insight!

    Code:
    exiftool.exe -createdate -Filecreatedate  01-20141214143020-07.jpg
    File Creation Date/Time         : 2014:12:18 20:44:25+10:30
    The EXIF data in the top of the file doesn't appear to have text like a camera name such as "OLYMPUS DIGITAL CAMERA .OLYMPUS OPTICAL" and instead has text like "cdefghijklmnopqtstuvwzyx" with no dates, which leads me to think the writing software isn't paying much attention to creating valid exif data ...

    The jpeg file is a direct copy of the .jpg saved by the Raspberry Pi.
    It looks like that software doesn't save exif data ...
    Oh well, time to look at alternative Rpi software.
    Quote Quote