[FFmpeg-devel] [RFC] avfilter/image2: Add source file path and basename to each packet side data.

Alexandre Heitor Schmidt alexandre.schmidt at gmail.com
Sun Dec 29 21:41:16 EET 2019

On 26/12/2019 14:01, Alexandre Heitor Schmidt wrote:
 > > you may have to only activate this (or at least the full path 
metadata) feature
 > > if the user explicitly requests it. Probably the best way to do 
that is to
 > > introduce a new option of the image2 demuxer, probably with an 
 > > type.
 > Do you mean image2 should, for example, have another option like 
'enable_path_metadata' which would make the demuxer export the metadata 
only when set to "1"?

Can I add a new parameter to VideoDemuxData in img2.h, named 
export_path_metadata, which, when explicitly set to 1, will allow 
exporting input path as the special metadata parameters 
(lavf.image2dec.source_path and lavf.image2dec.source_basename)? The 
default will be not to export them, so it won't compromise security, as 
discussed previously in this thread.

Something like this:

In img2.h:

typedef struct VideoDemuxData {
     const AVClass *class;  /**< Class for private options. */
     int img_first;
     int img_last;
     int img_number;
     int64_t pts;
     int img_count;
     int is_pipe;
     int split_planes;       /**< use independent file for each Y, U, V 
plane */
     char path[1024];
     char *pixel_format;     /**< Set by a private option. */
     int width, height;      /**< Set by a private option. */
     AVRational framerate;   /**< Set by a private option. */
     int loop;
     int pattern_type; /**< PatternType */
     int use_glob;
     glob_t globstate;
     int start_number;
     int start_number_range;
     int frame_size;
     int ts_from_file;
     int export_path_metadata; /**< enabled when set to 1. */
} VideoDemuxData;

In img2dec.c:

     { "framerate",    "set the video framerate", OFFSET(framerate),    
AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, INT_MAX, DEC }, \
     { "pixel_format", "set video pixel format", OFFSET(pixel_format), 
AV_OPT_TYPE_STRING,     {.str = NULL}, 0, 0,       DEC }, \
     { "video_size",   "set video size", OFFSET(width),        
AV_OPT_TYPE_IMAGE_SIZE, {.str = NULL}, 0, 0,       DEC }, \
     { "loop",         "force loop over input file sequence", 
OFFSET(loop), AV_OPT_TYPE_BOOL,   {.i64 = 0   }, 0, 1,       DEC }, \
     { "export_path_metadata", "enable metadata containing input path 
information", OFFSET(export_path_metadata), AV_OPT_TYPE_BOOL, {.i64 = 
0   }, 0, 1,       DEC }, \
     { NULL },


More information about the ffmpeg-devel mailing list