[FFmpeg-devel] [PATCH] examples/muxing: set timestamps in output audio packet

Michael Niedermayer michaelni at gmx.at
Thu Jan 9 00:41:45 CET 2014


On Wed, Jan 08, 2014 at 03:45:21PM +0100, Stefano Sabatini wrote:
> In particular, fix trac ticket #3231.
> ---
>  doc/examples/muxing.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/doc/examples/muxing.c b/doc/examples/muxing.c
> index 33b2989..cf3e336 100644
> --- a/doc/examples/muxing.c
> +++ b/doc/examples/muxing.c
> @@ -270,6 +270,7 @@ static void write_audio_frame(AVFormatContext *oc, AVStream *st)
>      }
>  
>      audio_frame->nb_samples = dst_nb_samples;
> +    audio_frame->pts += av_rescale_q(dst_nb_samples, (AVRational){1, c->sample_rate}, c->time_base);
>      avcodec_fill_audio_frame(audio_frame, c->channels, c->sample_fmt,
>                               dst_samples_data[0], dst_samples_size, 0);
>  
> @@ -280,6 +281,13 @@ static void write_audio_frame(AVFormatContext *oc, AVStream *st)
>      }
>  
>      pkt.stream_index = st->index;

> +    /* rescale output packet timestamp values */
> +    if (pkt.pts != AV_NOPTS_VALUE)
> +        pkt.pts = av_rescale_q(pkt.pts, c->time_base, st->time_base);
> +    if (pkt.dts != AV_NOPTS_VALUE)
> +        pkt.dts = av_rescale_q(pkt.dts, c->time_base, st->time_base);

see AV_ROUND_PASS_MINMAX


> +    if (pkt.duration)
> +        pkt.duration = av_rescale_q(pkt.duration, c->time_base, st->time_base);

the if seems unneeded

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

No snowflake in an avalanche ever feels responsible. -- Voltaire
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20140109/20347d98/attachment.asc>


More information about the ffmpeg-devel mailing list