Playing audio.mpd and video.mpd together in dash.js - dash.js

For MPEG DASH streaming, I have audio.mpd and video.mpd separately for a video.mp4 file generated using following command.
MP4Box -dash 5000 -frag 5000 -rap -bs-switching no -profile dashavc264:live -segment-name ./video/$2_segment_ -out ./mpds/$2_video.mpd $2.mp4#video
MP4Box -dash 5000 -frag 5000 -rap -bs-switching no -profile dashavc264:live -segment-name ./audio/$2_segment_ -out ./mpds/$2_audio.mpd $2.mp4#audio
Each mpd plays separately in dash.js. Is it possible to play them together using dash.js?
Or is there any way to merge both using MP4Box?

2 options:
MPD are XML. So you can easily post-process them to merge. Practically the MPD should be nearly identical. Insert both <AdaptationSet>s in a new MPD under <Period>.
Alternately execute the following command-line to make it in one pass: MP4Box -dash 5000 -frag 5000 -rap -bs-switching no -profile dashavc264:live -segment-name $2_segment_ -out ./mpds/$2_video.mpd $2.mp4#video:baseURL=video $2.mp4#audio:baseURL=audio

Related

Create different qaulities for my manifest with only mp4box

I asked a question on slack on why the quality and bitrate of my dash video wasn't changing and I got this response: You only have one quality in your manifest. there is no way for the player to choose a different one
So how can I create different "qualities"?
I have a mp4box command like:
MP4Box -dash 2000 -profile dashavc264:live -bs-switching multi -url-template whatever.mp4#trackID=1:id=vid0:role=vid0 whatever.mp4#trackID=2:id=aud0:role=aud0 -out whatever.mpd
Would it be possible to create different "qualities" with only mp4box or would I have to create the same video with different resolutions with something like ffmpeg and then feed them into the inputs to the command above?
GPAC contributor here. Since v0.9, GPAC has introduced a new architecture that allows to transcode by leveraging FFmpeg.
Example (forced intra period of 2 seconds):
MP4Box -dash 2000 -profile dashavc264:live -out session.mpd source.mp4:##enc:c=avc:fintra=2
Edit: since 2020/09/29 multi-encoding is possible
MP4Box -fgraph -dash 2000 -profile dashavc264:live source.mp4:#ffsws:osize=160x120#enc:c=avc:fintra=2:b=100k:#Representation=1##ffsws:osize=320x240#enc:c=avc:fintra=2:b=200k:#Representation=2
Please let us know if you have any questions!

How to change a track ID with ffmpeg or MP4Box?

I need to change the id of a video track in an mp4 container and of course without re-encoding. How can I do that with ffmpeg or MP4Box ? Is that even possible ?
With MP4Box you can fine-tune these parameters (more in MP4Box -h general):
-set-track-id id1:id2 changes the id of a track from id1 to id2
-swap-track-id id1:id2 swaps the IDs of the identified tracks
Example:
inplace: MP4Box -set-track-id 100:101 file.mp4
new file: MP4Box -set-track-id 100:101 file.mp4 -out new.mp4

CANNOT get FFserver stream going

I want to preface this question with the fact that I am very very new to ffmpeg and even newer to ffserver.
I cannot, for the life of me, get this thing going.
I get:
"Too large number of skipped frames 882933314374 > 60000"
Also, ffplay gives me first frame is no keyframe
Here is my ffserver.conf file
HTTPPort 8090
HTTPBindAddress 0.0.0.0
MaxHTTPConnections 1000
MaxClients 10
MaxBandwidth 2000000
NoDefaults
###############################################################################################
<Feed test.ffm>
File /tmp/test.ffm
FileMaxSize 10000M
ACL ALLOW localhost
</Feed>
<Stream status.html>
Format status
# Only allow local people to get the status
ACL allow localhost
</Stream>
<Stream test.avi>
Feed test.ffm
Format avi
ACL ALLOW localhost
ACL ALLOW 192.168.1.0
NoAudio
VideoSize 3840x2160
VideoFrameRate 30
Preroll 10
</Stream>
###############################################################################################
And here is my ffmpeg command
ffmpeg -i smaller.avi http://localhost:8090/test.ffm
I've been fighting with this thing all day, googling like a madman the entire time. What am I doing wrong? Any help will be welcomed enthusiastically.
These are my notes as I'm currently working through a similar process:
Video Streaming from ffserver for Raspberry PI - Unoptimized
Follow this tutorial: (I know people don't like links but this tut worked)
https://oscarliang.com/webcam-streaming-video-raspberry-pi-via-browser/
Download ffmpeg for windows (or linux)
git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg
// Keep your ffserver.conf simple at first
HTTPPort 8090
HTTPBindAddress 0.0.0.0
MaxHTTPConnections 1000
MaxClients 10
MaxBandwidth 2000000
NoDefaults
###############################################################################################
<Feed test.ffm>
File /tmp/test.ffm
FileMaxSize 10M
</Feed>
<Stream test.avi>
Feed test.avi
Format mjpeg
VideoSize 640x480
VideoFrameRate 20
VideoBitRate 2000
VideoQMin 2
VideoQMax 10
</Stream>
Put endpoint at http://<localhost>/webcam.mjpeg
Makesure webcam.sh contains:
ffserver -f /etc/ffserver.conf \
& ffmpeg -v verbose \
-r 30 \
-s 640x480 \
-f video4linux2 \
-i /dev/video0 http://localhost/webcam.ffm
Run the following:
// Use the following instead of vlc as this has faster streaming
Win:
ffplay.exe http://localhost/webcam.mjpeg
Linux:
ffplay http://localhost/webcam.mjpeg

Single Manifest file for different audio and video segments created using MP4Box (MPEG DASH)

I have three questions
1) Does dash.js support audio and video content multiplexed in a single segment?
2) If not how to merge audio.mpd and video.mpd created using MP4Box into a single out.mpd, that is supported by dash.js player?
3) It works if AdaptationSet is copied manually from audio.mpd and placed in video.mpd and video.mpd is played using dash.js. How to automate it?
MP4Box -dash 4000 -frag 4000 -rap -bs-switching no -profile dashavc264:live -segment-name ./video/segment_ -out video.mpd video.mp4#video
MP4Box -dash 4000 -frag 4000 -rap -bs-switching no -profile dashavc264:live -segment-name ./audio/segment_ -out audio.mpd video.mp4#audio
Answers:
No, dash.js by intention does not support muxed audio/video segments. This is because it is the reference player for the DASH Industry Forum (DASH IF). The DASH IF publish interop guidelines http://dashif.org/guidelines/ designed to simply and standardize deployments of MPEG DASH. One of those restrictions is that muxed segments are not supported. This is the current state. However, within dash.js we are looking at adding a mode of operation such that we will allow both muxed playback and playlist-based addressing (another IOP restriction) if the player is operating in non-reference-player mode. This should be implemented in either the 2.2 release or later.
2+3: to use mp4box to package to demuxed segments from a muxed source called muxed.mp4, try
MP4Box -dash 4000 -frag 4000 -rap -bs-switching no -profile dashavc264:live -segment-name ./video/segment_ -out video.mpd muxed.mp4#video muxed.mp4#audio
Cheers
Will
You can do it using MP4Box twice:
MP4Box -dash 4000 -frag 4000 -rap -bs-switching no -profile dashavc264:live -segment-name ./video/v_ -out video.mpd muxed.mp4#audio muxed.mp4#video
to create video segments
MP4Box -dash 4000 -frag 4000 -rap -bs-switching no -profile dashavc264:live -segment-name ./video/v_ -out video.mpd muxed.mp4#video muxed.mp4#audio
to create audio segments
Modify video.mpd
change the video_init.mp4 & video segment name
That's it.
In order to produce one MPD file containing details about separate audio and video segments using MP4Box, just remove the -segment-name option and it's value. So your command should look like this
MP4Box -dash 4000 -frag 4000 -rap -bs-switching no -profile dashavc264:live
-url-template video.mp4 audio.mp4 -out manifest.mpd

Generating MPEG DASH videos which are compilant with HbbTV 1.5 standard

I am looking for a the command line options for ffmpeg, DASHEncoder and MP4Box to generate HbbTV 1.5 compilant MPEG DASH videos.
See http://www.hbbtv.org/pages/about_hbbtv/specification.php for more information on the HbbTV 1.5 standard and its DASH profile which is used there.
When it comes to DASH-streaming for HbbTV 1.5 devices, the input arguments for FFmpeg and MP4Box depend on each other. Options to encode a video with FFmpeg for HbbTV terminals could be
FFmpeg -i input.avi -f h264 -c:v libx264 -aspect 16:9 -preset slow -profile:v high -r 50 -g 100 -force_key_frames "expr:gte(t,n_forced*2)" -b:v 3584k -maxrate 3584k -bufsize 7168k -x264opts nal-hrd=vbr -c:a libfdk_aac -b:a 192k -ar 48k -ac 2 output.mp4
In order to make sure that the video will be played back smoothly, the arguments for the bitrate and maxrate of the video should be the same. In addition, the bufsize argument should not be bigger then twice the bitrate.
The arguments for the the GOP and force_key_frames options depend on the length of segments you create with MP4Box.
It is recommended that each segment starts with a keyframe and that one segment includes an entire GOP. in this example, the length for each segment should be at least 2 seconds, or a multiple of 2 seconds.
Options to segment the encoded video could be
MP4Box -dash 2000 -frag 2000 -rap -profile live -segment-name video$Number$ -segment-ext m4s -out video.mpd input.mp4#video:id=1
MP4Box -dash 2000 -frag 2000 -rap -profile live -segment-name audio$Number$ -segment-ext m4s -out audio.mpd input.mp4#audio:id=2
Now each segment and each fragment within the segment has a length of 2 seconds. The required profile for HbbTV devices is the live profile.
If you are looking for adaptive MPEG-DASH or legacy test streams for HbbTV devices, you can find a wide variaty of testcases by following this link: http://av-standard.irt.de/wiki/index.php/Referenzclips

Resources