简体   繁体   中英

ffmpeg or MP4box how to convert video to universal playable Mpeg-DASH or HLS

What is the "good" way to encode (from any format like webm, rtmp) to UNIVERSALLY PLAYABLE hls or dash format???

I see tons of talks about HLS and MPEG-DASH with video tag that looks like this

<video width="90%" height="669" controls > <source src="index.m3u8" type="application/x-mpegURL" > </video>

but what is the good command in FFMPEG?

when I do this

ffmpeg -i file.webm  -acodec aac -vcodec libx264 -movflags faststart -s 640x360 -start_number 0 -hls_time 10 -hls_list_size 0 -f hls index.m3u8

it's playable ONLY in chrome:(

but I need it to be playable in safari, firefox, opera, etc

I recenlty viewed talks about MP4box, what would be the best line to be able to convert any source to a universal playable stream?

Hi Found a tested AND working code it can be adapted

NOTE 1; the input CAN be a https://www.....file.webm;) the webm can be generated in 1 server and the ffmpeg can be in an other server;)

NOTE 2; (untested) but seems FFMPEG can listen to IP cam as well ffmpeg -rtsp_flags listen -i rtsp://ownaddress/live.sdp

FFMPEG:

ffmpeg -re -v verbose -i "file.webm" -c:v libx264 -c:a aac -ac 1 -strict -2 -crf 18 -profile:v baseline -maxrate 1000k -bufsize 1835k -pix_fmt yuv420p -flags -global_header -hls_time 10 -hls_list_size 6 -hls_wrap 10 -start_number 1 'index.m3u8'

HLS Universally playable HTML;) thanks to hls.js https://github.com/video-dev/hls.js/

<html>
<head></head>
<body>
<script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script>
<center><video width="90%" height="600" id="video" controls="" src="https://moctobpltc-i.akamaihd.net/hls/live/571329/eight/playlist.m3u" playsinline="true" ></video></center>
<script>
  var video = document.getElementById("video");
  var videoSrc = "https://moctobpltc-i.akamaihd.net/hls/live/571329/eight/playlist.m3u8";
  if (video.canPlayType("application/vnd.apple.mpegurl")) {
    video.src = videoSrc;
  } else if (Hls.isSupported()) {
    var hls = new Hls();
    hls.loadSource(videoSrc);
    hls.attachMedia(video);
  }
</script>
</body>
</html>

*********** It MUST be inside a http or preferably https: because tested locally is not working

**** AN other note: playsinline="true" in video tag is for IOS and WKWebview to avoid being forced to watch it only in fullscreen

This.m3u8 is a live akamai playlist...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM