[Ffmpeg-devel] h264 decoder/ts-streams

Måns Rullgård mru
Fri Nov 3 20:59:05 CET 2006


Julian Scheel <julian at jusst.de> writes:

> Hi,
>
> I am just looking into xines demux_ts to make it possible to play ts-streams 
> holding h264 with xine/ffmpeg.
> I can across the problem, that xine won't play video at all if using
> ffmpeg as decoder for ts-streams (no matter if mpeg2 or h264).
> Some digging around turned out that some kind of paketizing is
> needed. Now I did the following:
> I added a parse to xine_ts, that searches for the startblock (0 0 1,
> for h264, according to VLC sources). When new data comes in I parse
> it to find a startblock. Until the first startblock is found all
> data is dumped.
> When I found a startblock I start slicing the stream - a packet
> always starts with the first byte after the startblock and ends with
> the last byte before the next startblock.

This looks wrong in two ways:
1. You need to check the NAL unit type and only split when there is a
new frame.  A frame is usually made up of several NAL units.
2. The start code must be included in the packet sent to the decoder.

> Then I set the xine-decoder-flags to mark each block as a complete frame.
>
> Now ffmpeg shows these errors:
> [h264 @ 0xb72d83a8]Unknown NAL code: 21
> [h264 @ 0xb72d83a8]Unknown NAL code: 21
> [h264 @ 0xb72d83a8]Unknown NAL code: 24
> [h264 @ 0xb72d83a8]Unknown NAL code: 0
> [h264 @ 0xb72d83a8]Unknown NAL code: 21
> [h264 @ 0xb72d83a8]non existing PPS referenced
> [h264 @ 0xb72d83a8]decode_slice_header error
> [h264 @ 0xb72d83a8]Unknown NAL code: 29
> [h264 @ 0xb72d83a8]Unknown NAL code: 29
> [h264 @ 0xb72d83a8]Unknown NAL code: 29
>
> and so on.
>
> Might someone outline how the data has to be prepared before passing to 
> ffmpeg?

Use an AVParser.  It does the splitting into frames you are struggling
with, and is already written.

> And can it be that the size for each frame is only a few thousand
> bytes for a 1920x1080 stream?

In a low motion scene that could very well be possible.  However, it
seems like you're splitting on NAL units rather frames.

-- 
M?ns Rullg?rd
mru at inprovide.com




More information about the ffmpeg-devel mailing list