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

后端 未结 4 1845
南方客
南方客 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-07 23:54

    At the moment FFMPEG does not support DASH encoding. You can segment with FFMPEG (https://www.ffmpeg.org/ffmpeg-formats.html#segment_002c-stream_005fsegment_002c-ssegment), but I recommend combining FFMPEG and MP4Box. Use FFMPEG to transcode your live video, and then MP4Box to segment and create the .mpd index.

    MP4Box is a part of GPAC (http://gpac.wp.mines-telecom.fr/).

    Here is an example using h264:

    ffmpeg -threads 4 -f v4l2 -i  /dev/video0 -acodec libfaac -ar 44100 -ab 128k -ac 2 -vcodec libx264 -r 30 -s 1280x720  -f mp4 -y "$movie" > temp1.mp4 && MP4Box -dash 10000 -frag 1000 -rap "$movie"
    

    If you need VP8 (WebM), use: -vcodec libvpx and -f webm or -f ts.

提交回复
热议问题