how to add dynamic urls (s3 presigned url) in dash.mpd file?

254 views Asked by At

I have generated the dash.mpd file using python-ffmpeg-video-streaming python module.

<?xml version="1.0" encoding="utf-8"?>
<MPD xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="urn:mpeg:dash:schema:mpd:2011"
    xmlns:xlink="http://www.w3.org/1999/xlink"
    xsi:schemaLocation="urn:mpeg:DASH:schema:MPD:2011 http://standards.iso.org/ittf/PubliclyAvailableStandards/MPEG-DASH_schema_files/DASH-MPD.xsd"
    profiles="urn:mpeg:dash:profile:isoff-live:2011"
    type="static"
    mediaPresentationDuration="PT24.5S"
    maxSegmentDuration="PT5.0S"
    minBufferTime="PT16.6S">
    <ProgramInformation>
    </ProgramInformation>
    <ServiceDescription id="0">
    </ServiceDescription>
    <Period id="0" start="PT0.0S">
        <AdaptationSet id="0" contentType="video" startWithSAP="1" segmentAlignment="true" bitstreamSwitching="true" frameRate="60/1" maxWidth="256" maxHeight="144" par="16:9" lang="und">
            <Representation id="0" mimeType="video/mp4" codecs="avc1.64000d" bandwidth="95000" width="256" height="144" sar="1:1">
                <SegmentTemplate timescale="15360" initialization="static/dash_init_$RepresentationID$.m4s" media="static/dash_chunk_$RepresentationID$_$Number%05d$.m4s" startNumber="1">
                    <SegmentTimeline>
                        <S t="0" d="128000" r="1" />
                        <S d="121088" />
                    </SegmentTimeline>
                </SegmentTemplate>
            </Representation>
        </AdaptationSet>
        <AdaptationSet id="1" contentType="audio" startWithSAP="1" segmentAlignment="true" bitstreamSwitching="true" lang="und">
            <Representation id="1" mimeType="audio/mp4" codecs="mp4a.40.2" bandwidth="64000" audioSamplingRate="48000">
                <AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="1" />
                <SegmentTemplate timescale="48000" initialization="static/dash_init_$RepresentationID$.m4s" media="static/dash_chunk_$RepresentationID$_$Number%05d$.m4s" startNumber="1">
                    <SegmentTimeline>
                        <S t="0" d="239592" />
                        <S d="240640" r="2" />
                        <S d="217088" />
                    </SegmentTimeline>
                </SegmentTemplate>
            </Representation>
        </AdaptationSet>
        <AdaptationSet id="2" contentType="video" startWithSAP="1" segmentAlignment="true" bitstreamSwitching="true" frameRate="60/1" maxWidth="426" maxHeight="240" par="71:40" lang="und">
            <Representation id="2" mimeType="video/mp4" codecs="avc1.64001e" bandwidth="150000" width="426" height="240" sar="1:1">
                <SegmentTemplate timescale="15360" initialization="static/dash_init_$RepresentationID$.m4s" media="static/dash_chunk_$RepresentationID$_$Number%05d$.m4s" startNumber="1">
                    <SegmentTimeline>
                        <S t="0" d="128000" r="1" />
                        <S d="121088" />
                    </SegmentTimeline>
                </SegmentTemplate>
            </Representation>
        </AdaptationSet>
        <AdaptationSet id="3" contentType="audio" startWithSAP="1" segmentAlignment="true" bitstreamSwitching="true" lang="und">
            <Representation id="3" mimeType="audio/mp4" codecs="mp4a.40.2" bandwidth="94000" audioSamplingRate="48000">
                <AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="1" />
                <SegmentTemplate timescale="48000" initialization="static/dash_init_$RepresentationID$.m4s" media="static/dash_chunk_$RepresentationID$_$Number%05d$.m4s" startNumber="1">
                    <SegmentTimeline>
                        <S t="0" d="239592" />
                        <S d="240640" r="2" />
                        <S d="217088" />
                    </SegmentTimeline>
                </SegmentTemplate>
            </Representation>
        </AdaptationSet>
        <AdaptationSet id="4" contentType="video" startWithSAP="1" segmentAlignment="true" bitstreamSwitching="true" frameRate="60/1" maxWidth="640" maxHeight="360" par="16:9" lang="und">
            <Representation id="4" mimeType="video/mp4" codecs="avc1.64001f" bandwidth="276000" width="640" height="360" sar="1:1">
                <SegmentTemplate timescale="15360" initialization="static/dash_init_$RepresentationID$.m4s" media="static/dash_chunk_$RepresentationID$_$Number%05d$.m4s" startNumber="1">
                    <SegmentTimeline>
                        <S t="0" d="128000" r="1" />
                        <S d="121088" />
                    </SegmentTimeline>
                </SegmentTemplate>
            </Representation>
        </AdaptationSet>
        <AdaptationSet id="5" contentType="audio" startWithSAP="1" segmentAlignment="true" bitstreamSwitching="true" lang="und">
            <Representation id="5" mimeType="audio/mp4" codecs="mp4a.40.2" bandwidth="128000" audioSamplingRate="48000">
                <AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="1" />
                <SegmentTemplate timescale="48000" initialization="static/dash_init_$RepresentationID$.m4s" media="static/dash_chunk_$RepresentationID$_$Number%05d$.m4s" startNumber="1">
                    <SegmentTimeline>
                        <S t="0" d="239592" />
                        <S d="240640" r="2" />
                        <S d="217088" />
                    </SegmentTimeline>
                </SegmentTemplate>
            </Representation>
        </AdaptationSet>
        <AdaptationSet id="6" contentType="video" startWithSAP="1" segmentAlignment="true" bitstreamSwitching="true" frameRate="60/1" maxWidth="854" maxHeight="480" par="427:240" lang="und">
            <Representation id="6" mimeType="video/mp4" codecs="avc1.64001f" bandwidth="750000" width="854" height="480" sar="1:1">
                <SegmentTemplate timescale="15360" initialization="static/dash_init_$RepresentationID$.m4s" media="static/dash_chunk_$RepresentationID$_$Number%05d$.m4s" startNumber="1">
                    <SegmentTimeline>
                        <S t="0" d="128000" r="1" />
                        <S d="121088" />
                    </SegmentTimeline>
                </SegmentTemplate>
            </Representation>
        </AdaptationSet>
        <AdaptationSet id="7" contentType="audio" startWithSAP="1" segmentAlignment="true" bitstreamSwitching="true" lang="und">
            <Representation id="7" mimeType="audio/mp4" codecs="mp4a.40.2" bandwidth="192000" audioSamplingRate="48000">
                <AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="1" />
                <SegmentTemplate timescale="48000" initialization="static/dash_init_$RepresentationID$.m4s" media="static/dash_chunk_$RepresentationID$_$Number%05d$.m4s" startNumber="1">
                    <SegmentTimeline>
                        <S t="0" d="239592" />
                        <S d="240640" r="2" />
                        <S d="217088" />
                    </SegmentTimeline>
                </SegmentTemplate>
            </Representation>
        </AdaptationSet>
        <AdaptationSet id="8" contentType="video" startWithSAP="1" segmentAlignment="true" bitstreamSwitching="true" frameRate="60/1" maxWidth="1280" maxHeight="720" par="16:9" lang="und">
            <Representation id="8" mimeType="video/mp4" codecs="avc1.640020" bandwidth="2048000" width="1280" height="720" sar="1:1">
                <SegmentTemplate timescale="15360" initialization="static/dash_init_$RepresentationID$.m4s" media="static/dash_chunk_$RepresentationID$_$Number%05d$.m4s" startNumber="1">
                    <SegmentTimeline>
                        <S t="0" d="128000" r="1" />
                        <S d="121088" />
                    </SegmentTimeline>
                </SegmentTemplate>
            </Representation>
        </AdaptationSet>
        <AdaptationSet id="9" contentType="audio" startWithSAP="1" segmentAlignment="true" bitstreamSwitching="true" lang="und">
            <Representation id="9" mimeType="audio/mp4" codecs="mp4a.40.2" bandwidth="288000" audioSamplingRate="48000">
                <AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="1" />
                <SegmentTemplate timescale="48000" initialization="static/dash_init_$RepresentationID$.m4s" media="static/dash_chunk_$RepresentationID$_$Number%05d$.m4s" startNumber="1">
                    <SegmentTimeline>
                        <S t="0" d="239592" />
                        <S d="240640" r="2" />
                        <S d="217088" />
                    </SegmentTimeline>
                </SegmentTemplate>
            </Representation>
        </AdaptationSet>
        <AdaptationSet id="10" contentType="video" startWithSAP="1" segmentAlignment="true" bitstreamSwitching="true" frameRate="60/1" maxWidth="1920" maxHeight="1080" par="16:9" lang="und">
            <Representation id="10" mimeType="video/mp4" codecs="avc1.64002a" bandwidth="4096000" width="1920" height="1080" sar="1:1">
                <SegmentTemplate timescale="15360" initialization="static/dash_init_$RepresentationID$.m4s" media="static/dash_chunk_$RepresentationID$_$Number%05d$.m4s" startNumber="1">
                    <SegmentTimeline>
                        <S t="0" d="128000" />
                        <S d="120320" />
                        <S d="128000" />
                        <S d="768" />
                    </SegmentTimeline>
                </SegmentTemplate>
            </Representation>
        </AdaptationSet>
        <AdaptationSet id="11" contentType="audio" startWithSAP="1" segmentAlignment="true" bitstreamSwitching="true" lang="und">
            <Representation id="11" mimeType="audio/mp4" codecs="mp4a.40.2" bandwidth="288000" audioSamplingRate="48000">
                <AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="1" />
                <SegmentTemplate timescale="48000" initialization="static/dash_init_$RepresentationID$.m4s" media="static/dash_chunk_$RepresentationID$_$Number%05d$.m4s" startNumber="1">
                    <SegmentTimeline>
                        <S t="0" d="239592" />
                        <S d="240640" r="2" />
                        <S d="217088" />
                    </SegmentTimeline>
                </SegmentTemplate>
            </Representation>
        </AdaptationSet>
        <AdaptationSet id="12" contentType="video" startWithSAP="1" segmentAlignment="true" bitstreamSwitching="true" frameRate="60/1" maxWidth="2560" maxHeight="1440" par="16:9" lang="und">
            <Representation id="12" mimeType="video/mp4" codecs="avc1.640033" bandwidth="6144000" width="2560" height="1440" sar="1:1">
                <SegmentTemplate timescale="15360" initialization="static/dash_init_$RepresentationID$.m4s" media="static/dash_chunk_$RepresentationID$_$Number%05d$.m4s" startNumber="1">
                    <SegmentTimeline>
                        <S t="0" d="128000" />
                        <S d="119552" />
                        <S d="128000" />
                        <S d="1536" />
                    </SegmentTimeline>
                </SegmentTemplate>
            </Representation>
        </AdaptationSet>
        <AdaptationSet id="13" contentType="audio" startWithSAP="1" segmentAlignment="true" bitstreamSwitching="true" lang="und">
            <Representation id="13" mimeType="audio/mp4" codecs="mp4a.40.2" bandwidth="288000" audioSamplingRate="48000">
                <AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="1" />
                <SegmentTemplate timescale="48000" initialization="static/dash_init_$RepresentationID$.m4s" media="static/dash_chunk_$RepresentationID$_$Number%05d$.m4s" startNumber="1">
                    <SegmentTimeline>
                        <S t="0" d="239592" />
                        <S d="240640" r="2" />
                        <S d="217088" />
                    </SegmentTimeline>
                </SegmentTemplate>
            </Representation>
        </AdaptationSet>
        <AdaptationSet id="14" contentType="video" startWithSAP="1" segmentAlignment="true" bitstreamSwitching="true" frameRate="60/1" maxWidth="3840" maxHeight="2160" par="16:9" lang="und">
            <Representation id="14" mimeType="video/mp4" codecs="avc1.640034" bandwidth="17408000" width="3840" height="2160" sar="1:1">
                <SegmentTemplate timescale="15360" initialization="static/dash_init_$RepresentationID$.m4s" media="static/dash_chunk_$RepresentationID$_$Number%05d$.m4s" startNumber="1">
                    <SegmentTimeline>
                        <S t="0" d="119808" />
                        <S d="101888" />
                        <S d="128000" />
                        <S d="27392" />
                    </SegmentTimeline>
                </SegmentTemplate>
            </Representation>
        </AdaptationSet>
        <AdaptationSet id="15" contentType="audio" startWithSAP="1" segmentAlignment="true" bitstreamSwitching="true" lang="und">
            <Representation id="15" mimeType="audio/mp4" codecs="mp4a.40.2" bandwidth="288000" audioSamplingRate="48000">
                <AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="1" />
                <SegmentTemplate timescale="48000" initialization="static/dash_init_$RepresentationID$.m4s" media="static/dash_chunk_$RepresentationID$_$Number%05d$.m4s" startNumber="1">
                    <SegmentTimeline>
                        <S t="0" d="239592" />
                        <S d="240640" r="2" />
                        <S d="217088" />
                    </SegmentTimeline>
                </SegmentTemplate>
            </Representation>
        </AdaptationSet>
    </Period>
</MPD>

how to add dynamic s3 presigned url as baseurl, so I can serve the small video files from s3 but only authenticated user can access dash.mpd file

I am using a backend server for authentication and s3 for serving the file, I am also using dash mpd technology to serve videos but I want to create dynamic dash.mpd file which can help me expire the s3 presigned url and add new presigned url again for security purpose.

0

There are 0 answers