【问题标题】:ffmpeg sidedata or metadata per frame每帧的ffmpeg sidedata或元数据
【发布时间】:2019-09-26 21:14:43
【问题描述】:

我正在尝试使用the FFMpeg encoding example为每帧添加一些辅助数据或元数据

这是我迄今为止尝试过的:

/* encode 1 second of video */
for (i = 0; i < 25; i++) {
    fflush(stdout);
    /* make sure the frame data is writable */
    ret = av_frame_make_writable(frame);
    if (ret < 0)
        exit(1);
    /* prepare a dummy image */
    /* Y */
    for (y = 0; y < c->height; y++) {
        for (x = 0; x < c->width; x++) {
            frame->data[0][y * frame->linesize[0] + x] = x + y + i * 3;
        }
    }
    /* Cb and Cr */
    for (y = 0; y < c->height/2; y++) {
        for (x = 0; x < c->width/2; x++) {
            frame->data[1][y * frame->linesize[1] + x] = 128 + y + i * 2;
            frame->data[2][y * frame->linesize[2] + x] = 64 + x + i * 5;
        }
    }
    frame->pts = I;

    AVFrameSideData *angle = av_frame_new_side_data (frame, AV_FRAME_DATA_GOP_TIMECODE, sizeof(int32_t));
    if(!angle)
        return AVERROR(ENOMEM);
    unint8_t a = i; 
    angle->data = &a;

    frame->side_data = angle
    /* encode the image */
    encode(c, frame, pkt, f);
}

我也尝试过使用并将其设置为 AVDictionary

AVDictionary *d = NULL;
av_dict_set(&d, "foo", "bar", 0);
frame->metadata = d;

但是没有任何东西被添加到编码中。

如何分别向每一帧添加数据?

【问题讨论】:

    标签: c ffmpeg metadata


    【解决方案1】:

    您应该尝试将数据直接应用于框架的侧面数据

    av_dict_set(&(frame->metadata), "foo", "bar", 0);
    

    同样,您可能需要在 AVFrameSideData 中分配数据。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-01-19
    • 1970-01-01
    • 1970-01-01
    • 2012-05-06
    • 2013-06-19
    • 2014-06-18
    • 1970-01-01
    相关资源
    最近更新 更多