how to play mpd file - mpeg-dash

.
I am trying to understand how mpd file plays and i am referring to the following data set:
http://www-itec.uni-klu.ac.at/ftp/datasets/mmsys12/Valkaama/MPDs/Valkaama_1s_act_isoffmain_DIS_23009_1_v_2_1c2_2011_08_30.mpd
In mpd file format there is segment base consists of mp4 chunk and within it has chunk list with extension .m4s.I downloaded mpd file using :
http://www-itec.uni-klu.ac.at/ftp/datasets/mmsys12/Valkaama/valkaama_1s/valkaama_1s_50kbit/valkaama_50kbit_dash.mp4
and m4s chunk by following link:
http://www-itec.uni-klu.ac.at/ftp/datasets/mmsys12/Valkaama/valkaama_1s/valkaama_1s_50kbit/valkaama_1s1.m4s
I tried to play both mp4 and m4s in vlc player but not able to play any of these two so i want to ask which of the chunk links in the mpd file forma i can be able to play standalone in vlc player.
Please correct me if any of my observations is wrong:
Regards
Mayank

MPD file is just a index of streams with various formats in order to adapt to your bandwidth, to get more information follow the links of the other answers here.
It's possible to download all streams and merge them into a single file, you could achieve this by using youtube-dl:
youtube-dl http://URL/TO/manifest.mpd
You can get more information in https://stackoverflow.com/a/39931712/1522342.
Also, VLC 3.0.0+ can play that kind of file from a url, just open VLC, use the shortcut CTRL+N, paste the url and enjoy.

A DASH player plays an MPD by selecting a Period, and in the Period one or more AdaptationSet, and then one Representation per AdaptationSet. For the chosen Representation, it downloads and passes the intialization segment and some media segments to the media engine. As indicated by others you can simulate that by concatenating (simply using caton Linux).
The MPEG-DASH standard requires that initialization segments (in your case the mp4 file) contain no data. This is because when switching the player might use several times the initialization segment. You can open it in a player but it does not contain any media.
For m4s files, they contain media data but they cannot be interpreted without the associated initialization segment.

you can download init segment (SegmentBase/Initialization#sourceURL) and all media segments (SegmentList/SegmentURL#media) and concatenate everything (e.g. with the copy command on windows). The result should be playable on VLC. This has to be done for audio and video separately. In the next step you can then use MP4Box or similar tools to mux audio and video.
Alternatively you can use www.dash-downloader.com to download everything in one step. The page will display some log explaining what it's doing. That might be helpfull.
(full disclosure: that's my website).

I dont think it is possible to play any of the files in a standalone player. The mp4 is the init segment which is required to decode the .m4s media segments. I dont think there is an option in the vlc player to map an init segment to multiple media segments. Nevertheless you can try a Dash player to play the manifest file. For instance dash.js
Initialization segment: A sequence of bytes that contain all of the initialization information required to decode a sequence of media segments. This includes codec initialization data, Track ID mappings for multiplexed segments, and timestamp offsets (e.g. edit lists).
Media segment: A sequence of bytes that contain packetized & timestamped media data for a portion of the media timeline. Media segments are always associated with the most recently appended initialization segment.
Source: http://www.w3.org/TR/media-source/#init-segment

Related

Building m3u8 playlist with mp4 files

I own a digital receiver which could also play IPTV channels (m3u8). I want to build my own local IPTV station to be able to watch a video playlist on TV. I configured a computer as a web server. Now, I am trying to build the m3u8 playlist. I tried to add the video files (mp4) to a blank m3u8 file.
#EXTM3U
file1.mp4
file2.mp4
The problem is that my IPTV player only plays file1.mp4 then stops. I am new to hls, however I would like to avoid to convert all my videos to hls with ts segments.
Are there any ways to make it working? Thank you!
While the first mp4 is recognized and played correctly, it isn't the 'correct' type of mp4 file to be played in this type of playlist. They need to be encoded as 'Fragmented MPEG-4' files. I'm suspecting that each file needs to contain a bit of information about the next segment.
From RFC 8216:
3.3. Fragmented MPEG-4
MPEG-4 Fragments are specified by the ISO Base Media File Format
[ISOBMFF]. Unlike regular MPEG-4 files that have a Movie Box
('moov') that contains sample tables and a Media Data Box ('mdat')
containing the corresponding samples, an MPEG-4 Fragment consists of
a Movie Fragment Box ('moof') containing a subset of the sample table
and a Media Data Box containing those samples. Use of MPEG-4
Fragments does require a Movie Box for initialization, but that Movie
Box contains only non-sample-specific information such as track and
sample descriptions.
A Fragmented MPEG-4 (fMP4) Segment is a "segment" as defined by
Section 3 of [ISOBMFF], including the constraints on Media Data Boxes
in Section 8.16 of [ISOBMFF].
The Media Initialization Section for an fMP4 Segment is an ISO Base
Media File that can initialize a parser for that Segment.
Broadly speaking, fMP4 Segments and Media Initialization Sections
are [ISOBMFF] files that also satisfy the constraints described in
this section.
The Media Initialization Section for an fMP4 Segment MUST contain a
File Type Box ('ftyp') containing a brand that is compatible with
'iso6' or higher. The File Type Box MUST be followed by a Movie Box.
The Movie Box MUST contain a Track Box ('trak') for every Track
Fragment Box ('traf') in the fMP4 Segment, with matching track_ID.
Each Track Box SHOULD contain a sample table, but its sample count
MUST be zero. Movie Header Boxes ('mvhd') and Track Header Boxes
('tkhd') MUST have durations of zero. A Movie Extends Box ('mvex')
MUST follow the last Track Box. Note that a Common Media Application
Format (CMAF) Header [CMAF] meets all these requirements.

How to include same segment into m3u8 playlist multiple times?

I have several .ts files, generated by ffmpeg from live stream. All of them have the same length (well, approximately). Ideally, they are being generated constantly, with names representing the datetime when they have been recorded (for example, "2019-04-11_10-51-40.ts"). But it may happen so, that for any technical reasons recording was being stopped for a while and files have not been generated.
Now, I have a task to create a playlist of these files for a certain datetime range - and if there are no files for part of this range, I need to show just a black screen. I have a black video for this purpose with the same length as other files. So, I'm trying to manually create an .m3u8 file and insert this black video in all gaps between normal videos that I have. For example:
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:34
#EXT-X-PLAYLIST-TYPE:VOD
#EXTINF:30.07,
http://example.com/black_video.ts
#EXTINF:30.07,
http://example.com/black_video.ts
#EXTINF:33.33,
http://example.com/2019-04-11_10-51-40.ts
#EXTINF:33.33,
http://example.com/2019-04-11_10-52-15.ts
#EXTINF:25.00,
http://example.com/2019-04-11_10-52-48.ts
#EXT-X-ENDLIST
The problem is that when I'm trying to play this playlist, it does not play correctly: depending on player either only one black part is being played no matter how much of them there are in a sequence (VLC), or player is getting stuck after first black video ("Play HLS M3u8" extension for Chrome or player on our own service, based on hls.js).
I also tried to use #EXT-X-DISCONTINUITY; in this case all videos are being played, but progress bar drops to the very beginning after each #EXT-X-DISCONTINUITY appearance, which is also an undesired behaviour. Example:
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:34
#EXT-X-PLAYLIST-TYPE:VOD
#EXTINF:30.07,
http://example.com/black_video.ts
#EXT-X-DISCONTINUITY
#EXTINF:30.07,
http://example.com/black_video.ts
#EXTINF:33.33,
http://example.com/2019-04-11_10-51-40.ts
#EXTINF:33.33,
http://example.com/2019-04-11_10-52-15.ts
#EXTINF:25.00,
http://example.com/2019-04-11_10-52-48.ts
#EXT-X-ENDLIST
As for black videos themselves, I tried several options: each link was to the same file; each link was to a different symlink to the same file; each link was to a separately generated black video - none of them worked.
As of now the only way I found is to collect all normal videos for the time range, fill the gaps with black video files and then combine them into one file with ffmpeg -f concat and split the concatenated file back to parts. But this approach works way longer than manual m3u8 file creation, so I would like to avoid it.
So, what could be the reason of manually formed playlist not working correctly and how could I fix that? May it be the problem with playlist itself, or playlist is technically fine but players I used possibly don't fully implement the specification?
TLDR: I am creating m3u8 playlist manually and I want to insert the same video multiple times into this playlist. Unfortunately, such playlist is not being played correctly: depending on player either this inserted video is being played only once no matter how many times has it been included, or playing is getting stuck after the first inserted video part. May it be that there is something wrong with playlist and how can this be fixed?
Add a #EXT-X-DISCONTINUITY tag before and after black_video.ts file and change the #EXT-X-VERSION tag to 5. That should fix the issue. This solution worked for me on VLC player.

For an HLS VOD Stream, Is it possible to only play specific Media Sequences in a Media Playlist File?

I'd like to play specific time-segments from an HLS Stream, without needing to re-edit the original MP4 file. Is it possible to alter the Media Playlist File to play specific TS Media Sequences that are out of order?
For instance, in the below M3U list, is it possible to only play fileSequence0-fileSequence2, then skip over fileSequence3 and go right to fileSequence4?
Example M3U List:
#EXTM3U
#EXT-X-PLAYLIST-TYPE:EVENT
#EXT-X-TARGETDURATION:10
#EXT-X-VERSION:4
#EXT-X-MEDIA-SEQUENCE:0
#EXTINF:10.0,
fileSequence0.ts
#EXTINF:10.0,
fileSequence1.ts
#EXTINF:10.0,
fileSequence2.ts
#EXTINF:10.0,
fileSequence3.ts
#EXTINF:10.0,
fileSequence4.ts
According to HLS Documentation, I would need to change or omit the Media Sequence Number for fileSequence3.ts in order to skip it, but I'm unsure if this is possible.
6.3.5. Determining the Next Segment to Load
...
The first segment to load is generally the segment that the client has chosen to play first (see Section 6.3.3).
In order to play the presentation normally, the next Media Segment to load is the one with the lowest Media Sequence Number that is greater than the Media Sequence Number of the last Media Segment loaded.
Yes, you can play them in any order, Just put a #EXT-X-DISCONTINUITY tag before any 'splice'. You also need #EXT-X-ENDLIST at the end, or the player will assume this is a live manifest and only play the most recent segments.
If the segments do not begin with keyframes however, you may not get the result you want.

Can .m3u8 playlist files reference OTHER .m3u8 playlist files?

I know that the EXT-X-STREAM-INF tag provides a mechanism for linking to another playlist file, but this appears to be to support variant encoding's (at lower or higher bandwidth) of the same stream. What I would like to do is return a playlist that references actual .ts files but the last reference in the playlist is to the "next" .m3u8.
The reason I want this is that I can use this mechanism to build a stateless HLS server that is not necessarily serving a "live" stream (because the playlist URL can encode information about WHERE in the stream you are). Any idea what players support this (does iOS?)?
It is not supported in the draft specification (as of draft 10).
Yes They can. The main m3u8 that holds other m3u8 is called variant playlist m3u8.
But why we need a variant playlist? - for storing various bit rates of the same stream
I used "One Click m3u8" app from the mac app store - that created the variant playlist as well the children m3u8. No need of ffmpeg or mediafilesegmenter.
How to video here from youtube
Website

Rebuilding MP4 file from fragmented MP4 "mdat" atom?

I'm trying to rebuild a video file from a Smooth Streaming server. Smooth Streaming serves fMP4 files which are regular MP4 files without neither their FTYP nor their MOOV atoms.
All the informations stored in those atom are placed into a Manifest XML file, which I have.
Is there a way to programmatically rebuild the original MP4 file, either by:
rebuilding a new file straight from H264/AAC content located in MDAT
(and picture format infos); or
rebuilding FTYP and MOOV atoms
Or else, is there a tool which can merge fMP4?
Yes. It is completely possible.
You can do this with FFmpeg. Study the mov.c [MP4 demuxer] from libavformat.
You will need to complete the MP4 in memory with all data that is "missing" in the fMP4. In other words, when you need an atom that doesn't exist in fMP4 [almost all], you will have to input all information hard-coded (such information, most of them come from the manifest).
It's not easy... but for sure it's possible. I've done by myself. Unfortunately the code is not my property.
Good luck! ;-)
UPDATE: the PIFF format specification will be very useful (http://go.microsoft.com/?linkid=9682897) so one can understand what is already in the fMP4 and what is not!
It is simple to rebuild a mp4 file, if there are ism and ismc file which are related to fragmented mp4 files.
It is requested that you should know media type, codec type, codec specific data and time scale of each trak to rebuild a moov and ftyp atom.
these information can be retrieved from ism and ismc file.
you can retrieve a media type of each track from the ism file.
you can retrieve codec type, codec specific data and time scale of each track from the ismc file.
simply speaking, ism/ismc files are meta data for server and client so that you can rebuild meta data(ftyp, moov atom) for a mp4 file.

Resources