Use FFMPEG to generate MPD files for MPEG-DASH adaptive streaming

Viewed 11178

So I am trying to setup adaptive streaming and I have what I think is 80-90% of the problem finished. Right now I ingest my source video, transcode it into 5 resolutions each with 3 bitrates (low, medium, high) and then I split all of those videos into 5 second chunks so that the user can always have the best viewing possible. Now I am at the point where I need to generate / create my MPD manifest file and I am having a hard time figuring out how. Almost everyone just says to use MP4Box but their license is too restrictive for my project.

Is there anyway to generate a MPD file using FFMPEG when I segment my video? or maybe generate a HLS that I can then convert into a MPD manifest? Any info would be awesome, this is my current FFMPEG command (working)

Note the $ variables are inputs into a bash script that set the input file, bitrate and scale.

/usr/bin/ffmpeg \
  -re \
  -i $1 \
  -an \
  -c:v libx264 \
  -b:v $7 \
  -b:a 196k \
  -strict -2 \
  -movflags faststart \
  -pix_fmt yuv420p \
  -vf "scale='$4:trunc(ow/a/2)*2'" \
  -flags -global_header \
  -map 0 \
  -f segment \
  -segment_time 5 \
  -segment_list test.m3u8 \
  -segment_format mpegts \
  $2%05d.mp4
2 Answers

Try this from the official docs (it is not exactly the script that you need but you get the idea):

ffmpeg -re -i <input> -map 0 -map 0 -c:a libfdk_aac -c:v libx264 \
-b:v:0 800k -b:v:1 300k -s:v:1 320x170 -profile:v:1 baseline \
-profile:v:0 main -bf 1 -keyint_min 120 -g 120 -sc_threshold 0 \
-b_strategy 0 -ar:a:1 22050 -use_timeline 1 -use_template 1 \
-window_size 5 -adaptation_sets "id=0,streams=v id=1,streams=a" \
-f dash /path/to/out.mpd
Related