example ffmpeg command line for mp4 & webm in same manifest

1,416 views
Skip to first unread message

Andy Hochhaus

unread,
Apr 13, 2016, 12:37:24 AM4/13/16
to Shaka Player Users
Hello,

Can anyone provide a pointer to an example ffmpeg command line which generates a dash manifest (*.mpd) containing both webm and mp4 content?

With such a manifest will shaka player automatically select the best content based upon the codecs available in the browser?

-Andy

Joey Parrish

unread,
Apr 13, 2016, 1:28:49 PM4/13/16
to Andy Hochhaus, Shaka Player Users
Hi Andy,

To the best of my knowledge, ffmpeg can only output manifests for WebM DASH, not MP4.  To create the multicodec assets we published for Shaka, I only used ffmpeg to encode the files into various resolutions.  I used edash packager to package both the MP4 and WebM streams at the same time into one manifest.

For an example, here are the commands I used to create the first period of our short multi-period clip.  Does this help?
-Joey


COMMON_OPTS="-map 0:0 -an -threads 11 -cpu-used 4 -cmp chroma"
MP4_OPTS="-f mp4 -c:v libx264 -movflags +faststart -strict -2 -x264opts scenecut=0:open_gop=0:bframes=0:min-keyint=89:keyint=89 -flags +loop+cgop -profile:v baseline -level:v 3.0"
WEBM_OPTS="-f webm -c:v vp9 -keyint_min 89 -g 89 -dash 1"

# Encode MP4 in 4 resolutions:
ffmpeg -i sun.mp4 $COMMON_OPTS $MP4_OPTS \
  -b:v 1000k -vf scale=640:480 -y output/v-0480p-1000k-libx264.mp4
ffmpeg -i sun.mp4 $COMMON_OPTS $MP4_OPTS \
  -b:v 750k -vf scale=480:360 -y output/v-0360p-0750k-libx264.mp4
ffmpeg -i sun.mp4 $COMMON_OPTS $MP4_OPTS \
  -b:v 400k -vf scale=320:240 -y output/v-0240p-0400k-libx264.mp4
ffmpeg -i sun.mp4 $COMMON_OPTS $MP4_OPTS \
  -b:v 100k -vf scale=192:144 -y output/v-0144p-0100k-libx264.mp4
# Encode WebM in 4 resolutions:
ffmpeg -i sun.mp4 $COMMON_OPTS $WEBM_OPTS \
  -b:v 750k -vf scale=640:480 -y output/v-0480p-0750k-vp9.webm
ffmpeg -i sun.mp4 $COMMON_OPTS $WEBM_OPTS \
  -b:v 550k -vf scale=480:360 -y output/v-0360p-0550k-vp9.webm
ffmpeg -i sun.mp4 $COMMON_OPTS $WEBM_OPTS \
  -b:v 300k -vf scale=320:240 -y output/v-0240p-0300k-vp9.webm
ffmpeg -i sun.mp4 $COMMON_OPTS $WEBM_OPTS \
  -b:v 100k -vf scale=192:144 -y output/v-0144p-0100k-vp9.webm

# These outputs are only intermediate.  Rename them.
cd output
rename 's/webm/tmp.webm/' *.webm
rename 's/mp4/tmp.mp4/' *.mp4

# Package the content into one manifest.
packager --profile on-demand \
  input=v-0480p-1000k-libx264.tmp.mp4,stream=video,output=v-0480p-1000k-libx264.mp4 \
  input=v-0360p-0750k-libx264.tmp.mp4,stream=video,output=v-0360p-0750k-libx264.mp4 \
  input=v-0240p-0400k-libx264.tmp.mp4,stream=video,output=v-0240p-0400k-libx264.mp4 \
  input=v-0144p-0100k-libx264.tmp.mp4,stream=video,output=v-0144p-0100k-libx264.mp4 \
  input=v-0480p-0750k-vp9.tmp.webm,stream=video,output=v-0480p-0750k-vp9.webm \
  input=v-0360p-0550k-vp9.tmp.webm,stream=video,output=v-0360p-0550k-vp9.webm \
  input=v-0240p-0300k-vp9.tmp.webm,stream=video,output=v-0240p-0300k-vp9.webm \
  input=v-0144p-0100k-vp9.tmp.webm,stream=video,output=v-0144p-0100k-vp9.webm \
  --mpd_output dash.mpd

# Remove the intermediate files.
rm *.tmp.webm *.tmp.mp4



--
You received this message because you are subscribed to the Google Groups "Shaka Player Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shaka-player-us...@googlegroups.com.
To post to this group, send email to shaka-pla...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/shaka-player-users/8c531c07-4fa8-4e14-b4f1-f1b3921988fd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Joey Parrish

unread,
Apr 13, 2016, 1:30:39 PM4/13/16
to Andy Hochhaus, Shaka Player Users
Oh, and I forgot to answer the second part of your question.  Yes, Shaka will filter out any streams in a manifest that the browser can't parse/decode.

If your browser supports WebM but not MP4, Shaka will play WebM from a multicodec manifest.  If your browser supports MP4 but not WebM, Shaka chooses MP4.

If your browser supports both, the choice is arbitrary and based on what appears first in the manifest.

Thanks,
Joey

Reply all
Reply to author
Forward
0 new messages