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

FFmpeg trac at avcodec.org
Fri Dec 13 12:12:51 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):

 Hi, [comment:17 jlubeck]!

 Make sure you're using exif the right way. For example:

 {{{
 exif -c --tag="DateTime" --ifd=0 --set-value="2011-12-13 14:15:16"
 --output="/tmp/new.jpg" /tmp/2019.12.03_22.26.52.jpg
 }}}

 Note -c was necessary here as your original image appears to not have an
 EXIF header.

 After this, we can see the frame with ffprobe:


 {{{
 $ ffprobe -i new.jpg -show_frames
 [FRAME]
 media_type=video
 stream_index=0
 key_frame=1
 pkt_pts=0
 pkt_pts_time=0.000000
 pkt_dts=0
 pkt_dts_time=0.000000
 best_effort_timestamp=0
 best_effort_timestamp_time=0.000000
 pkt_duration=1
 pkt_duration_time=0.040000
 pkt_pos=N/A
 pkt_size=54705
 width=1280
 height=720
 pix_fmt=yuvj420p
 sample_aspect_ratio=1:1
 pict_type=I
 coded_picture_number=0
 display_picture_number=0
 interlaced_frame=0
 top_field_first=0
 repeat_pict=0
 color_range=pc
 color_space=bt470bg
 color_primaries=unknown
 color_transfer=unknown
 chroma_location=center
 TAG:XResolution=     72:1
 TAG:YResolution=     72:1
 TAG:ResolutionUnit=    2
 TAG:DateTime=2011-12-13 14:15:16     <<<-------
 TAG:YCbCrPositioning=    1
 TAG:ExifVersion= 48,  50,  49,  48
 TAG:ComponentsConfiguration=  1,   2,   3,   0
 TAG:FlashpixVersion= 48,  49,  48,  48
 TAG:ColorSpace=65535
 TAG:PixelXDimension=      0
 TAG:PixelYDimension=      0
 [/FRAME]
 }}}

 This is what interests us:

 {{{
 TAG:DateTime=2011-12-13 14:15:16
 }}}

 Then we can use this tag with drawtext. For example:

 {{{
 ffmpeg -f image2 -i new.jpg -filter_complex
 drawtext="fontsize=50:fontcolor=white:fontfile=/usr/share/fonts/truetype/freefont/FreeSans.ttf:borderw=2:bordercolor=black:text='%{metadata\:DateTime\:notfound}':x=100:y=100"
 out.avi
 }}}

 Hope that helps...

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


More information about the FFmpeg-trac mailing list