3

I'm stumped with encoding videos into a dash compliant format. I'm going from .mp4 to .webm

Firstly, I am running OS X and ffmpeg 2.5.4.

Here's the encoding commands I am using in my test (I got these from here):

ffmpeg -i IMG_0113.mp4 -c:v libvpx-vp9 -s 160x90 -b:v 25k -g 1 -tile-columns 4 -frame-parallel 1 -an -f webm -dash 1 video_160x90_25k.webm

ffmpeg -i IMG_0113.mp4 -c:v libvpx-vp9 -s 160x90 -b:v 50k -g 1 -tile-columns 4 -frame-parallel 1 -an -f webm -dash 1 video_160x90_50k.webm

ffmpeg -i IMG_0113.mp4 -vn -acodec libvorbis -ab 128k  -dash 1 audio_128k.webm

ffmpeg -f webm_dash_manifest -i video_160x90_25k.webm -f webm_dash_manifest -i video_160x90_50k.webm -f webm_dash_manifest -i audio_128k.webm -c copy -map 0 -map 1 -map 2 -f webm_dash_manifest -adaptation_sets "id=0,streams=0,1 id=1,streams=2" manifest.mpd

Secondly, the problem is not with my server, as I have downloaded the samples from here, and they work 100% on the dash.js player when served from my local server.

Please could someone out there point me in the right direction? Or provide a sample of the ffmpeg commands used to get the output format correct.

Thanks, Dean.

jub0bs
  • 60,866
  • 25
  • 183
  • 186
Dean
  • 288
  • 2
  • 13

2 Answers2

17

Ok, here goes, managed to solve this. Hopefully this will save someone else some hassles.

Firstly, here's the solution.

Step 1: (strip audio from video, and create single audio file)

ffmpeg -i IMG_0113.mp4 -c:v libvpx -s 160x90 -threads 4 -b:v 25k -tile-columns 4 -frame-parallel 1 -an -keyint_min 30 -g 30 -f webm video_160x90_25k.webm

ffmpeg -i IMG_0113.mp4 -c:v libvpx -s 160x90 -threads 4 -b:v 50k -tile-columns 4 -frame-parallel 1 -an -keyint_min 30 -g 30 -f webm video_160x90_50k.webm

ffmpeg -i IMG_0113.mp4 -vn -acodec libvorbis -ab 128k audio_128k.webm

Step 2: (using sample_muxer from the libwebm project available here, to create the video cue points)

mkvmuxer_sample -i video_160x90_25k.webm -o video_160x90_25k_cued.webm

mkvmuxer_sample -i video_160x90_50k.webm -o video_160x90_50k_cued.webm

Step 3: (Use ffmpeg to create the audio cue points)

ffmpeg -i audio_128k.webm -vn -acodec libvorbis -ab 128k -dash 1 audio_128k_cued.webm

Step 4: (Use ffmpeg to create the webm dash manifest file .mpd)

ffmpeg -f webm_dash_manifest -i video_160x90_25k_cued.webm -f webm_dash_manifest -i video_160x90_50k_cued.webm -f webm_dash_manifest -i audio_128k_cued.webm -c copy -map 0 -map 1 -map 2 -f webm_dash_manifest -adaptation_sets "id=0,streams=0,1 id=1,streams=2" manifest.mpd

Secondly, here's the explanation.

ffmpeg (my version atleast), was not creating the cue points in the video files correctly (when adding the -dash 1) param. I determined this by probing the video files, and by understanding the webm file format (read this, if you'd like to know more).

I then stumbled upon sample_muxer from reading this page, and decided to see if it would better handle the video cue points that ffmpeg wasn't getting right. Whoop Whoop, it did!

I noticed that the cue points in the extracted audio file from ffmpeg (using the -dash 1 param), were being created correctly!

The ffmpeg generation of the webm dash manifest is also working nicely!

For playing back the video, I found shaka-player worked best but I could not use it as I required video playback from a cefpython container and the shaka-player did not work on the latest cef (chromium embedded framework) included in the cefpython release.

I then wrote my own player based off of this helpful site from google

Anyway, hope this helps someone

frfernandezdev
  • 383
  • 4
  • 10
Dean
  • 288
  • 2
  • 13
  • This issue of FFMPEG still not got resolved in the latest version at this point . – BartMao Feb 21 '17 at 11:40
  • 1
    Video newby here. In step 1, why are you creating 2 video files? – StormyKnight Apr 06 '17 at 17:58
  • @StormyKnight, you'll notice that the '-b:v' args have different values. higher bitrate for video (and many more options) will produce larger better looking video. As a VOD service, one would prepare various sized / quality videos (from the same source video) for a 'dynamic' player to load. Players look for a manifest file of videos and their bitrates (poor to best quality), and will decide which to play according to the clients connectivity speed. – Dean Apr 08 '17 at 09:24
  • I am interested in audio only. I have some MP3 files and successfully converted them to WEBM using libopus. However, when I try to stream it, it don't work (3007 - WEBM_CUES_ELEMENT_MISSING) is displayed. What went wrong? – Menilik Belay Woldeyes Sep 03 '19 at 09:21
0

I had similar issue. When I converted mpeg2 to vp9 with ffmpeg v3.4.2, the output video was not seekable in VLC player (seeking took long time). When I tried ffmpeg v4.0.2, the video was seekable in VLC player. So it seems, that it is fixed in ffmpeg v4.0.2

Matho
  • 125
  • 2
  • 11