将h264 olimex a13编码数据包装到RTMP服务器

时间:2014-05-08 12:20:26

标签: c flash h.264 vlc rtmp

我正在尝试使用librtmp将Olimex A13编码数据流式传输到RTMP服务器,并在VLC上查看它。问题是我找不到如何正确地将Cedar数据包装到flash容器中...我发现this example看起来正是我需要的,但是VLC仍然有理解它 -

No suitable decoder module:
VLC does not support the audio or video format "undf". Unfortunately there is no way for you to fix this.

我尝试通过rtmpdump抓取数据,看来我无法禁用VLC试图从标题中获取的音轨

Format                                   : Flash Video
File size                                : 195 KiB
Duration                                 : 1mn 27s
Overall bit rate                         : 1 464 Kbps
_Server                                  : NGINX RTMP (github.com/arut/nginx-rtmp-module)
_displayWidth                            : 640.000
_displayHeight                           : 480.000
_fps                                     : 25.000

Video
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Codec ID                                 : 7
Duration                                 : 1mn 27s
Width                                    : 640 pixels
Height                                   : 480 pixels
Display aspect ratio                     : 4:3
Frame rate mode                          : Constant
Frame rate                               : 25.000 fps
Bit depth                                : 8 bits
Bits/(Pixel*Frame)                       : 0.191

Audio

“音频”的最后一行是我怀疑是导致VLC错误的。此外,我确信我尝试发送的视频数据没有正确包装。

从我理解的示例中可以看出FLV需要一个可以标记视频和音频流信息的一般流描述,我发现的其他示例(包括ffmpeg)在onMetaData标签后面使用了一些幻数,但我不认为我通过以上示例来做到这一点:

STR2AVAL(av, "onMetaData");
enc = AMF_EncodeString(enc, pend, &av);
*enc++ = AMF_ECMA_ARRAY;
enc = AMF_EncodeInt32(enc, pend, 5+5+2); //5 - video 5 - audio 

我的rtmp标头的转储是:

sending 307 as header
00000000  02 00 0d 40 73 65 74 44 61 74 61 46 72 61 6d 65 ...@setDataFrame
00000010  02 00 0a 6f 6e 4d 65 74 61 44 61 74 61 03 00 06 ...onMetaData...
00000020  61 75 74 68 6f 72 02 00 00 00 09 63 6f 70 79 72 author.....copyr
00000030  69 67 68 74 02 00 00 00 0b 64 65 73 63 72 69 70 ight.....descrip
00000040  74 69 6f 6e 02 00 00 00 08 6b 65 79 77 6f 72 64 tion.....keyword
00000050  73 02 00 00 00 06 72 61 74 69 6e 67 02 00 00 00 s.....rating....
00000060  0a 70 72 65 73 65 74 6e 61 6d 65 02 00 06 43 75 .presetname...Cu
00000070  73 74 6f 6d 00 05 77 69 64 74 68 00 40 84 00 00 stom..width.@...
00000080  00 00 00 00 00 05 77 69 64 74 68 00 40 84 00 00 ......width.@...
00000090  00 00 00 00 00 06 68 65 69 67 68 74 00 40 7e 00 ......height.@~.
000000a0  00 00 00 00 00 00 09 66 72 61 6d 65 72 61 74 65 .......framerate
000000b0  00 40 39 00 00 00 00 00 00 00 0c 76 69 64 65 6f .@9........video
000000c0  63 6f 64 65 63 69 64 02 00 04 61 76 63 31 00 0d codecid...avc1..
000000d0  76 69 64 65 6f 64 61 74 61 72 61 74 65 00 40 96 videodatarate.@.
000000e0  e3 60 00 00 00 00 00 08 61 76 63 6c 65 76 65 6c .`......avclevel
000000f0  00 3f f0 00 00 00 00 00 00 00 0a 61 76 63 70 72 .?.........avcpr
00000100  6f 66 69 6c 65 00 40 50 80 00 00 00 00 00 00 17 ofile.@P........
00000110  76 69 64 65 6f 6b 65 79 66 72 61 6d 65 5f 66 72 videokeyframe_fr
00000120  65 71 75 65 6e 63 79 00 40 20 00 00 00 00 00 00 equency.@ ......
00000130  00 00 09                                        ...

在该应用程序之后发送PSP和SPS数据,我不确定我是否正确编码: 这就是我在编码器应用程序中的作用

psp struct start
00000000  34 32 30 31 66 00 00 00 00 00 5a 30 49 41 48 2b 4201f.....Z0IAH+
00000010  56 41 55 42 37 49 00 00 00 00 00 00 00 00 00 00 VAUB7I..........
00000020  00 00 00 00 00 00 00 00 61 4f 34 78 45 67 3d 3d ........aO4xEg==
00000030  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000040  00 00 00 00 00 00                               ......
psp struct end

这就是我发送给RTMP服务器的内容:

sending 38 as sps/pps info
00000000  17 00 00 00 00 01 42 c0 15 03 01 00 0d 67 5a 30 ......B......gZ0
00000010  49 41 48 2b 56 41 55 42 37 49 01 00 09 68 61 4f IAH+VAUB7I...haO
00000020  34 78 45 67 3d 3d                               4xEg==
info frame sent

所以问题是:

  • 如何修改标题以明确说明其视频?
  • 如何以NAL格式包装视频数据以及您多久必须传输SPS和PPS数据?
  • 是否有任何在线服务检查RTMP数据以了解它的错误? VLC没有多大帮助......

0 个答案:

没有答案
相关问题