具有 MPEG-4 视频流的 DirectShow RTSP SourceFilter
我使用 FFmpeg 创建一个简单的直接显示源过滤器。我从 RTSP 源读取 rtp 数据包并将其提供给解码器。 它适用于 h264 流。
MyRtspSourceFilter[H264 Stream] ---> h264 Decoder --> Video Renderer
坏消息是它不适用于 MPEG-4。我可以将我的 rtsp 源过滤器与 MPEG-Decoder 连接。我也不例外,但视频渲染器没有显示任何内容。 实际上只显示一帧,然后什么也没有 [只是停止]...解码器和渲染器是第三方,所以我无法调试它们。
MyRtspSourceFilter[MP4 Stream] ---> MPEG-4 Decoder --> Video Renderer
我可以使用 FFmpeg 成功从 MPEG-4 RTSP 源获取 rtp 数据包。没有问题。
看来我没有在我的 Rtsps 源中设置某些内容(?) 过滤器对于 H264 流不是必需的,但对于 MPEG-4 流
什么可能导致直接显示 rtsp 源过滤器中的 h264 流和 MPEG-4 流差异?任何想法。
更多信息:
-- 首先,我尝试一些其他 MPEG-4 流的 rtsp 源过滤器...虽然我的 rtsp 源是相同的,但我在它们的引脚连接中看到了不同的子类型。
-- 其次,如果源确实是 MPEG-4,我真的很怀疑,所以我用 FFmpeg 检查...FFmpeg 给出的源编解码器 ID 为“CODEC_ID_MPEG4”。
更新: [ Hack ]
我刚刚设置了 m_bmpInfo.biCompression = DWORD('xvid') 它工作正常......但它是静态的。 如何使用 ffmpeg 或其他方式动态获取/确定该值...
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...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在 RTSP 服务器端,需要按帧转换的不同用例
将部署 libav,其中是ffmpeg的内核。
编辑:
使用 H264 编码的视频层,视频只需从
根据 MPEG-4 规范的某些“附录 B”,将长度前缀文件格式“AVCC”转换为字节流格式。 libav 提供了所需的比特流过滤器“h264_mp4toannexb”
现在,用于解码 RTSP:
视频和音频位于不同的通道中。解析和解码 H264 流在这里完成: 我使用 libav 的基本 h264 解码器
音频是另一件事:
RTP Transport 表明,AAC 帧封装在 ADTS 中,其中 VLC 等 RTSP 播放器期望平面 AAC 以及相应可用的 RTSP 服务器实现 AACSource::HandleFrame() 捏住 ADTS标题关闭。
另一个不同的事情是“时间戳和 RTP”:
VLC 不支持音频和视频之间的时间偏移补偿。几乎每个 RTSP 生产者或消费者都对时间偏移有限制或未记录的假设;您可以考虑使用额外的延迟管道来补偿 RTSP 源的偏移。
I am on the RTSP-server side, different use case with required by-frame conversions
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"
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.