Sending metadata per frame with libavcodec

801 views Asked by At

I'm trying to send some metadata with every frame that I encode. I've tried this:

Encoder side:

AVDictionary *myMeta = NULL;
int ret = av_dict_set(&myMeta, "temp_data", "test", 0);
if (ans < 0)
{
    cout << "Error: " << ret << endl;
}
av_frame_set_metadata(frameToEncode, myMeta);

Decoder side:

AVDictionaryEntry *e;
AVDictionary *dict = NULL;
dict = av_frame_get_metadata(decodedFrame);
if (dict != NULL)
{
    if (e = av_dict_get(dict, "temp_data", NULL, AV_DICT_IGNORE_SUFFIX)) {
        cout << e->value << endl;
    }
}

I'm using x264 to encode. After I decode the data, the metadata member of decodedFrame is NULL.

Any ideas?

Thanks.

0

There are 0 answers