I am using the following ffmpeg command to generate MPEG DASH files and manifest. I use single_file 1 to have a single file for each representation; so no chunking. But IDK why when I want to play the manifest using ExoPlayer, the video doesn't play from the beginning (rather it starts from around 50s).
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 -single_file 1 -use_template 1 -window_size 5 -adaptation_sets "id=0,streams=v id=1,streams=a" -f dash out.mpd
What is wrong with this? Is the manifest correct? Here is the generated mpd:
<?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="PT1M20.1S"
maxSegmentDuration="PT5.0S"
minBufferTime="PT16.0S">
<ProgramInformation>
</ProgramInformation>
<ServiceDescription id="0">
</ServiceDescription>
<Period id="0" start="PT48.0S">
<AdaptationSet id="0" contentType="video" startWithSAP="1" segmentAlignment="true" bitstreamSwitching="true" frameRate="30/1" maxWidth="960" maxHeight="540" par="517072:290799" lang="eng">
<Representation id="0" mimeType="video/mp4" codecs="avc1.4d401f" bandwidth="800000" width="960" height="540" sar="32317:32311">
<BaseURL>out-stream0.mp4</BaseURL>
<SegmentList timescale="1000000" duration="5000000" startNumber="7">
<Initialization range="0-832" />
<SegmentURL mediaRange="4800141-5599188" indexRange="4800141-4800192" />
<SegmentURL mediaRange="5599189-6243069" indexRange="5599189-5599240" />
<SegmentURL mediaRange="6243070-7224302" indexRange="6243070-6243121" />
<SegmentURL mediaRange="7224303-8138118" indexRange="7224303-7224354" />
<SegmentURL mediaRange="8138119-8232111" indexRange="8138119-8138170" />
</SegmentList>
</Representation>
<Representation id="2" mimeType="video/mp4" codecs="avc1.42c00d" bandwidth="300000" width="320" height="170" sar="549389:581598">
<BaseURL>out-stream2.mp4</BaseURL>
<SegmentList timescale="1000000" duration="5000000" startNumber="7">
<Initialization range="0-832" />
<SegmentURL mediaRange="1782920-2005667" indexRange="1782920-1782971" />
<SegmentURL mediaRange="2005668-2229412" indexRange="2005668-2005719" />
<SegmentURL mediaRange="2229413-2615209" indexRange="2229413-2229464" />
<SegmentURL mediaRange="2615210-2975346" indexRange="2615210-2615261" />
<SegmentURL mediaRange="2975347-2999288" indexRange="2975347-2975398" />
</SegmentList>
</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="69000" audioSamplingRate="44100">
<AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="1" />
<BaseURL>out-stream1.mp4</BaseURL>
<SegmentList timescale="1000000" duration="5000000" startNumber="12">
<Initialization range="0-764" />
<SegmentURL mediaRange="491493-536039" indexRange="491493-491544" />
<SegmentURL mediaRange="536040-580657" indexRange="536040-536091" />
<SegmentURL mediaRange="580658-625158" indexRange="580658-580709" />
<SegmentURL mediaRange="625159-669825" indexRange="625159-625210" />
<SegmentURL mediaRange="669826-713289" indexRange="669826-669877" />
</SegmentList>
</Representation>
<Representation id="3" mimeType="audio/mp4" codecs="mp4a.40.2" bandwidth="69000" audioSamplingRate="22050">
<AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="1" />
<BaseURL>out-stream3.mp4</BaseURL>
<SegmentList timescale="1000000" duration="5000000" startNumber="12">
<Initialization range="0-764" />
<SegmentURL mediaRange="486188-530059" indexRange="486188-486239" />
<SegmentURL mediaRange="530060-574175" indexRange="530060-530111" />
<SegmentURL mediaRange="574176-618922" indexRange="574176-574227" />
<SegmentURL mediaRange="618923-663118" indexRange="618923-618974" />
<SegmentURL mediaRange="663119-706121" indexRange="663119-663170" />
</SegmentList>
</Representation>
</AdaptationSet>
</Period>
</MPD>
you need to remove
-window_size 5
it keeps only 5 segments of video in mpd
https://ffmpeg.org/ffmpeg-formats.html#dash-2
Related
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)
I can set cast.framework.PlaybackConfig.initialBandwidth. I am wondering is there a setting for max bandwidth throughout the playback.
Below is the manifest that I am receiving, Chromecast player is auto switching according to my current network speed. I want to set a max bandwidth to 2987000 so it can never go to 1080p.
<Representation bandwidth="79000" codecs="avc1.42000c" frameRate="2997/100" height="144" id="7c96d52b-6a35-406f-bcb8-d1fbdca1892c" width="256"></Representation>
<Representation bandwidth="199000" codecs="avc1.42000c" frameRate="2997/100" height="160" id="6c20b31e-4503-4c58-ac87-e431ca0814b1" width="284"></Representation>
<Representation bandwidth="349000" codecs="avc1.420015" frameRate="2997/100" height="240" id="5f38f276-918e-4b53-9e59-49828e8370e1" width="426"></Representation>
<Representation bandwidth="597000" codecs="avc1.4d001e" frameRate="2997/100" height="360" id="f98c3885-6a69-40c1-b41d-cf497fe144db" width="640"></Representation>
<Representation bandwidth="848000" codecs="avc1.4d001f" frameRate="2997/100" height="540" id="9efd598f-ab6a-48df-850a-f74e5787c35d" width="960"></Representation>
<Representation bandwidth="1094000" codecs="avc1.4d001f" frameRate="2997/100" height="576" id="4a4c0dae-1e42-45cc-a0ec-c35ebc9a1d1b" width="1024"></Representation>
<Representation bandwidth="1495000" codecs="avc1.4d001f" frameRate="2997/100" height="576" id="a023a254-0885-4ddf-895b-839f5cb384ce" width="1024"></Representation>
<Representation bandwidth="1995000" codecs="avc1.64001f" frameRate="2997/100" height="720" id="1007e5e6-8400-4d92-bcd8-8cfdaf4dde1d" width="1280"></Representation>
<Representation bandwidth="2987000" codecs="avc1.64001f" frameRate="2997/100" height="720" id="e0879e7b-19e3-4c65-8063-300411fc40bf" width="1280"></Representation>
<Representation bandwidth="4482000" codecs="avc1.640028" frameRate="2997/100" height="1080" id="5576c06c-3a6a-4167-ba7a-803b424af204" width="1920"></Representation>
I am facing issue with onbeforeunload window event popup in chrome. I have installed chrome extension.
Steps:
Create Open Browser activity with url:
https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_onbeforeunload"\
Create Click Event with selector:
<webctrl aaname='Click here to go to w3schools.com' tag='A' />
Create Click Event with selector:
<ctrl name='Leave site?' role='dialog' /><ctrl name='Leave' role='push button' />
My problem is the second click is not working.
Main.xaml:
<Activity mc:Ignorable="sap sap2010 sads" x:Class="Main" mva:VisualBasic.Settings="{x:Null}" sap2010:WorkflowViewState.IdRef="Main_1"
xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:mva="clr-namespace:Microsoft.VisualBasic.Activities;assembly=System.Activities"
xmlns:sads="http://schemas.microsoft.com/netfx/2010/xaml/activities/debugger"
xmlns:sap="http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation"
xmlns:sap2010="http://schemas.microsoft.com/netfx/2010/xaml/activities/presentation"
xmlns:scg="clr-namespace:System.Collections.Generic;assembly=mscorlib"
xmlns:sco="clr-namespace:System.Collections.ObjectModel;assembly=mscorlib"
xmlns:ui="http://schemas.uipath.com/workflow/activities"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<TextExpression.NamespacesForImplementation>
<sco:Collection x:TypeArguments="x:String">
<x:String>System.Activities</x:String>
<x:String>System.Activities.Statements</x:String>
<x:String>System.Activities.Expressions</x:String>
<x:String>System.Activities.Validation</x:String>
<x:String>System.Activities.XamlIntegration</x:String>
<x:String>Microsoft.VisualBasic</x:String>
<x:String>Microsoft.VisualBasic.Activities</x:String>
<x:String>System</x:String>
<x:String>System.Collections</x:String>
<x:String>System.Collections.Generic</x:String>
<x:String>System.Data</x:String>
<x:String>System.Diagnostics</x:String>
<x:String>System.Drawing</x:String>
<x:String>System.IO</x:String>
<x:String>System.Linq</x:String>
<x:String>System.Net.Mail</x:String>
<x:String>System.Xml</x:String>
<x:String>System.Xml.Linq</x:String>
<x:String>UiPath.Core</x:String>
<x:String>UiPath.Core.Activities</x:String>
<x:String>System.Windows.Markup</x:String>
</sco:Collection>
</TextExpression.NamespacesForImplementation>
<TextExpression.ReferencesForImplementation>
<sco:Collection x:TypeArguments="AssemblyReference">
<AssemblyReference>System.Activities</AssemblyReference>
<AssemblyReference>Microsoft.VisualBasic</AssemblyReference>
<AssemblyReference>mscorlib</AssemblyReference>
<AssemblyReference>System.Data</AssemblyReference>
<AssemblyReference>System</AssemblyReference>
<AssemblyReference>System.Drawing</AssemblyReference>
<AssemblyReference>System.Core</AssemblyReference>
<AssemblyReference>System.Xml</AssemblyReference>
<AssemblyReference>System.Xml.Linq</AssemblyReference>
<AssemblyReference>UiPath.Core</AssemblyReference>
<AssemblyReference>UiPath.Core.Activities</AssemblyReference>
<AssemblyReference>PresentationFramework</AssemblyReference>
<AssemblyReference>WindowsBase</AssemblyReference>
<AssemblyReference>PresentationCore</AssemblyReference>
<AssemblyReference>System.Xaml</AssemblyReference>
<AssemblyReference>System.ComponentModel.Composition</AssemblyReference>
<AssemblyReference>System.ServiceModel</AssemblyReference>
</sco:Collection>
</TextExpression.ReferencesForImplementation>
<ui:OpenBrowser UiBrowser="{x:Null}" BrowserType="Chrome" DisplayName="Open browser" Hidden="False" sap2010:WorkflowViewState.IdRef="OpenBrowser_3" NewSession="True" Private="False" Url="https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_onbeforeunload">
<ui:OpenBrowser.Body>
<ActivityAction x:TypeArguments="x:Object">
<ActivityAction.Argument>
<DelegateInArgument x:TypeArguments="x:Object" Name="ContextTarget" />
</ActivityAction.Argument>
<Sequence DisplayName="Do" sap2010:WorkflowViewState.IdRef="Sequence_25">
<ui:Click DelayBefore="{x:Null}" DelayMS="{x:Null}" ClickType="CLICK_SINGLE" DisplayName="Click 'A https://www.w3school...'" sap2010:WorkflowViewState.IdRef="Click_6" KeyModifiers="None" MouseButton="BTN_LEFT" SendWindowMessages="False" SimulateClick="False">
<ui:Click.CursorPosition>
<ui:CursorPosition Position="Center">
<ui:CursorPosition.OffsetX>
<InArgument x:TypeArguments="x:Int32" />
</ui:CursorPosition.OffsetX>
<ui:CursorPosition.OffsetY>
<InArgument x:TypeArguments="x:Int32" />
</ui:CursorPosition.OffsetY>
</ui:CursorPosition>
</ui:Click.CursorPosition>
<ui:Click.Target>
<ui:Target ClippingRegion="{x:Null}" Element="{x:Null}" TimeoutMS="{x:Null}" InformativeScreenshot="ad281f65b6ab6cc6ce588fb1cf53160a" Selector="<webctrl aaname='Click here to go to w3schools.com' tag='A' />" WaitForReady="INTERACTIVE" />
</ui:Click.Target>
</ui:Click>
<ui:Click DelayBefore="{x:Null}" DelayMS="{x:Null}" ClickType="CLICK_SINGLE" DisplayName="Click 'push button Leave'" sap2010:WorkflowViewState.IdRef="Click_5" KeyModifiers="None" MouseButton="BTN_LEFT" SendWindowMessages="False" SimulateClick="False">
<ui:Click.CursorPosition>
<ui:CursorPosition Position="Center">
<ui:CursorPosition.OffsetX>
<InArgument x:TypeArguments="x:Int32" />
</ui:CursorPosition.OffsetX>
<ui:CursorPosition.OffsetY>
<InArgument x:TypeArguments="x:Int32" />
</ui:CursorPosition.OffsetY>
</ui:CursorPosition>
</ui:Click.CursorPosition>
<ui:Click.Target>
<ui:Target ClippingRegion="{x:Null}" Element="{x:Null}" TimeoutMS="{x:Null}" InformativeScreenshot="a52efda054f51d9ac88fd53b22f4663a" Selector="<ctrl name='Leave site?' role='dialog' /><ctrl name='Leave' role='push button' />" WaitForReady="INTERACTIVE" />
</ui:Click.Target>
</ui:Click>
</Sequence>
</ActivityAction>
</ui:OpenBrowser.Body>
<sads:DebugSymbol.Symbol>dyhFOlxVaVBhdGhXb3Jrc3BhY2VcV2hhdHNhcHBNc2dcTWFpbi54YW1sBzoDYxQCAQE6vQE6iQICAQdACV8UAgECQQtPFgIBBVALXhYCAQNNngFN5AECAQZcngFc/QECAQQ=</sads:DebugSymbol.Symbol>
</ui:OpenBrowser>
<sap2010:WorkflowViewState.ViewStateManager>
<sap2010:ViewStateManager>
<sap2010:ViewStateData Id="Click_6" sap:VirtualizedContainerService.HintSize="314,106" />
<sap2010:ViewStateData Id="Click_5" sap:VirtualizedContainerService.HintSize="314,106" />
<sap2010:ViewStateData Id="Sequence_25" sap:VirtualizedContainerService.HintSize="336,376">
<sap:WorkflowViewStateService.ViewState>
<scg:Dictionary x:TypeArguments="x:String, x:Object">
<x:Boolean x:Key="IsExpanded">True</x:Boolean>
</scg:Dictionary>
</sap:WorkflowViewStateService.ViewState>
</sap2010:ViewStateData>
<sap2010:ViewStateData Id="OpenBrowser_3" sap:VirtualizedContainerService.HintSize="414,475" />
<sap2010:ViewStateData Id="Main_1" sap:VirtualizedContainerService.HintSize="454,635" />
</sap2010:ViewStateManager>
</sap2010:WorkflowViewState.ViewStateManager>
</Activity>
Which not working with script alerts.
Please find the solved workflow here. It's a tricky way to solve your problem.
I created a dash output sample_video.mpd file using ffmpeg, but when I tried to play it using dash js the video was just loading and nothing else.
Below is the generated mpd file
<?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="PT1M2.3S"
minBufferTime="PT20.0S">
<ProgramInformation>
</ProgramInformation>
<Period id="0" start="PT0.0S">
<AdaptationSet id="0" contentType="video" segmentAlignment="true" bitstreamSwitching="true" lang="und">
<Representation id="0" mimeType="video/mp4" codecs="avc1.640015" bandwidth="255520" width="426" height="240" frameRate="24/1">
<SegmentTemplate timescale="12288" initialization="init-stream$RepresentationID$.m4s" media="chunk-stream$RepresentationID$-$Number%05d$.m4s" startNumber="3">
<SegmentTimeline>
<S t="198656" d="69120" />
<S d="75264" />
<S d="174592" />
<S d="122880" />
<S d="125440" />
</SegmentTimeline>
</SegmentTemplate>
</Representation>
<Representation id="2" mimeType="video/mp4" codecs="avc1.64001e" bandwidth="726596" width="854" height="480" frameRate="24/1">
<SegmentTemplate timescale="12288" initialization="init-stream$RepresentationID$.m4s" media="chunk-stream$RepresentationID$-$Number%05d$.m4s" startNumber="3">
<SegmentTimeline>
<S t="198656" d="69120" />
<S d="75264" />
<S d="174592" />
<S d="122880" />
<S d="125440" />
</SegmentTimeline>
</SegmentTemplate>
</Representation>
<Representation id="4" mimeType="video/mp4" codecs="avc1.64001f" bandwidth="1433314" width="1280" height="720" frameRate="24/1">
<SegmentTemplate timescale="12288" initialization="init-stream$RepresentationID$.m4s" media="chunk-stream$RepresentationID$-$Number%05d$.m4s" startNumber="3">
<SegmentTimeline>
<S t="198656" d="69120" />
<S d="75264" />
<S d="174592" />
<S d="122880" />
<S d="125440" />
</SegmentTimeline>
</SegmentTemplate>
</Representation>
</AdaptationSet>
<AdaptationSet id="1" contentType="audio" segmentAlignment="true" bitstreamSwitching="true" lang="und">
<Representation id="1" mimeType="audio/mp4" codecs="mp4a.40.2" bandwidth="341000" audioSamplingRate="48000">
<AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="6" />
<SegmentTemplate timescale="48000" initialization="init-stream$RepresentationID$.m4s" media="chunk-stream$RepresentationID$-$Number%05d$.m4s" startNumber="3">
<SegmentTimeline>
<S t="772096" d="270336" />
<S d="293888" />
<S d="681984" />
<S d="480256" />
<S d="492544" />
</SegmentTimeline>
</SegmentTemplate>
</Representation>
<Representation id="3" mimeType="audio/mp4" codecs="mp4a.40.2" bandwidth="341000" audioSamplingRate="48000">
<AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="6" />
<SegmentTemplate timescale="48000" initialization="init-stream$RepresentationID$.m4s" media="chunk-stream$RepresentationID$-$Number%05d$.m4s" startNumber="3">
<SegmentTimeline>
<S t="772096" d="270336" />
<S d="293888" />
<S d="681984" />
<S d="480256" />
<S d="492544" />
</SegmentTimeline>
</SegmentTemplate>
</Representation>
<Representation id="5" mimeType="audio/mp4" codecs="mp4a.40.2" bandwidth="341000" audioSamplingRate="48000">
<AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="6" />
<SegmentTemplate timescale="48000" initialization="init-stream$RepresentationID$.m4s" media="chunk-stream$RepresentationID$-$Number%05d$.m4s" startNumber="3">
<SegmentTimeline>
<S t="772096" d="270336" />
<S d="293888" />
<S d="681984" />
<S d="480256" />
<S d="492544" />
</SegmentTimeline>
</SegmentTemplate>
</Representation>
</AdaptationSet>
</Period>
The following is the ffmpeg command that i used to generate multi bitrate video
ffmpeg -y -i sample_video.mp4 ^
-c:v libx264 -x264opts "keyint=24:min-keyint=24:no-scenecut" -r 24 ^
-c:a aac -b:a 128k ^
-bf 1 -b_strategy 0 -sc_threshold 0 -pix_fmt yuv420p ^
-map 0:v:0 -map 0:a:0 -map 0:v:0 -map 0:a:0 -map 0:v:0 -map 0:a:0 ^
-b:v:0 250k -filter:v:0 "scale=-2:240" -profile:v:0 baseline ^
-b:v:1 750k -filter:v:1 "scale=-2:480" -profile:v:1 main ^
-b:v:2 1500k -filter:v:2 "scale=-2:720" -profile:v:2 high ^
sample_dash.mp4
and to generate the mpd file
ffmpeg -y -re -i sample_dash.mp4 ^
-map 0 ^
-use_timeline 1 -use_template 1 -window_size 5 -adaptation_sets
"id=0,streams=v id=1,streams=a" ^
-f dash sample_video.mpd
Also I saw in the chrome network tab that only init-stream4.m4s and init-stream5.m4s was called.
Are you ready to use ffmpeg+mp4box dash packager? I have found mp4box produce better segments+manifest.
ffmpeg -i tos.mp4 -threads 4 -preset fast -c:v libx264 -profile:v main -level 4.0 -s:v 640x360 -b:v 512k -pix_fmt yuv420p -refs 3 -bf 3 -g 75 -keyint_min 25 -b_strategy 1 -flags +cgop -sc_threshold 0 -movflags negative_cts_offsets+faststart -an -y temp-v1.mp4
ffmpeg -i tos.mp4 -threads 4 -preset fast -c:v libx264 -profile:v main -level 4.0 -s:v 1280x720 -b:v 1500k -pix_fmt yuv420p -refs 3 -bf 3 -g 75 -keyint_min 25 -b_strategy 1 -flags +cgop -sc_threshold 0 -movflags negative_cts_offsets+faststart -an -y temp-v2.mp4
ffmpeg -i tos.mp4 -threads 4 -preset fast -c:v libx264 -profile:v main -level 4.0 -s:v 1920x1080 -b:v 2100k -pix_fmt yuv420p -refs 3 -bf 3 -g 75 -keyint_min 25 -b_strategy 1 -flags +cgop -sc_threshold 0 -movflags negative_cts_offsets+faststart -an -y temp-v3.mp4
ffmpeg -i tos.mp4 -threads 4 -c:a aac -strict experimental -b:a 128k -maxrate:a 128k -bufsize:a 128k -af aresample=44100 -ar 44100 -ac 2 -vn -y temp-a1.mp4
MP4Box -dash 264600 -frag 264600 -dash-scale 44100 -bound -mem-frags -rap -profile dashavc264:live -min-buffer 12000 -bs-switching no -sample-groups-traf -single-traf -subsegs-per-sidx -1 -segment-name $RepresentationID$/$Number$$Init=i$ -out manifest.mpd temp-v1.mp4#trackID=1:id=v1:period=p0 temp-v2.mp4#trackID=1:id=v2:period=p0 temp-v3.mp4#trackID=1:id=v3:period=p0 temp-a1.mp4#trackID=1:id=a1:period=p0
I always use audiorate(44100,48000) in a dash-scale and scale*seconds=value of dash/frag formula to give a segment file duration.
Help. I wont show bitrate.
player.getBitrateInfoListFor("video");
Shows only one bitrate - 454948
manifest.mpd generated by GPAC
<Period duration="PT0H21M48.338S">
<AdaptationSet segmentAlignment="true" group="1" maxWidth="270" maxHeight="480" maxFrameRate="2070000/93437" par="270:480" lang="und">
<Representation id="1" mimeType="video/mp4" codecs="avc3.640015" width="270" height="480" frameRate="2070000/93437" sar="1:1" startWithSAP="1" bandwidth="454948">
<SegmentTemplate media="480_bbb/segment__track1_$Number$.m4s" timescale="2070000" startNumber="1" duration="8280000" initialization="480_bbb/segment__track1_init.mp4"/>
</Representation>
</AdaptationSet>
<AdaptationSet segmentAlignment="true" group="1" maxWidth="202" maxHeight="360" maxFrameRate="2070000/93437" par="202:360" lang="und">
<Representation id="2" mimeType="video/mp4" codecs="avc3.64000D" width="202" height="360" frameRate="2070000/93437" sar="1:1" startWithSAP="1" bandwidth="281508">
<SegmentTemplate media="360_bbb/segment__track1_$Number$.m4s" timescale="2070000" startNumber="1" duration="8280000" initialization="360_bbb/segment__track1_init.mp4"/>
</Representation>
</AdaptationSet>
<AdaptationSet segmentAlignment="true" group="1" maxWidth="134" maxHeight="240" maxFrameRate="2070000/93437" par="134:240" lang="und">
<Representation id="3" mimeType="video/mp4" codecs="avc3.64000B" width="134" height="240" frameRate="2070000/93437" sar="1:1" startWithSAP="1" bandwidth="182832">
<SegmentTemplate media="240_bbb/segment__track1_$Number$.m4s" timescale="2070000" startNumber="1" duration="8280000" initialization="240_bbb/segment__track1_init.mp4"/>
</Representation>
</AdaptationSet>
<AdaptationSet segmentAlignment="true" group="1" maxWidth="80" maxHeight="144" maxFrameRate="2070000/93437" par="80:144" lang="und">
<Representation id="4" mimeType="video/mp4" codecs="avc3.640009" width="80" height="144" frameRate="2070000/93437" sar="1:1" startWithSAP="1" bandwidth="99667">
<SegmentTemplate media="144_bbb/segment__track1_$Number$.m4s" timescale="2070000" startNumber="1" duration="8280000" initialization="144_bbb/segment__track1_init.mp4"/>
</Representation>
</AdaptationSet>
<AdaptationSet segmentAlignment="true" lang="und">
<Representation id="5" mimeType="audio/mp4" codecs="mp4a.40.2" startWithSAP="1" bandwidth="66056">
<AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="1"/>
<SegmentTemplate media="audio_bbb/segment__track2_$Number$.m4s" timescale="48000" startNumber="1" duration="192000" initialization="audio_bbb/segment__track2_init.mp4"/>
</Representation>
</AdaptationSet>
</Period>
</MPD>
player.getBitrateInfoListFor("video");
Shows only one bitrate - 454948
Assuming the video Representations are interchangeable versions of the same content, they should all be within a single AdaptationSet so the client knows it may switch between them dynamically.
As you currently have it, the client will select the most appropriate AdaptationSet at start up (probably the first since there are no other indicators) and correctly determines there is only one bitrate available.
Your MPD file shows that all videos are in separate adaptation set.
Problem is in the command you use to segment videos in MP4Box. You have to set "profile" parameter while segmenting videos using MP4Box.
-profile NAME specifies the target DASH profile: onDemand, live, main, simple, full, and two profiles from the DASH-IF: dashavc264:live, dashavc264:onDemand. This will set default option values to ensure conformance to the desired profile.
MP4Box command to segment videos with onDemand profile:
MP4Box -dash 4000 -frag 4000 -rap -profile onDemand -segment-name %s/segment_ -url-template -out manifest.mpd video144.mp4#video video240.mp4#video video360.mp4#video video480.mp4#video audio.mp4#audio
Source: GPAC's DASH support in MP4Box