Bonus Round: Adaptive Streaming

adaptive streaming

What? the act of producing many resolutions (bit rates) and split the media into chunks and serve them via http.

Why? to provide a flexible media that can be watched on a low end smartphone or on a 4K TV, it’s also easy to scale and deploy but it can add latency.

How? creating an adaptive WebM using DASH.

  1. # video streams
  2. $ ffmpeg -i bunny_1080p_60fps.mp4 -c:v libvpx-vp9 -s 160x90 -b:v 250k -keyint_min 150 -g 150 -an -f webm -dash 1 video_160x90_250k.webm
  3.  
  4. $ ffmpeg -i bunny_1080p_60fps.mp4 -c:v libvpx-vp9 -s 320x180 -b:v 500k -keyint_min 150 -g 150 -an -f webm -dash 1 video_320x180_500k.webm
  5.  
  6. $ ffmpeg -i bunny_1080p_60fps.mp4 -c:v libvpx-vp9 -s 640x360 -b:v 750k -keyint_min 150 -g 150 -an -f webm -dash 1 video_640x360_750k.webm
  7.  
  8. $ ffmpeg -i bunny_1080p_60fps.mp4 -c:v libvpx-vp9 -s 640x360 -b:v 1000k -keyint_min 150 -g 150 -an -f webm -dash 1 video_640x360_1000k.webm
  9.  
  10. $ ffmpeg -i bunny_1080p_60fps.mp4 -c:v libvpx-vp9 -s 1280x720 -b:v 1500k -keyint_min 150 -g 150 -an -f webm -dash 1 video_1280x720_1500k.webm
  11.  
  12. # audio streams
  13. $ ffmpeg -i bunny_1080p_60fps.mp4 -c:a libvorbis -b:a 128k -vn -f webm -dash 1 audio_128k.webm
  14.  
  15. # the DASH manifest
  16. $ ffmpeg \
  17. -f webm_dash_manifest -i video_160x90_250k.webm \
  18. -f webm_dash_manifest -i video_320x180_500k.webm \
  19. -f webm_dash_manifest -i video_640x360_750k.webm \
  20. -f webm_dash_manifest -i video_640x360_1000k.webm \
  21. -f webm_dash_manifest -i video_1280x720_500k.webm \
  22. -f webm_dash_manifest -i audio_128k.webm \
  23. -c copy -map 0 -map 1 -map 2 -map 3 -map 4 -map 5 \
  24. -f webm_dash_manifest \
  25. -adaptation_sets "id=0,streams=0,1,2,3,4 id=1,streams=5" \
  26. manifest.mpd

PS: I stole this example from the Instructions to playback Adaptive WebM using DASH