[Ffmpeg-devel] Demuxing still pictures in dvd's

elupus elupus
Tue Aug 2 18:33:08 CEST 2005


We are using the ffmpeg mpeg2 demuxer for our dvdplayer in the XBMC (Xbox
Media Center) Project. We ran into an problem with it when it's decoding
still frames. When a still frame is decoded on a dvd, there doesn't need to
be any new startcode for the next image following that frame, there is only
a sequence end code. When this occured, ffmpeg refused to return the last
package of data containing the still frame. 

We now finally managed to track the problem down to the packetizer in
ffmpeg. It seems it doesn't look for an end code, but only the start code of
the next frame. Here is a VERY ugly patch that solves the problem when
playing dvd's, but i only attatch it so as to get some response on how to
solve this in a clean way.

Ps. Please CC me on reply as i'm not subscribed to the mailing list, so I
don't need to toppost on reply.


Index: libavcodec/parser.c
RCS file: /cvsroot/ffmpeg/ffmpeg/libavcodec/parser.c,v
retrieving revision 1.26
diff -u -r1.26 parser.c
--- libavcodec/parser.c	29 Jun 2005 08:41:01 -0000	1.26
+++ libavcodec/parser.c	2 Aug 2005 14:24:10 -0000
@@ -429,8 +429,15 @@
     ParseContext1 *pc1 = s->priv_data;
     ParseContext *pc= &pc1->pc;
     int next;
-    next= ff_mpeg1_find_frame_end(pc, buf, buf_size);
+#ifdef _XBOX
+	// XXX major hack
+	// it seems that a frame end is not detected if libdvdnav sends out
1 frame (still picture) and after tha only audio
+	// dunno where to fix it, in ff_mpeg1_find_frame_end or somewhere
+	// it seems that there are always 4 bytes in these cases send to the
parser (0x00, 0x00, 0x01, 0xb7) / SEQUENCE END CODE
+    if (buf_size == 4) next = 4;
+    else
+#endif // _XBOX
+	next= ff_mpeg1_find_frame_end(pc, buf, buf_size);
     if (ff_combine_frame(pc, next, (uint8_t **)&buf, &buf_size) < 0) {
         *poutbuf = NULL;

More information about the ffmpeg-devel mailing list