[FFmpeg-devel] [PATCH] avcodec/nvenc: fix dts>pts when b frame >= 1

Michael Niedermayer michaelni at gmx.at
Sat Jan 10 17:44:58 CET 2015


On Sat, Jan 10, 2015 at 05:30:03PM +0100, Timo Rothenpieler wrote:
> Am 07.01.2015 um 10:48 schrieb Agatha Hu:
> > When B frames >= 1, there'll be a invalid dts/pts warning during
> > encoding like:
> > 
> > [mp4 @ 000000000034cba0] Invalid DTS: 1024 PTS: 512 in output stream
> > 0:0, replacing by guess
> > [mp4 @ 000000000034cba0] Invalid DTS: 1536 PTS: 1024 in output stream
> > 0:0, replacing by guess
> > Set a -1 offset to dts to prevent dts>pts case.
> > 
> > From: agathah <ahu at nvidia.com>
> > ---
> >  libavcodec/nvenc.c | 11 ++++++++++-
> >  1 file changed, 10 insertions(+), 1 deletion(-)
> > 
> > diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
> > index 345fb78..19a3ec8 100644
> > --- a/libavcodec/nvenc.c
> > +++ b/libavcodec/nvenc.c
> > @@ -657,9 +657,14 @@ static av_cold int nvenc_encode_init(AVCodecContext
> > *avctx)
> >      }
> > 
> >      if (ctx->gobpattern >= 0) {
> > -        ctx->encode_config.frameIntervalP = 1;
> > +        ctx->encode_config.frameIntervalP = ctx->gobpattern;
> >      }
> > 
> > +    // when there're b frames, set dts offset
> > +    if (ctx->encode_config.frameIntervalP >= 2) {
> > +        ctx->last_dts = -2;
> > +    }
> > +
> > 
> > ctx->encode_config.encodeCodecConfig.h264Config.h264VUIParameters.colourDescriptionPresentFlag
> > = 1;
> > 
> > ctx->encode_config.encodeCodecConfig.h264Config.h264VUIParameters.videoSignalTypePresentFlag
> > = 1;
> > 
> > @@ -905,6 +910,10 @@ static int process_output_surface(AVCodecContext
> > *avctx, AVPacket *pkt, AVFrame
> >      pkt->pts = lock_params.outputTimeStamp;
> >      pkt->dts = timestamp_queue_dequeue(&ctx->timestamp_list);
> > 
> > +    // when there're b frame(s), set dts offset
> > +    if (ctx->encode_config.frameIntervalP >= 2)
> > +        pkt->dts -= 1;
> > +
> >      if (pkt->dts > pkt->pts)
> >          pkt->dts = pkt->pts;
> > 
> 
> Looks good to merge for me.

i wanted to apply it but the patch is corrupted
Applying: avcodec/nvenc: fix dts>pts when b frame >= 1
fatal: corrupt patch at line 10

its so badly corrupted, even unwrap-diff cant fix it
Agatha, please disable line/word wrap for patches or attach them
and if that doesnt help use a different MUA / SMTP server whatever is
causing this

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Into a blind darkness they enter who follow after the Ignorance,
they as if into a greater darkness enter who devote themselves
to the Knowledge alone. -- Isha Upanishad
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150110/4830f05d/attachment.asc>


More information about the ffmpeg-devel mailing list