[FFmpeg-devel] [PATCH] Fix 2 pass mjpeg encoding

Michael Niedermayer michaelni
Sat Dec 4 18:28:40 CET 2010


On Fri, Dec 03, 2010 at 11:41:55PM -0600, Bobby Bingham wrote:
> On Sat, 4 Dec 2010 05:16:01 +0100
> Michael Niedermayer <michaelni at gmx.at> wrote:
> 
> > On Fri, Dec 03, 2010 at 09:33:27PM -0600, Bobby Bingham wrote:
[...]
> > 
> > [...]
> > >  ffmpeg.c |    3 ++-
> > >  1 file changed, 2 insertions(+), 1 deletion(-)
> > > 05a100018f136d03018bbf451c5e13b8bb7e133f  02-eof_stats.patch
> > > Don't output duplicate stats for the last frame
> > > 
> > > From: Bobby Bingham <uhmmmm at gmail.com>
> > > 
> > > 
> > > ---
> > >  ffmpeg.c |    3 ++-
> > >  1 files changed, 2 insertions(+), 1 deletions(-)
> > > 
> > > diff --git a/ffmpeg.c b/ffmpeg.c
> > > index e58e7b5..f5c8d30 100644
> > > --- a/ffmpeg.c
> > > +++ b/ffmpeg.c
> > > @@ -1803,13 +1803,14 @@ static int output_packet(AVInputStream *ist, int ist_index,
> > >                              if (ret < 0) {
> > >                                  fprintf(stderr, "Video encoding failed\n");
> > >                                  ffmpeg_exit(1);
> > > -                            }
> > > +                            } else if(ret > 0) {
> > >                              video_size += ret;
> > >                              if(enc->coded_frame && enc->coded_frame->key_frame)
> > >                                  pkt.flags |= AV_PKT_FLAG_KEY;
> > >                              if (ost->logfile && enc->stats_out) {
> > >                                  fprintf(ost->logfile, "%s", enc->stats_out);
> > >                              }
> > > +                            }
> > 
> > stats_out should be null if a encoder doesnt mean to output stats
> > otherwise it would become impossible to output something at the end
> > 
> 
> Here's what I'm seeing.  If I do
> 
> ffmpeg -i source.png -pass 1 pass1.jpg
> 
> the pass1 stats file contains two identical lines. The first is written
> by do_video_out when the frame is actually encoded. The second is
> written by the code I changed. It calls avcodec_encode_video, which
> doesn't actually call into the codec because
> avctx->codec->capabilities & CODEC_CAP_DELAY || pict is false.
> 
> AFAICS, it never actually calls into the encoder after writing the
> stats out the first time.  I don't see where the encoder has a chance
> to set this to null before ffmpeg writes the stats out a second time.

avcodec_encode_video() could set it to NULL (make sure though this doesnt
result in a leak)


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

Many that live deserve death. And some that die deserve life. Can you give
it to them? Then do not be too eager to deal out death in judgement. For
even the very wise cannot see all ends. -- Gandalf
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20101204/7accbdc4/attachment.pgp>



More information about the ffmpeg-devel mailing list