6

我正在尝试流式传输使用 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 输出重定向到文件接收器时,绝对时间码和相对时间码被正确写入。相同的 gstreamer 管道用于提取字节序列(样本)。然后这些样本通过 websocket 传输并使用 MediaSource API 在客户端接收。

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

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

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

无论我尝试哪种方式,chrome 上的实时提要都无法正常工作,而 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”???

4

0 回答 0