playerdemo icon indicating copy to clipboard operation
playerdemo copied to clipboard

新版的FFMPEG有许多api已经废弃了,能提供下项目内某些函数的思路嘛?

Open swltown opened this issue 10 months ago • 0 comments

int VideoCtl::audio_thread(void *arg) { VideoState *is = (VideoState *)arg; AVFrame *frame = av_frame_alloc(); Frame *af;

int got_frame = 0;
AVRational tb;
int ret = 0;

if (!frame)
    return AVERROR(ENOMEM);

do {
    if ((got_frame = decoder_decode_frame(&is->auddec, frame, NULL)) < 0)
        goto the_end;

    if (got_frame) {
        tb = { 1, frame->sample_rate };

        if (!(af = frame_queue_peek_writable(&is->sampq)))
            goto the_end;

        af->pts = (frame->pts == AV_NOPTS_VALUE) ? NAN : frame->pts * av_q2d(tb);
        af->pos = av_frame_get_pkt_pos(frame);
        af->serial = is->auddec.pkt_serial;
        af->duration = av_q2d({ frame->nb_samples, frame->sample_rate });

        av_frame_move_ref(af->frame, frame);
        frame_queue_push(&is->sampq);

    }
} while (ret >= 0 || ret == AVERROR(EAGAIN) || ret == AVERROR_EOF);

the_end:

av_frame_free(&frame);
return ret;

} 比如说这个函数,新版本里面av_frame_get_pkt_pos已经废弃,Frame这个自定义的结构体是必须要用到pos这个成员吗?

swltown avatar Apr 06 '24 07:04 swltown