Encoding FFMPEG to MPEG-DASH – or WebM with Keyframe Clusters – for MediaSource API

后端 未结 4 1760
南方客
南方客 2020-12-07 23:10

I\'m currently sending a video stream to Chrome, to play via the MediaSource API.

As I understand it, MediaSource only supports MP4 files encoded with MPEG-DASH, or

4条回答
  •  醉梦人生
    2020-12-08 00:06

    To ensure every cluster in your WebM starts with a keyframe, try something like this:

    ffmpeg \
      [...inputs] \
      -vcodec libvpx \
      -keyint_min 60 \
      -g 60 \
      -vb 4000k \
      -f webm \
      -cluster_size_limit 10M \
      -cluster_time_limit 2100 \
      [...output]
    

    Basically, as implemented, every keyframe has to be at the beginning of a cluster but the inverse is not true. That is, on key frame there will be a new cluster, but on new cluster there won't necessarily be a keyframe. To get around this issue, we simply set the cluster size to something large that we'll never hit.

    In this example, we'll have a keyframe every 2 seconds, and the cluster time limit is 2.1 seconds, so we'll never hit it. The bitrate is 4Mbit, and the cluster size limit is 10M-something. Not sure if it's bit or byte there but it doesn't matter as we'll never hit it as I've set it much greater than it needs to be.

提交回复
热议问题