I can watch videos on a website with MPEG-DASH technology.
I can obtain the video's manifest.mpd
file from the website. (I am not sure whether the file contains any user credentials or not, so I am not going to post it)
The video contains 3 tracks (1 video track + 2 audio tracks), and I found 3 <AdaptationSet/>
elements with attribute mimeType
in manifest.mpd
.
They both contain a <SegmentTemplate/>
element which has an attribute media
containing the segment filename template which is being used to download the segment files in the browser from time to time.
The values to be used to construct the segment file URL are inside SegmentTemplate.SegmentTimeline.S
elements.
For example :
...
<AdaptationSet mimeType="video/mp4" ...other attributes>
<SegmentTemplate
presentationTimeOffset="0"
timescale="90000"
media="chunk_video_$RepresentationID$_cs$Time$_mpd.m4s"
initialization="chunk_video_$RepresentationID$_cinit_mpd.m4s"
>
<SegmentTimeline>
<S t="0" d="900000"/>
<S d="900000" r="352"/>
<S d="638370"/>
</SegmentTimeline>
</SegmentTemplate>
<Representation id="SOME-ID" codecs="avc1.640029" sar="1:1" bandwidth="1268094"/>
<AdaptationSet/>
<AdaptationSet mimeType="audio/mp4" ...other attributes>
...
will produce requests to
https://some-website-domain/some-path/chunk_video_SOME-ID_cinit_mpd.m4s
https://some-website-domain/some-path/chunk_video_SOME-ID_cs0_mpd.m4s
https://some-website-domain/some-path/chunk_video_SOME-ID_cs900000_mpd.m4s
https://some-website-domain/some-path/chunk_video_SOME-ID_cs1800000_mpd.m4s
https://some-website-domain/some-path/chunk_video_SOME-ID_cs2700000_mpd.m4s
...
some-website-domain/some-path
is not sure at this moment, but I could figure this out.
The real question is:
Is it possible to download and encode all the segment files into one single video file?
---- EDIT ----
After running the following command:
ffmpeg -v 48 -i manifest.mpd -c copy out.mp4
I got this output:
Splitting the commandline.
Reading option '-v' ... matched as option 'v' (set logging level) with argument '48'.
Reading option '-i' ... matched as input url with argument 'manifest.mpd'.
Reading option '-c' ... matched as option 'c' (codec name) with argument 'copy'.
Reading option 'out.mp4' ... matched as output url.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option v (set logging level) with argument 48.
Successfully parsed a group of options.
Parsing a group of options: input url manifest.mpd.
Successfully parsed a group of options.
Opening an input file: manifest.mpd.
[NULL @ 0x7feff2000800] Opening 'manifest.mpd' for reading
[file @ 0x7feff1c0b100] Setting default whitelist 'file,crypto'
[AVIOContext @ 0x7feff1c0b2c0] Statistics: 28989 bytes read, 0 seeks
manifest.mpd: Invalid data found when processing input
ffmpeg -i in.mpd -c copy out.mp4
. The dash demuxer will fetch the segments and demux in order.manifest.mpd: Invalid data found when processing input
id
of<Representation/>
is related tomedia
of<SegmentTemplate/>
.