I've tried your config, but uncommented all lines except
//c->flags2|=CODEC_FLAG2_8X8DCT;
//c->flags2^=CODEC_FLAG2_8X8DCT;                // flags2=-dct8x8
and commented out
 c->crf = 22;

It seems that problem is caused by wrong value of c->keyint_min. What is
default value for it?
Try to set it manually to, say, 25 :)

2011/2/1 Sven Alisch <[email protected]>

> Hello list,
>
> I want to (re-) encode some pictures I decoded with libav. The following
> code shows how I do that:
>
> First I decode an h.264 Stream and get pictures in an AVFrame structure.
> After doing this I want to encode them into an h.264 stream.
> <snip>
> bytesDecoded =
> avcodec_decode_video2(m->videofile->VideoTrack->codec_context, avframe,
> &frameFinished, &packet);
>
> if (frameFinished)
> {
>        frameNr++;
>
>        if (frameNr >= decodeToFrame)
>        {
>                AVCodecContext* c = t->streamContext->codec;
>                avframe->pts = (frameNr - decodeToFrame)*40*90;
>                int out_size = avcodec_encode_video(c, video_outbuf,
> video_outbuf_size, avframe);
>                if (out_size > 0)
>                {
>                        ...
>                }
> <snap>
>
> My Encoding parameters for x264 are set in a function like this:
>
> bool h264_initEncoder(AVFormatContext* fc, tavtrack_t* track)
> {
>        AVCodec* codec = NULL;
>        AVCodecContext* c = NULL;
>
>        c = track->streamContext->codec;
>        c->profile = track->codec_context->profile;     // original set by
> libavformat/libavcodec
>        c->level = track->codec_context->level;         // original set by
> libavformat/libavcodec
>
>        // Medium Profile
>        // libx264-medium.ffpreset preset
>        c->coder_type = FF_CODER_TYPE_AC;       // coder = 1
>        c->flags |= CODEC_FLAG_LOOP_FILTER; // flags=+loop
>        c->me_cmp|= 1;                                          //
> cmp=+chroma, where CHROMA = 1
>        c->partitions |=
> X264_PART_I8X8+X264_PART_I4X4+X264_PART_P8X8+X264_PART_B8X8;
>
>    // partitions=+parti8x8+parti4x4+partp8x8+partb8x8
>        c->me_method=ME_HEX;                            // me_method=hex
>        c->me_subpel_quality = 7;                       // subq=7
>        c->me_range = 16;                                       //
> me_range=16
>        //c->gop_size = 250;                                    // g=250
>        //c->keyint_min = 25;                                   //
> keyint_min=25
>        c->scenechange_threshold = 40;          // sc_threshold=40
>        //c->i_quant_factor = 0.71;                     // i_qfactor=0.71
>        //c->b_frame_strategy = 1;                      // b_strategy=1
>        c->qcompress = 0.6;                                     // qcomp=0.6
>        c->qmin = 10;                                           // qmin=10
>        c->qmax = 51;                                           // qmax=51
>        c->max_qdiff = 4;                                       // qdiff=4
>        c->max_b_frames = 3;                            // bf=3
>        c->refs = 3;                                            // refs=3
>        //c->directpred = 1;                                    //
> directpred=1
>        //c->trellis = 1;                                               //
> trellis=1
>        c->flags2 |=
> CODEC_FLAG2_BPYRAMID+CODEC_FLAG2_MIXED_REFS+CODEC_FLAG2_WPRED+CODEC_FLAG2_8X8DCT+CODEC_FLAG2_FASTPSKIP;
>
>    // flags2=+bpyramid+mixed_refs+wpred+dct8x8+fastpskip
>        c->weighted_p_pred = 2;                         // wpredp=2
>
>        // libx264-main.ffpreset preset
>        //c->flags2|=CODEC_FLAG2_8X8DCT;
>        //c->flags2^=CODEC_FLAG2_8X8DCT;                // flags2=-dct8x8
>        c->crf = 22;
>        codec = avcodec_find_encoder(c->codec_id);
>        if (!codec)
>                return false;
>
>        if (avcodec_open(c, codec) < 0)
>                return false;
>
>        return true;
> }
>
> The Problem is, that the avcode_encode_video( ... ) works but no frame will
> be compressed. I get strange errors like this:
>
> [libx264 @ 0x101003600] specified frame type (5) at 0 is not compatible
> with keyframe interval
> [libx264 @ 0x101003600] specified frame type (5) at 1 is not compatible
> with keyframe interval
> [libx264 @ 0x101003600] specified frame type (3) at 2 is not compatible
> with keyframe interval
>
> I get no frame. But why? Does anybody has an hint for me? Are my parameters
> wrong?
>
> regards,
> Sven
> _______________________________________________
> libav-user mailing list
> [email protected]
> https://lists.mplayerhq.hu/mailman/listinfo/libav-user
>
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user

Reply via email to