From 06f1b98082b9e91115b9667dd413cc0eff88f5ce Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Tue, 8 Nov 2022 13:18:35 +0000 Subject: [PATCH] Initial work on supporting renditions. --- README.md | 4 ++-- media/generate | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) create mode 100755 media/generate diff --git a/README.md b/README.md index f13794d..1e16702 100644 --- a/README.md +++ b/README.md @@ -45,12 +45,12 @@ This demo simulates a live stream by reading a file from disk and sleeping based Download your favorite media file: ``` -wget http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4 -O media/combined.mp4 +wget http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4 -O media/source.mp4 ``` Use ffmpeg to create a LL-DASH playlist. This creates a segment every 2s and MP4 fragment every 10ms. ``` -ffmpeg -i media/combined.mp4 -f dash -use_timeline 0 -r:v 24 -g:v 48 -keyint_min:v 48 -sc_threshold:v 0 -tune zerolatency -streaming 1 -ldash 1 -seg_duration 2 -frag_duration 0.01 -frag_type duration media/fragmented.mpd +ffmpeg -i media/source.mp4 -f dash -use_timeline 0 -r:v 24 -g:v 48 -keyint_min:v 48 -sc_threshold:v 0 -tune zerolatency -streaming 1 -ldash 1 -seg_duration 2 -frag_duration 0.01 -frag_type duration media/fragmented.mpd ``` You can increase the `frag_duration` (microseconds) to slightly reduce the file size in exchange for higher latency. diff --git a/media/generate b/media/generate new file mode 100755 index 0000000..110f401 --- /dev/null +++ b/media/generate @@ -0,0 +1,18 @@ +#!/bin/bash +ffmpeg -i source.mp4 \ + -f dash -ldash 1 \ + -c:v libx264 \ + -preset veryfast -tune zerolatency \ + -c:a aac \ + -b:a 128k -ac 2 -ar 44100 \ + -map v:0 -s:v:0 1280x720 -b:v:0 3M \ + -map v:0 -s:v:1 854x480 -b:v:1 1.1M \ + -map v:0 -s:v:2 640x360 -b:v:2 365k \ + -map 0:a \ + -force_key_frames "expr:gte(t,n_forced*2)" \ + -sc_threshold 0 \ + -streaming 1 \ + -use_timeline 0 \ + -seg_duration 2 -frag_duration 0.01 \ + -frag_type duration \ + playlist.mpd