mediaSource API无法在Chrome上运行,但在Firefox上运行顺畅

时间:2015-03-17 01:20:20

标签: google-chrome firefox video-streaming html5-video media-source

我正在尝试流式传输使用gstreamer生成的WebM格式视频,并通过websockets发送单个帧。 webm文件的典型字节排列是这样的(您可能已经熟悉了这一点)。

EBML (head size: 12 bytes, data: 16 bytes, pos: 0, '0x0')
    DocType (head size: 3 bytes, data: 5 bytes, pos: 12L, '0xcL') : 'webm\x00'
    DocTypeVersion (head size: 3 bytes, data: 1 bytes, pos: 20L, '0x14L') : 2
    DocTypeReadVersion (head size: 3 bytes, data: 1 bytes, pos: 24L, '0x18L') : 2
...
...
SegmentInfo (head size: 12 bytes, data: 91 bytes, pos: 192L, '0xc0L')
    TimecodeScale (head size: 4 bytes, data: 3 bytes, pos: 204L, '0xccL') : 1000000
    Duration (head size: 3 bytes, data: 8 bytes, pos: 211L, '0xd3L') : 0.0
    MuxingApp (head size: 3 bytes, data: 31 bytes, pos: 222L, '0xdeL') : 'GStreamer plugin version 1.2.4\x00'
    WritingApp (head size: 3 bytes, data: 25 bytes, pos: 256L, '0x100L') : 'GStreamer Matroska muxer\x00'
    DateUTC (head size: 3 bytes, data: 8 bytes, pos: 284L, '0x11cL') : 447902803000000000L
Video (head size: 9 bytes, data: 8 bytes, pos: 295L, '0x127L')
    Pixel Width (head size: 2 bytes, data: 2 bytes, pos: 351L, '0x15fL') : 640
    Pixel Height (head size: 2 bytes, data: 2 bytes, pos: 355L, '0x163L') : 480
    Codec Id (head size: 2 bytes, data: 6 bytes, pos: 359L, '0x167L') : 'V_VP8\x00'
Cluster (head size: 12 bytes, data: 72057594037927935L bytes, pos: 367L, '0x16fL')
    TimeCode (head size: 2 bytes, data: 2 bytes, pos: 379L, '0x17bL') : 1514
    SimpleBlock (head size: 4 bytes, data: 44618 bytes, pos: 383L, '0x17fL') : 'binary'
      track number : 1, keyframe : True, invisible : 'no', discardable : 'no'
      lace : 'no lacing', time code : 0, time code(absolute) : 1514
    SimpleBlock (head size: 3 bytes, data: 793 bytes, pos: 45005L, '0xafcdL') : 'binary'
      track number : 1, keyframe : False, invisible : 'no', discardable : 'no'
      lace : 'no lacing', time code : 27, time code(absolute) : 1541
<<conitnued....>>

我看到,当我将gstreamer输出重定向到filesink时,正确写入了绝对时间码和相对时间码。相同的gstreamer管道用于提取字节序列(样本)。然后,这些样本通过websocket传输,并使用MediaSource API在客户端接收。

我对客户端javascript的实现进行了描述here。 当我在Firefox中运行客户端时,视频运行顺畅,没有任何故障。但是在Chrome上,视频会在一段时间后或开始时冻结。

我尝试修改sourceBuffer.mode =“sequence”或“segments”,但Chrome上的所有选项都不起作用,而Firefox上的视频Feed完全不受任何“sourceBuffer.mode”值的影响。这些模式的描述是here。 (我假设MediaSource API在IE和Firefox上的工作方式相同,因为Mozilla网站上没有可用的文档)。

此外,mediaSource.duration在Chrome和Firefox中都是Infinity / NaN。

无论我尝试哪种方式, Chrome上的实时Feed都不起作用,而Firefox则显示流畅的视频。任何建议,为什么会发生这种情况?

更新: 我升级到Chrome版本41,它提供了有关chrome:// media-internals的更多详细信息。显示的消息是:

render_id: 23
player_id: 1
pipeline_state: kStopped
EVENT: WEBMEDIAPLAYER_DESTROYED
url: blob:http%3A//localhost%3A8080/172f68c8-9ff3-4983-9dcb-    396b3f843752
found_video_stream: true
video_codec_name: vp8
duration: unknown
video_dds: false
video_decoder: FFmpegVideoDecoder
error: Append: stream parsing failed. Data size=2283         append_window_start=0 append_window_end=inf
pipeline_error: pipeline: decode error


Timestamp   Property    Value
00:00:00 00 pipeline_state  kCreated
00:00:00 00 EVENT   PIPELINE_CREATED
00:00:00 00 EVENT   WEBMEDIAPLAYER_CREATED
00:00:00 00 url blob:http%3A//localhost%3A8080/172f68c8-9ff3-4983-9dcb-396b3f843752
00:00:00 00 pipeline_state  kInitDemuxer
00:00:01 687    found_video_stream  true
00:00:01 692    video_codec_name    vp8
00:00:01 692    duration    unknown
00:00:01 692    pipeline_state  kInitRenderer
00:00:01 694    video_dds   false
00:00:01 694    video_decoder   FFmpegVideoDecoder
00:00:01 695    pipeline_state  kPlaying
00:00:10 989    EVENT   PLAY
00:00:11 276    error   Got a block with a timecode before the previous block.
00:00:11 276    error   Append: stream parsing failed. Data size=2283 append_window_start=0 append_window_end=inf
00:00:11 276    pipeline_error  pipeline: decode error
00:00:11 276    pipeline_state  kStopping
00:00:11 277    pipeline_state  kStopped
00:01:14 239    EVENT   WEBMEDIAPLAYER_DESTROYED

如何修复或计算“append_window_end”???

0 个答案:

没有答案