0

I'm extending an existing codec (Hap) inside ffmpeg library, adding some additional stuff to it (modifying FFmpeg code in my own fork of it)

One of the things I'd like to do is to store a per-file maximum encoded packet size in some global header/metadata so I can use it later while doing decoding (generally, the metadata/info to store can be arbitrary, size is just what I currently need for some specialized decoder I'm writing).

I'm modifying the ffmpeg code file https://github.com/FFmpeg/FFmpeg/blob/master/libavcodec/hapenc.c

EDIT: What I'd like to achieve

  • Compute some numeric value during the encoding (namely, the maximum encoded frame size for the video - it's needed for a specialized fast decoder to not read all the frames beforehand) - that is done already
  • Store that value in the video file metadata (looks like it should be done on container level)

My initial incorrect attempt: But I don't currently see any possibility to save any info outside of a single packet being produced by hap_encode function and written to AVPacket *pkt parameter.

  1. Set dict parameter on AVCodecContext *avctx's priv_data:
    av_opt_set_int(avctx->priv_data, "max_compressed_frame_size", <size>, 0);
    av_opt_set(avctx->priv_data, "max_compressed_frame_size", "<size_str>", 0);

Later, while decoding av_opt_get/av_opt_get_int report non-existing key.

  1. Set various AVCodecContext *avctx fields:
    avctx->flags2 = <size>;
    avctx->extradata_size = <size>;
    avctx->ticks_per_frame = <size>;
    avctx->delay = <size>;

They all also seem to be not preserved when doing decoding later (I get just default values from decoder's AVCodecContext)

leavittx
  • 87
  • 5
  • 1
    The parameters you are setting / modifying are encoding parameters and not metadata. Please explain what do you mean by "embed additional metadata". – Rotem Mar 01 '23 at 21:00
  • @Rotem Yes, looks like I'm doing it wrong at the moment. (A) I'd like to compute some value during the encoding (namely, the maximum encoded frame size for the video - it's needed for a specialized fast decoder to not read all the frames beforehand). (B) Then I'd like to store that value in the video metadata (I assume it should be done on container level but I don't know how to pass info from encoder to mov muxer and how to do it only add in case of specific codec). (C) Then I will read that stored value in my decoder app which is using ffmpeg C API for demuxing the video file. – leavittx Mar 03 '23 at 12:26

0 Answers0