0

I create a simple direct show source filter using FFmpeg.I read rtp packets from RTSP source and give them to decoder. It works for h264 stream.

MyRtspSourceFilter[H264 Stream] ---> h264 Decoder --> Video Renderer

The bad news is that it does not work for MPEG-4. I can able to connect my rtsp source filter with MPEG-Decoder. I got no exception but video renderer does not show anything. Actually just show one frame then nothing [just stop]... Decoders and Renderers are 3rd party so i can not debug them.

MyRtspSourceFilter[MP4 Stream] ---> MPEG-4 Decoder --> Video Renderer

I can able to get rtp packets from MPEG-4 RTSP Source using FFmpeg sucessfully.There is no problem with it.

It seems that i have not set something(?) in my Rtsps Source Filter which is not necessary for H264 stream but may be important for MPEG-4 stream

What may cause this h264 stream and MPEG-4 stream difference in a direct show rtsp source filter? Any ideas.

More Info:

-- First i try some other rtsp source filters for MPEG-4 Stream...Although my rtsp source is same i see different subtypes in their pin connections.

-- Secondly i realy get suspicious if the source is really MPEG-4 SO i check with FFmpeg...FFmpeg gives the source codec id as "CODEC_ID_MPEG4".

Update: [ Hack ]

I just set m_bmpInfo.biCompression = DWORD('xvid') it just worked fine...But it is static. How to dynamically get/determine this value using ffmpeg or other ways...

Novalis
  • 2,265
  • 6
  • 39
  • 63
  • Do you reassemble packets correctly? MPEG4 and H264 packetizations are not same! Do you use `0x000001` code for each reassembled frame before you send it to decoder? Are your media sample timings correct? – Cipi Oct 05 '11 at 23:14
  • I understand that MPEG4 and H264 packetizations are not same! FFmpeg do packetizations for me .. But i really wanted to know how to add 0x000001 code for each reassembled frame by myself...What is its algorithm-pattern? – Novalis Oct 06 '11 at 06:47
  • Actually you answer it from my different question...http://stackoverflow.com/questions/7665217/how-to-process-raw-udp-packets-so-that-they-can-be-decoded-by-a-decoder-filter-in Thanks....I will try – Novalis Oct 06 '11 at 06:56
  • Oh sorry didn't notice that this was also your question. – Cipi Oct 06 '11 at 08:11

1 Answers1

1

I am on the RTSP-server side, different use case with required by-frame conversions

MP4 file ---> MPEG-4 Decoder --> H264 Encoder -->  RTSP Stream

Will deploy libav, which is kernel of ffmpeg.

EDIT: With H264 encoded video layer, the video just needs to be remuxed from length-prefixed file format "AVCC" to byte stream format according to some "Annex B" of the MPEG-4 specification. libav provides required bit-stream filter "h264_mp4toannexb"

MP4 file ---> h264_mp4toannexb_bsf -->  RTSP Stream

Now, for decoding RTSP:

Video and Audio come in separate channels. Parsing and decoding the H264 stream is done here: my basic h264 decoder using libav

Audio is a different thing: RTP Transport suggests, that AAC frames are encapsulated in ADTS, where RTSP players like VLC expect plane AAC and accordingly available RTSP server implementations AACSource::HandleFrame() pinch the ADTS header off.

Another different thing is "time stamps and RTP": VLC does not support compensation of time offsets between audio and video. Nearly every RTSP producer or consumer has constraints or non-documented assumptions for a time offset; you might consider an additional delay pipe to compensate the offset of an RTSP source.

Sam Ginrich
  • 661
  • 6
  • 7