On 02/21/2012 07:08 PM, Paul B Mahol wrote:

> This also improves seeking.
> 
> Signed-off-by: Paul B Mahol <[email protected]>
> ---
>  libavformat/cdxl.c |    7 +++++--
>  1 files changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/libavformat/cdxl.c b/libavformat/cdxl.c
> index b056d69..a66f4f1 100644
> --- a/libavformat/cdxl.c
> +++ b/libavformat/cdxl.c
> @@ -104,6 +104,7 @@ static int cdxl_read_packet(AVFormatContext *s, AVPacket 
> *pkt)
>              st->codec->channels      = cdxl->header[1] & 0x10 ? 2 : 1;
>              st->codec->sample_rate   = cdxl->sample_rate;
>              st->start_time           = 0;
> +            st->duration             = avio_size(pb) / current_size * 
> audio_size;
>              cdxl->audio_stream_index = st->index;
>              avpriv_set_pts_info(st, 64, 1, cdxl->sample_rate);
>          }
> @@ -128,10 +129,12 @@ static int cdxl_read_packet(AVFormatContext *s, 
> AVPacket *pkt)
>              st->codec->height        = height;
>              st->start_time           = 0;
>              cdxl->video_stream_index = st->index;
> -            if (cdxl->framerate)
> +            if (cdxl->framerate) {
>                  avpriv_set_pts_info(st, 64, cdxl->fps.den, cdxl->fps.num);
> -            else
> +            } else {
>                  avpriv_set_pts_info(st, 64, 1, cdxl->sample_rate);
> +                st->duration         = avio_size(pb) / current_size * 
> audio_size;
> +            }


in the case where the user sets the framerate you can still calculate
duration for video as (avio_size(pb) / current_size) because this should
be the total number of frames.

-Justin

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to