Last active
July 27, 2022 03:44
-
-
Save ddennedy/16b7d0c15843829b4dc4 to your computer and use it in GitHub Desktop.
Use ffmpeg and mp4box to prepare DASH-AVC/264 v1.0 VoD
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
See my DASH-IF presentation from October, 2014: | |
https://s3.amazonaws.com/misc.meltymedia/dash-if-reveal/index.html#/ | |
1. encode multiple bitrates with keyframe alignment: | |
ffmpeg -i ~/Movies/5D2_Portrait.MOV -s 1280x720 -c:v libx264 -b:v 1450k -bf 2 \ | |
-g 90 -sc_threshold 0 -c:a aac -strict experimental -b:a 96k -ar 32000 out.mp4 | |
My input was 30 fps = 3000 ms. If it were 29.97, then a GOP size of 90 frames will yield a base segment | |
size of 3003 milliseconds. You can make the segment size some multiple of this, e.g.: 6006, 9009, 12012. | |
You could encode to other resolutions and bitrates here, and if you do, you might want to skip the audio | |
encoding for them. To do that replace "-c:a aac -strict experimental -b:a 96k -ar 32000" with "-an". | |
2. verify keyframes: | |
ffprobe -show_frames -print_format compact out.mp4 | less | |
=> too difficult to read | |
ffprobe -show_frames -print_format compact out.mp4 | | |
awk -F '|' '($2 == "media_type=video") {print i++, $3}' | less | |
=> Now we can just see video key frame indication - better, but let's filter it more. | |
ffprobe -show_frames -print_format compact out.mp4 | | |
awk -F '|' '($2 == "media_type=video") {if ($3 == "key_frame=1") print i, $3; ++i}' | |
=> Now we can just see frame# of frames that are a key frame and verify they are multiples of 90. | |
At this point, we could extend the awk with a test on i modulo 90 and exit with result | |
code 1 to signal failure in an automated script. | |
3. segment and generate mpd: | |
mp4box -dash 3000 -rap -profile dashavc264:onDemand out.mp4#audio out.mp4#video | |
=> generates out_dash.mp4 and out_track?_dashinit.mp4 | |
If you have multiple files at different bitrates, just add them to the end of the command | |
line, but there will be more _track_dashinit.mp4 files you need to ensure you upload. | |
4. test locally: | |
Osmo4 out_dash.mpd | |
5. view mp4 dump: | |
mp4box -diso -stdb out_track1_dashinit.mp4 2>&1 | xmllint -format - | |
or, mp4dump out_track1_dashinit.mp4 | |
6. upload to web server: | |
s3cmd put --acl-public out_dash.mpd out_track?_dashinit.mp4 s3://${S3BUCKET}/dash/ | |
7. validate mpd: | |
http://dashif.org/conformance.html | |
copy-and-paste: http://${S3BUCKET}.s3.amazonaws.com/dash/out_dash.mpd | |
8. play with dashif.org test player: | |
http://dashif.org/reference/players/javascript/1.0.0/index.html?mpd=http://${S3BUCKET}.s3.amazonaws.com/dash/out_dash.mpd | |
9. embed in own web page using video.js and dash.js: | |
s3cmd put --acl-public --recursive videojs-dash/* s3://${S3BUCKET}/videojs/ | |
open http://${S3BUCKET}.s3.amazonaws.com/dash/videojs.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8" /> | |
<title>Video.js DASH-AVC/264</title> | |
<!-- Video.JS --> | |
<link href="/videojs/video-js.css" rel="stylesheet"> | |
<script src="/videojs/video.dev.js"></script> | |
<!-- Dash.JS --> | |
<script src="https://rawgit.com/Dash-Industry-Forum/dash.js/master/dash.min.js"></script> | |
<!-- Video.JS Tech Loads --> | |
<!-- videojs-dashjs --> | |
<!-- <script src="https://rawgit.com/Dash-Industry-Forum/dash.js/master/contrib/videojs/videojs-tech-dashjs.js"></script> --> | |
<script src="/videojs/videojs-tech-dashjs.js"></script> | |
</head> | |
<body> | |
<video id="vid1" class="video-js vjs-default-skin" data-setup='{}' | |
width="854" height="480" controls preload="auto"> | |
<source src="/dash/out_dash.mpd" type="application/dash+xml"> | |
</video> | |
</body> | |
</html> |
Does this approach generate muxed or demuxed streams for audio and video
@Anmolk22 muxed
i want to know , if 1gb mpd dash taking 12 sec to play after forward or rewind , how to reduce the time.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@ddennedy FYI:
https://trac.ffmpeg.org/wiki/Encode/AAC#NativeFFmpegAACencoder