[Libav-user] Writing .mkv files with libav API

vishnukumarmdu vishnukumarmdu at gmail.com
Wed Oct 8 07:30:51 CEST 2014


Hi,

i also facing the same problem.  my code is same as what you have mentioned
as solution.  but still i am having same problem.  please find sample code
below.

 av_init_packet(&pkt);
    pkt.data = NULL;    // packet data will be allocated by the encoder
    pkt.size = 0;
    int out_size =
ffmpeg::avcodec_encode_video(pCodecCtx,outbuf,outbuf_size,ppicture);
    //printf("Frame size: %d\n",out_size);
    if (out_size > 0)
    {
        if (pCodecCtx->coded_frame->pts != AV_NOPTS_VALUE)
        //if (pCodecCtx->coded_frame->pts !=
((unsigned)0x8000000000000000LL))
            pkt.pts= av_rescale_q(pCodecCtx->coded_frame->pts,
pCodecCtx->time_base, pVideoStream->time_base);
        if(pCodecCtx->coded_frame->key_frame)
            pkt.flags |= AV_PKT_FLAG_KEY;
        pkt.pts = i;
        i++;
        //pkt.stream_index= pVideoStream->index;
        pkt.data= outbuf;
        pkt.size= out_size;
        int ret = av_interleaved_write_frame(pFormatCtx, &pkt);
        //int ret = av_write_frame(pFormatCtx, &pkt);
        //printf("Wrote %d\n",ret);
        if(ret<0)
            return -1;
         av_free_packet(&pkt);
    }



--
View this message in context: http://libav-users.943685.n4.nabble.com/Writing-mkv-files-with-libav-API-tp4657443p4660519.html
Sent from the libav-users mailing list archive at Nabble.com.


More information about the Libav-user mailing list