[streaming] How to play rtp h264 stream with vlc.

王玮 claritywong at gmail.com
Thu Dec 4 09:50:18 CET 2008


Hi,

i'm puzzled by playing h264 stream from rtp with vlc-0.9.4. There is no
picture out.

i change the source\modules\demux\rtp.c like this:

1. in function Demux() add
          case 96:
            msg_Dbg(demux, "****detected H264 Stream****");
            pt.init = h264_init;
            pt.decode = h264_decode;
            pt.frequency = 9000;
            break;
2. add function h264_init
static void *h264_init (demux_t *demux)
{
    es_format_t fmt;

    es_format_Init (&fmt, VIDEO_ES, VLC_FOURCC ('h', '2', '6', '4'));
    return codec_init (demux, &fmt);
}
i also changed function es_format_Init with fmt->b_packetized           =
false;

3. add function h264_decode
static void h264_decode (demux_t *demux, void *data, block_t *block)
{
    if (block->i_buffer < 4)
    {
        block_Release (block);
        return;
    }

    //add 0x00,0x00,0x00,0x01 after the RTP header for every block
    block_t *p_block = block_New(demux, block->i_buffer + 4);
    p_block->p_buffer[0] = 0x00;
    p_block->p_buffer[1] = 0x00;
    p_block->p_buffer[2] = 0x00;
    p_block->p_buffer[3] = 0x01;

    memcpy(p_block->p_buffer + 4, block->p_buffer, block->i_buffer);
    codec_decode (demux, data, p_block);
}

4. compile it and play the rtp h264 stream and the log is as following:
main debug: thread 4400 (interface) created at priority 0
(interface/interface.c:168)
main debug: thread started
main debug: looking for interface module: 1 candidate
main debug: using interface module "hotkeys"
main debug: TIMER module_Need() : 0.000 ms - Total 0.000 ms / 1 intvls (Avg
0.000 ms)
main debug: thread 4428 (interface) created at priority 0
(interface/interface.c:168)
main debug: thread started
main debug: adding item `rtp://@:1234' ( rtp://@:1234 )
main: Running vlc with the default interface. Use 'cvlc' to use vlc without
interface.
main debug: looking for interface module: 1 candidate
rc: VLC media player - version 0.9.4 Grishenko - (c) 1996-2008 the VideoLAN
team
rc:

main debug: using interface module "rc"
main debug: TIMER module_Need() : 9.000 ms - Total 9.000 ms / 1 intvls (Avg
9.000 ms)
main debug: thread 4468 (interface) created at priority 0
(interface/interface.c:168)
main debug: thread started
main debug: rebuilding array of current - root
main debug: rebuild done - 1 items, index -1
main debug: starting new item
main debug: processing request item null node  skip 0
main debug: creating new input thread
main debug: Creating an input for 'rtp://@:1234'
main debug: waiting for thread initialization
main debug: thread started
main debug: `rtp://@:1234' gives access `rtp' demux `' path `@:1234'
main debug: thread 4508 (input) created at priority 1 (input/input.c:370)
main debug: creating demux: access='rtp' demux='' path='@:1234'
main debug: looking for access_demux module: 1 candidate
main debug: net: opening any datagram port 1234
main debug: net: opening any datagram port 1235
main debug: using access_demux module "rtp"
main debug: TIMER module_Need() : 34.000 ms - Total 34.000 ms / 1 intvls
(Avg 34.000 ms)
main debug: looking for a subtitle file in
D:\cygwin\home\wangwei1\vlc-0.9.4\vlc-0.9.4\
main debug: `rtp://@:1234' successfully opened
rtp debug: ****detected H264 Stream****
rtp debug: added payload type 96 (f = 9000 Hz)
main debug: selecting program id=0
main debug: looking for decoder module: 31 candidates
avcodec debug: libavcodec initialized (interface 3358464 )
avcodec debug: ffmpeg codec (H264 - MPEG-4 AVC (part 10)) started
main debug: using decoder module "avcodec"
main debug: TIMER module_Need() : 32.000 ms - Total 32.000 ms / 1 intvls
(Avg 32.000 ms)
main debug: looking for packetizer module: 18 candidates
main debug: using packetizer module "packetizer_h264"
main debug: TIMER module_Need() : 3.000 ms - Total 3.000 ms / 1 intvls (Avg
3.000 ms)
main debug: thread 4660 (decoder) created at priority 0
(input/decoder.c:217)
main debug: thread started
rtp debug: added RTP source (23be84e1)
main debug: control type=1
packetizer_h264 warning: waiting for SPS/PPS
packetizer_h264 warning: waiting for SPS/PPS
packetizer_h264 warning: waiting for SPS/PPS
packetizer_h264 warning: waiting for SPS/PPS
packetizer_h264 warning: waiting for SPS/PPS
packetizer_h264 warning: waiting for SPS/PPS
packetizer_h264 warning: waiting for SPS/PPS
packetizer_h264 debug: found NAL_SPS (sps_id=0)
packetizer_h264 debug: found NAL_PPS (pps_id=0 sps_id=0)

vlc-0.9.4 stoped when it found the NAL_SPS and NAL_PPS.

i don't know how to solve this problem.

sorry for my bad english.

best regards.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.videolan.org/pipermail/streaming/attachments/20081204/7b7d4d66/attachment.htm 


More information about the streaming mailing list