0

I have built a simple mpeg-dash player using exoplayer API in Android. It reads and plays this MPD file. But can't play the following MPD file generated by FFmpeg:

ffmpeg -re -i .\video-h264.mkv -map 0 -map 0 -c:a aac -c:v libx264 -b:v:0 800k -b:v:1 300k -s:v:1 320x170 -profile:v:1 baseline -profile:v:0 main -bf 1 -keyint_min 120 -g 120 -sc_threshold 0 -b_strategy 0 -ar:a:1 22050 -use_timeline 1 -use_template 1 -window_size 5 -adaptation_sets "id=0,streams=v id=1,streams=a" -f dash out.mpd

What is the issue? I can't understand it.

<?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="PT16.0S"
maxSegmentDuration="PT5.0S"
minBufferTime="PT10.0S">
    <ProgramInformation>
    </ProgramInformation>
    <ServiceDescription id="0">
    </ServiceDescription>
    <Period id="0" start="PT0.0S">
        <AdaptationSet id="0" contentType="video" startWithSAP="1" segmentAlignment="true" bitstreamSwitching="true" frameRate="24/1" maxWidth="1920" maxHeight="960" par="2:1">
            <Representation id="0" mimeType="video/mp4" codecs="avc1.4d4028" bandwidth="800000" width="1920" height="960" sar="1:1">
                <SegmentTemplate timescale="12288" initialization="init-stream$RepresentationID$.m4s" media="chunk-stream$RepresentationID$-$Number%05d$.m4s" startNumber="1">
                    <SegmentTimeline>
                        <S t="0" d="61440" r="2" />
                        <S d="13312" />
                    </SegmentTimeline>
                </SegmentTemplate>
            </Representation>
            <Representation id="2" mimeType="video/mp4" codecs="avc1.42c00d" bandwidth="300000" width="320" height="170" sar="17:16">
                <SegmentTemplate timescale="12288" initialization="init-stream$RepresentationID$.m4s" media="chunk-stream$RepresentationID$-$Number%05d$.m4s" startNumber="1">
                    <SegmentTimeline>
                        <S t="0" d="61440" r="2" />
                        <S d="13312" />
                    </SegmentTimeline>
                </SegmentTemplate>
            </Representation>
        </AdaptationSet>
        <AdaptationSet id="1" contentType="audio" startWithSAP="1" segmentAlignment="true" bitstreamSwitching="true" lang="eng">
            <Representation id="1" mimeType="audio/mp4" codecs="mp4a.40.2" bandwidth="128000" audioSamplingRate="48000">
                <AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2" />
                <SegmentTemplate timescale="48000" initialization="init-stream$RepresentationID$.m4s" media="chunk-stream$RepresentationID$-$Number%05d$.m4s" startNumber="1">
                    <SegmentTimeline>
                        <S t="0" d="238584" />
                        <S d="239616" />
                        <S d="240640" />
                        <S d="50176" />
                    </SegmentTimeline>
                </SegmentTemplate>
            </Representation>
            <Representation id="3" mimeType="audio/mp4" codecs="mp4a.40.2" bandwidth="128000" audioSamplingRate="22050">
                <AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2" />
                <SegmentTemplate timescale="22050" initialization="init-stream$RepresentationID$.m4s" media="chunk-stream$RepresentationID$-$Number%05d$.m4s" startNumber="1">
                    <SegmentTimeline>
                        <S t="0" d="109564" />
                        <S d="110592" r="1" />
                        <S d="22519" />
                    </SegmentTimeline>
                </SegmentTemplate>
            </Representation>
        </AdaptationSet>
    </Period>
</MPD>

My simple ExoPlayer API code is HERE. And my MPD is located on a local server. The error I get is this:

2022-01-20 11:49:13.751 11201-11929/com.example.myexoplayer E/ExoPlayerImplInternal: Source error.
    com.google.android.exoplayer2.upstream.HttpDataSource$HttpDataSourceException: Unable to connect to http://192.168.80.80/dash/out.mpd
        at com.google.android.exoplayer2.upstream.DefaultHttpDataSource.open(DefaultHttpDataSource.java:194)
        at com.google.android.exoplayer2.upstream.DataSourceInputStream.checkOpened(DataSourceInputStream.java:102)
        at com.google.android.exoplayer2.upstream.DataSourceInputStream.open(DataSourceInputStream.java:65)
        at com.google.android.exoplayer2.upstream.ParsingLoadable.load(ParsingLoadable.java:114)
        at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:295)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:923)
     Caused by: java.io.IOException: Cleartext HTTP traffic to 192.168.80.80 not permitted
        at com.android.okhttp.HttpHandler$CleartextURLFilter.checkURLPermitted(HttpHandler.java:127)
        at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:462)
        at com.android.okhttp.internal.huc.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:131)
        at com.google.android.exoplayer2.upstream.DefaultHttpDataSource.makeConnection(DefaultHttpDataSource.java:429)
        at com.google.android.exoplayer2.upstream.DefaultHttpDataSource.makeConnection(DefaultHttpDataSource.java:350)
        at com.google.android.exoplayer2.upstream.DefaultHttpDataSource.open(DefaultHttpDataSource.java:192)
        at com.google.android.exoplayer2.upstream.DataSourceInputStream.checkOpened(DataSourceInputStream.java:102) 
        at com.google.android.exoplayer2.upstream.DataSourceInputStream.open(DataSourceInputStream.java:65) 
        at com.google.android.exoplayer2.upstream.ParsingLoadable.load(ParsingLoadable.java:114) 
        at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:295) 
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 
        at java.lang.Thread.run(Thread.java:923) 
Tina J
  • 4,983
  • 13
  • 59
  • 125
  • Try the following parameter when using ffmpeg: -use_timeline 0 -use_template 1 – Markus Schumann Jan 19 '22 at 21:50
  • No luck again. I added my ffmpeg command above. One difference is that the working mpd has .m4v and .m4a files, while the one I generate has .m4s! – Tina J Jan 20 '22 at 09:10
  • Is there any logging that you can turn on for the Exoplayer? – Markus Schumann Jan 20 '22 at 13:11
  • Just added the logs. Looks like it might be due to MPD being on a local server and it can't read it :-| – Tina J Jan 20 '22 at 17:53
  • 2
    Apparently it's because of not supporting HTTP (must be HTTPS)! I added this to my Android manifest and it's working now: `android:usesCleartextTraffic="true"` – Tina J Jan 20 '22 at 17:59
  • 1
    I am glad you figured it out! – Markus Schumann Jan 20 '22 at 21:06
  • @MarkusSchumann a general question: when using adaptive streaming, do the videos have to be segmented? I like to have a simpler solution where we only keep 2 representations of WHOLE video, and player only at the beginning of playout seletcs the right quality. But plays that same quality the whole time. So no chunking. – Tina J Jan 20 '22 at 23:31
  • 1
    At this point you are doing something the player and system wasn't designed for. So I would either change the Exoplayer not to switch bitrates or implement my own player. I am guessing that a player typically starts with a lower bitrate, then times the bandwidth and adjusts. So at the beginning the player doesn't have any bandwidth information. Also - if you lock the player into one bitrate then you can't accommodate for changing network condition. – Markus Schumann Jan 21 '22 at 15:54
  • I asked two questions on Video SE. Your thoughts would be very useful: https://video.stackexchange.com/questions/34895 and https://video.stackexchange.com/questions/34893/ – Tina J Jan 21 '22 at 20:40

0 Answers0