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」という警告が出ているので、同じ状況だと思いますか?

4

1 に答える 1

0

私にとっても、常に0を返します。しかし、うまくエンコードされます。0 が返されても問題はないと思います。avcodec.h で、これを確認できます。

「エラーの場合は負の値が返され、成功の場合はゼロまたは出力バッファから使用されたバイト数 * が返されます。」

于 2014-01-02T11:17:49.797 に答える