ffmpeg +libx264 iPhone ->; “avcodec_encode_video”始终返回 0 。请指教

发布于 2024-11-10 17:27:38 字数 1341 浏览 8 评论 0原文

av_register_all();

        AVCodec *codec;
        AVCodecContext *c= NULL;
        int  out_size, size, outbuf_size;
        //FILE *f;
        uint8_t *outbuf;

        printf("Video encoding\n");

        /* find the mpeg video encoder */
        codec =avcodec_find_encoder(CODEC_ID_H264);//avcodec_find_encoder_by_name("libx264"); //avcodec_find_encoder(CODEC_ID_H264);//CODEC_ID_H264);
        NSLog(@"codec = %i",codec);
        if (!codec) {
            fprintf(stderr, "codec not found\n");
            exit(1);
        }   
c= avcodec_alloc_context();

        /* put sample parameters */
        c->bit_rate = 400000;
        c->bit_rate_tolerance = 10;
        c->me_method = 2;
        /* resolution must be a multiple of two */
        c->width = 352;//width;//352;
        c->height = 288;//height;//288;
        /* frames per second */
        c->time_base= (AVRational){1,25};
        c->gop_size = 10; /* emit one intra frame every ten frames */
        //c->max_b_frames=1;
        c->pix_fmt = PIX_FMT_YUV420P;

        c ->me_range = 16;
        c ->max_qdiff = 4;
        c ->qmin = 10;
        c ->qmax = 51;
        c ->qcompress = 0.6f;

'avcodec_encode_video' 始终为 0 。

我猜是因为“非严格单调 PTS”警告,你知道同样的情况吗?

av_register_all();

        AVCodec *codec;
        AVCodecContext *c= NULL;
        int  out_size, size, outbuf_size;
        //FILE *f;
        uint8_t *outbuf;

        printf("Video encoding\n");

        /* find the mpeg video encoder */
        codec =avcodec_find_encoder(CODEC_ID_H264);//avcodec_find_encoder_by_name("libx264"); //avcodec_find_encoder(CODEC_ID_H264);//CODEC_ID_H264);
        NSLog(@"codec = %i",codec);
        if (!codec) {
            fprintf(stderr, "codec not found\n");
            exit(1);
        }   
c= avcodec_alloc_context();

        /* put sample parameters */
        c->bit_rate = 400000;
        c->bit_rate_tolerance = 10;
        c->me_method = 2;
        /* resolution must be a multiple of two */
        c->width = 352;//width;//352;
        c->height = 288;//height;//288;
        /* frames per second */
        c->time_base= (AVRational){1,25};
        c->gop_size = 10; /* emit one intra frame every ten frames */
        //c->max_b_frames=1;
        c->pix_fmt = PIX_FMT_YUV420P;

        c ->me_range = 16;
        c ->max_qdiff = 4;
        c ->qmin = 10;
        c ->qmax = 51;
        c ->qcompress = 0.6f;

'avcodec_encode_video' is always 0 .

I guess that because 'non-strictly-monotonic PTS' warning, do you konw same situation?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你丑哭了我 2024-11-17 17:27:39

对我来说它也总是返回 0。但编码很好。我认为如果它返回 0,则不会有问题。在 avcodec.h 中,您可以看到

“错误时返回负值,成功时返回零或数字”
* 输出缓冲区使用的字节数。”

For me also it returns 0 always. But encodes fine. I dont think there is an issue if it returns 0. In the avcodec.h, you can see this

"On error a negative value is returned, on success zero or the number
* of bytes used from the output buffer."

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文