[FFmpeg-trac] #2874(avformat:open): Export image2 file name as frame metadata

FFmpeg trac at avcodec.org
Sat Dec 7 18:52:17 EET 2019


#2874: Export image2 file name as frame metadata
-------------------------------------+-------------------------------------
             Reporter:  jlubeck      |                    Owner:
                 Type:  enhancement  |                   Status:  open
             Priority:  wish         |                Component:  avformat
              Version:  git-master   |               Resolution:
             Keywords:  drawtext     |               Blocked By:
  image2                             |
             Blocking:               |  Reproduced by developer:  1
Analyzed by developer:  0            |
-------------------------------------+-------------------------------------

Comment (by AlexSmith):

 While this is not marked as solved, a handy solution is to define a tag
 within each image with the desired value. In this case, I'm defining tag
 ImageDescription to contain the path to each file found. Like this:


 {{{
 find -name "*.JPG" -exec exif --tag="ImageDescription" --ifd=0 --set-
 value="{}" --output="{}" "{}" \;
 }}}


 Or, if you need more control over what's being saved to the metatag, you
 can use:

 find -name "*.JPG" | while read f; do exif --tag="ImageDescription"
 --ifd=0 --set-value="$f" --output="$f" "$f"; done

 Then issuing something ffmpeg like this:


 {{{
 ffmpeg -f image2 -pattern_type glob -framerate 12 -i
 '/path/to/some/dir/*.JPG' -s 1920x1080 -b:v 3M -filter_complex
 drawtext="fontsize=h/20:fontcolor=white:fontfile=/usr/share/fonts/truetype/freefont/FreeSans.ttf:text='%{metadata\:DateTime\:notfound}':x=0:y=100",drawtext="fontsize=h/20:fontcolor=white:fontfile=/usr/share/fonts/truetype/freefont/FreeSans.ttf:text='%{metadata\:ImageDescription\:NA}':x=0:y=250"
 foo.avi
 }}}


 The above will use drawtext for two things:

 1. Drawing the contents of DateTime metadata.
 2. Drawing the contents of ImageDescription metadata.

 Hope this helps someone out there.

--
Ticket URL: <https://trac.ffmpeg.org/ticket/2874#comment:13>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list