[Libav-user] Video Playback fast

Talgorn Fran├žois-Xavier fxtalgorn at yahoo.fr
Thu Jul 2 19:22:27 CEST 2015


Hi Kevin,

I also used the .den and .num param and this led to synch issues in my project.
I tried numerous workarounds without any success.
I finally solved the synch issues by using the av_packet_rescale_ts() function that sets the timestamps based on time_base (get from streams infos).

This is my chunk of code that does it:
                avcodec_encode_video2(out_stream->codec, &styl_pkt, yuv_pix->av_frame, &got_something);
                if(!got_something)
                {
                    INFO(stderr, ":-( Unable to encode yuv frame.\n");
                    exit(0);
                }      
                //convert timestamps from in time_base to out time_base
                av_packet_rescale_ts(&styl_pkt, in_stream->time_base, out_stream->time_base);

                //log_packet(in_video_ctx->format_ctx, &orig_pkt, "Video orig. pkt");
                //log_packet(out_video_ctx->format_ctx, &styl_pkt, "Video styl. pkt");
                ret = av_write_frame(out_video_ctx->format_ctx, &styl_pkt);
                if (ret < 0)
                {
                    INFO(stderr, "Error muxing packet\n");
                    break;
                }

Hope that helps.

Le 2 juil. 2015 à 17:13, Kevin J. Brooks <kbrooks at r2c-ss.com> a écrit :

> This is were I am setting up the codec context and format:
> 
> m_videoCodecCTX->codec_id = AV_CODEC_ID_WMV2;
>     m_videoCodecCTX->bit_rate = 400000;
>     m_videoCodecCTX->width = 640;
>     m_videoCodecCTX->height = 480;
>     m_video_st.st->time_base.num = 1;
>     m_video_st.st->time_base.den = 25;
>     m_videoCodecCTX->time_base = m_video_st.st->time_base;
>     m_videoCodecCTX->gop_size = 12;
>     m_videoCodecCTX->pix_fmt = AV_PIX_FMT_YUV420P;
> 
> m_video_st.st is a AVStream pointer.  m_videoCodecCTX is a m_videoCodecCTX pointer.
> 
> Sincerely,
> Kevin J. Brooks
> Senior Software Engineer
> R2C Support Services
> 200 West Side Square Suite 604
> Huntsville, AL 35801
> Office: 256-684-8383 ext. 104 
> 
> <sdvosb.png>
> On 7/2/2015 9:59 AM, Talgorn François-Xavier wrote:
>> Hi,
>> 
>> Frames/second shouldn't be an issue in itself. It might be because of time_base parameter.
>> To help you better, could you provide the code used ?
>> 
>> Le 2 juil. 2015 à 16:41, Kevin J. Brooks <kbrooks at r2c-ss.com> a écrit :
>> 
>>> Hi all,
>>> 
>>> I am successfully saving video in a wmv format, capturing from a video capture card.  However, the play back in windows media is just a bit fast.  I am attempting to save at 25 frames per second, but the properties on the wmv file states it is 30 fps.  What should I be looking at to get this set up right?
>>> 
>>> Thanks,
>>> Kevin
>>> _______________________________________________
>>> Libav-user mailing list
>>> Libav-user at ffmpeg.org
>>> http://ffmpeg.org/mailman/listinfo/libav-user
>> _______________________________________________
>> Libav-user mailing list
>> Libav-user at ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/libav-user
>> 
> 
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/libav-user

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20150702/0a2ca918/attachment.html>


More information about the Libav-user mailing list