小编som*_*tes的帖子

ffmpeg 4.0 解码 h264 比旧版本 (n2.8.14) 慢

我使用 ffmpeg 解码 h264 并转码为 jpeg。
我以前用的2.8版本,现在改成4.0了。
新版本 avcodec_decode_video2 已弃用,因此我使用新 API(发送、接收)。
发现新版ffmpeg在解码h264时比旧版慢很多。
这是为什么?如何达到原来的速度?

这是解码器初始化代码?
版本 2.8

//2.8
if (avformat_open_input(&format_, path, NULL, &options) != 0) {
    printf("FileMediaBase: open input failed\n");
    return -1;
}
if (avformat_find_stream_info(format_, NULL) < 0) {
    printf("FileMediaBase: avformat_find_stream_info failed\n");
    avformat_close_input(&format_);
    return -1;
}
AVCodecContext *code_ctx = 0;
AVCodec *codec = 0;
// Find the first audio and video stream
for (int i = 0; i < format_->nb_streams; i++) {
    code_ctx = format_->streams[i]->codec;
    codec = avcodec_find_decoder(code_ctx->codec_id);
    if (code_ctx->codec_type == …
Run Code Online (Sandbox Code Playgroud)

ffmpeg

3
推荐指数
2
解决办法
1021
查看次数

标签 统计

ffmpeg ×1