Why is one ffmpeg webm dash stream much larger than the others?

355 views Asked by At

Over the summer, I worked on putting together a script which took a x264 video/mp3 stream and broke it up into the different streams so that it would work via MSE-DASH. (Based heavily on the instructions on the webmproject.org website) Those same scripts have ceased to work, turning a 6GB video into several 25 Gb videos. I kept up with updates of ffmpeg and so I don't know when it stopped working, but I am guessing it was due to the way that their DASH Webm implementation was updated.

I found new method which works better, but still has a major problem with one stream. I was hoping someone could explain how this encoding works so that I could understand the underlying cause.

#!/bin/bash
COMMON_OPTS="-map 0:0 -an -threads 11 -cpu-used 4 -cmp chroma"
WEBM_OPTS="-f webm -c:v vp9 -keyint_min 50 -g 50 -dash 1"

ffmpeg -i $1 -vn -acodec libvorbis -ab 128k audio.webm &
ffmpeg -i $1 $COMMON_OPTS $WEBM_OPTS -b:v 500k -vf scale=1280:720 -y vid-500k.webm &
ffmpeg -i $1 $COMMON_OPTS $WEBM_OPTS -b:v 700k -vf scale=1280:720 -y vid-700k.webm & 
ffmpeg -i $1 $COMMON_OPTS $WEBM_OPTS -b:v 1000k -vf scale=1280:720 -y vid-1000k.webm &
ffmpeg -i $1 $COMMON_OPTS $WEBM_OPTS -b:v 1500k -vf scale=1280:720 -y vid-1500k.webm  

The transcode is not yet complete, but you can see where this is headed:

-rw-r--r--  1 user  staff    87M Jan  4 23:27 audio.webm
-rw-r--r--  1 user  staff    27M Jan  4 23:42 vid-1000k.webm
-rw-r--r--  1 user  staff   285M Jan  4 23:42 vid-1500k.webm
-rw-r--r--  1 user  staff    15M Jan  4 23:42 vid-500k.webm
-rw-r--r--  1 user  staff    20M Jan  4 23:42 vid-700k.webm

The 1500k variant is disproportionately larger than the other streams.

The other problem is that when I use a shorter video, lets say eight or nine minutes, the above configuration runs as expected and everything is perfect. I don't know where the limit for this is since each test costs a lot of processing power and time, but if it's less than ten minutes, it works and if its longer than an hour, it produces massive files.

1

There are 1 answers

2
aergistal On BEST ANSWER

If you want to keep the video bitrate constrained to some value it's not enough to use just -b:v. Depending on the source (high movement, scene complexity) the actual bitrate will go higher.

You need to specify a -maxrate and -bufsize too.

Ie. to get a variable bitrate (VBR) video constrained at around 1500k - the peak can be higher depending on the size of the VBV - you would use:

-b:v 1500k -maxrate 1500k -bufsize 1500k

For constant bitrate (CBR) the best result are achieved with a single frame VBV. Example for 25fps (1500 / 25 = 60):

-b:v 1500k -minrate 1500k -maxrate 1500k -bufsize 60k