Recherche avancée

Médias (39)

Mot : - Tags -/audio

Autres articles (95)

  • Websites made ​​with MediaSPIP

    2 mai 2011, par

    This page lists some websites based on MediaSPIP.

  • Creating farms of unique websites

    13 avril 2011, par

    MediaSPIP platforms can be installed as a farm, with a single "core" hosted on a dedicated server and used by multiple websites.
    This allows (among other things) : implementation costs to be shared between several different projects / individuals rapid deployment of multiple unique sites creation of groups of like-minded sites, making it possible to browse media in a more controlled and selective environment than the major "open" (...)

  • Publier sur MédiaSpip

    13 juin 2013

    Puis-je poster des contenus à partir d’une tablette Ipad ?
    Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir

Sur d’autres sites (10931)

  • Do I need multiple video files in different resolutions to use MPEG DASH ?

    2 février 2023, par Gentil Alyson

    I'm trying to use Django REST Framework to serve .mpd files. When the user uploads a video, the server creates the MPD and the chunk files. However, I can't seem to able to make it work. I've tried using python-ffmpeg-video-streaming, but the client which is using dash.js to play the video will get only one bitrate (480p). I've also tried running this command 'ffmpeg -i {self.file.path} -map 0 -map 0 -c:a aac -c:v libx264 -b:v:0 800k -b:v:1 300k -var_stream_map "v:0,name:800k v:1,name:300k" -f dash -dash_segment_type mp4 -single_file 1 {file_dir}/dash.mpd' using os.system from Python, but then the player gets stuck at buffering.

    


    File structure generated by the command

    


    <mpd xmlns="urn:mpeg:dash:schema:mpd:2011" profiles="urn:mpeg:dash:profile:isoff-live:2011" type="static" mediapresentationduration="PT2M30.5S" maxsegmentduration="PT5.0S" minbuffertime="PT16.6S">&#xA;    <programinformation>&#xA;    </programinformation>&#xA;    <servicedescription>&#xA;    </servicedescription>&#xA;    <period start="PT0.0S">&#xA;        <adaptationset contenttype="video" startwithsap="1" segmentalignment="true" bitstreamswitching="true" framerate="30000/1001" maxwidth="1280" maxheight="720" par="16:9" lang="und">&#xA;            <representation mimetype="video/mp4" codecs="avc1.64001f" bandwidth="800000" width="1280" height="720" sar="1:1">&#xA;                <baseurl>dash-stream0.mp4</baseurl>&#xA;                <segmentlist timescale="1000000" duration="5000000" startnumber="1">&#xA;                    <initialization range="0-854"></initialization>&#xA;                    <segmenturl mediarange="855-190364" indexrange="855-906"></segmenturl>&#xA;                    <segmenturl mediarange="190365-448322" indexrange="190365-190416"></segmenturl>&#xA;                    <segmenturl mediarange="448323-628609" indexrange="448323-448374"></segmenturl>&#xA;                    <segmenturl mediarange="628610-741660" indexrange="628610-628661"></segmenturl>&#xA;                    <segmenturl mediarange="741661-1149015" indexrange="741661-741712"></segmenturl>&#xA;                    <segmenturl mediarange="1149016-1761260" indexrange="1149016-1149067"></segmenturl>&#xA;                    <segmenturl mediarange="1761261-1829636" indexrange="1761261-1761312"></segmenturl>&#xA;                    <segmenturl mediarange="1829637-2343368" indexrange="1829637-1829688"></segmenturl>&#xA;                    <segmenturl mediarange="2343369-2759155" indexrange="2343369-2343420"></segmenturl>&#xA;                    <segmenturl mediarange="2759156-3120911" indexrange="2759156-2759207"></segmenturl>&#xA;                    <segmenturl mediarange="3120912-3255416" indexrange="3120912-3120963"></segmenturl>&#xA;                    <segmenturl mediarange="3255417-3617692" indexrange="3255417-3255468"></segmenturl>&#xA;                    <segmenturl mediarange="3617693-3910773" indexrange="3617693-3617744"></segmenturl>&#xA;                    <segmenturl mediarange="3910774-4097693" indexrange="3910774-3910825"></segmenturl>&#xA;                    <segmenturl mediarange="4097694-4266685" indexrange="4097694-4097745"></segmenturl>&#xA;                    <segmenturl mediarange="4266686-4609479" indexrange="4266686-4266737"></segmenturl>&#xA;                    <segmenturl mediarange="4609480-4719699" indexrange="4609480-4609531"></segmenturl>&#xA;                    <segmenturl mediarange="4719700-4833193" indexrange="4719700-4719751"></segmenturl>&#xA;                    <segmenturl mediarange="4833194-4905000" indexrange="4833194-4833245"></segmenturl>&#xA;                    <segmenturl mediarange="4905001-5046627" indexrange="4905001-4905052"></segmenturl>&#xA;                </segmentlist>&#xA;            </representation>&#xA;        </adaptationset>&#xA;        <adaptationset contenttype="audio" startwithsap="1" segmentalignment="true" bitstreamswitching="true" lang="eng">&#xA;            <representation mimetype="audio/mp4" codecs="mp4a.40.2" bandwidth="128000" audiosamplingrate="44100">&#xA;                <audiochannelconfiguration schemeiduri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2"></audiochannelconfiguration>&#xA;                <baseurl>dash-stream1.mp4</baseurl>&#xA;                <segmentlist timescale="1000000" duration="5000000" startnumber="1">&#xA;                    <initialization range="0-764"></initialization>&#xA;                    <segmenturl mediarange="765-82409" indexrange="765-816"></segmenturl>&#xA;                    <segmenturl mediarange="82410-163592" indexrange="82410-82461"></segmenturl>&#xA;                    <segmenturl mediarange="163593-244493" indexrange="163593-163644"></segmenturl>&#xA;                    <segmenturl mediarange="244494-325181" indexrange="244494-244545"></segmenturl>&#xA;                    <segmenturl mediarange="325182-406218" indexrange="325182-325233"></segmenturl>&#xA;                    <segmenturl mediarange="406219-487174" indexrange="406219-406270"></segmenturl>&#xA;                    <segmenturl mediarange="487175-568100" indexrange="487175-487226"></segmenturl>&#xA;                    <segmenturl mediarange="568101-649853" indexrange="568101-568152"></segmenturl>&#xA;                    <segmenturl mediarange="649854-732519" indexrange="649854-649905"></segmenturl>&#xA;                    <segmenturl mediarange="732520-813751" indexrange="732520-732571"></segmenturl>&#xA;                    <segmenturl mediarange="813752-895429" indexrange="813752-813803"></segmenturl>&#xA;                    <segmenturl mediarange="895430-976537" indexrange="895430-895481"></segmenturl>&#xA;                    <segmenturl mediarange="976538-1058579" indexrange="976538-976589"></segmenturl>&#xA;                    <segmenturl mediarange="1058580-1139556" indexrange="1058580-1058631"></segmenturl>&#xA;                    <segmenturl mediarange="1139557-1220802" indexrange="1139557-1139608"></segmenturl>&#xA;                    <segmenturl mediarange="1220803-1301723" indexrange="1220803-1220854"></segmenturl>&#xA;                    <segmenturl mediarange="1301724-1382546" indexrange="1301724-1301775"></segmenturl>&#xA;                    <segmenturl mediarange="1382547-1464086" indexrange="1382547-1382598"></segmenturl>&#xA;                    <segmenturl mediarange="1464087-1546573" indexrange="1464087-1464138"></segmenturl>&#xA;                    <segmenturl mediarange="1546574-1627881" indexrange="1546574-1546625"></segmenturl>&#xA;                    <segmenturl mediarange="1627882-1710185" indexrange="1627882-1627933"></segmenturl>&#xA;                    <segmenturl mediarange="1710186-1791593" indexrange="1710186-1710237"></segmenturl>&#xA;                    <segmenturl mediarange="1791594-1872889" indexrange="1791594-1791645"></segmenturl>&#xA;                    <segmenturl mediarange="1872890-1954238" indexrange="1872890-1872941"></segmenturl>&#xA;                    <segmenturl mediarange="1954239-2036069" indexrange="1954239-1954290"></segmenturl>&#xA;                    <segmenturl mediarange="2036070-2117365" indexrange="2036070-2036121"></segmenturl>&#xA;                    <segmenturl mediarange="2117366-2198435" indexrange="2117366-2117417"></segmenturl>&#xA;                    <segmenturl mediarange="2198436-2279764" indexrange="2198436-2198487"></segmenturl>&#xA;                    <segmenturl mediarange="2279765-2362061" indexrange="2279765-2279816"></segmenturl>&#xA;                    <segmenturl mediarange="2362062-2443751" indexrange="2362062-2362113"></segmenturl>&#xA;                    <segmenturl mediarange="2443752-2446358" indexrange="2443752-2443803"></segmenturl>&#xA;                </segmentlist>&#xA;            </representation>&#xA;        </adaptationset>&#xA;        <adaptationset contenttype="video" startwithsap="1" segmentalignment="true" bitstreamswitching="true" framerate="30000/1001" maxwidth="1280" maxheight="720" par="16:9" lang="und">&#xA;            <representation mimetype="video/mp4" codecs="avc1.64001f" bandwidth="300000" width="1280" height="720" sar="1:1">&#xA;                <baseurl>dash-stream2.mp4</baseurl>&#xA;                <segmentlist timescale="1000000" duration="5000000" startnumber="1">&#xA;                    <initialization range="0-854"></initialization>&#xA;                    <segmenturl mediarange="855-117134" indexrange="855-906"></segmenturl>&#xA;                    <segmenturl mediarange="117135-288087" indexrange="117135-117186"></segmenturl>&#xA;                    <segmenturl mediarange="288088-435178" indexrange="288088-288139"></segmenturl>&#xA;                    <segmenturl mediarange="435179-520309" indexrange="435179-435230"></segmenturl>&#xA;                    <segmenturl mediarange="520310-903223" indexrange="520310-520361"></segmenturl>&#xA;                    <segmenturl mediarange="903224-1458808" indexrange="903224-903275"></segmenturl>&#xA;                    <segmenturl mediarange="1458809-1524956" indexrange="1458809-1458860"></segmenturl>&#xA;                    <segmenturl mediarange="1524957-2026894" indexrange="1524957-1525008"></segmenturl>&#xA;                    <segmenturl mediarange="2026895-2406246" indexrange="2026895-2026946"></segmenturl>&#xA;                    <segmenturl mediarange="2406247-2726266" indexrange="2406247-2406298"></segmenturl>&#xA;                    <segmenturl mediarange="2726267-2852806" indexrange="2726267-2726318"></segmenturl>&#xA;                    <segmenturl mediarange="2852807-3183174" indexrange="2852807-2852858"></segmenturl>&#xA;                    <segmenturl mediarange="3183175-3467272" indexrange="3183175-3183226"></segmenturl>&#xA;                    <segmenturl mediarange="3467273-3653219" indexrange="3467273-3467324"></segmenturl>&#xA;                    <segmenturl mediarange="3653220-3821184" indexrange="3653220-3653271"></segmenturl>&#xA;                    <segmenturl mediarange="3821185-4162978" indexrange="3821185-3821236"></segmenturl>&#xA;                    <segmenturl mediarange="4162979-4273050" indexrange="4162979-4163030"></segmenturl>&#xA;                    <segmenturl mediarange="4273051-4386223" indexrange="4273051-4273102"></segmenturl>&#xA;                    <segmenturl mediarange="4386224-4458425" indexrange="4386224-4386275"></segmenturl>&#xA;                    <segmenturl mediarange="4458426-4597502" indexrange="4458426-4458477"></segmenturl>&#xA;                </segmentlist>&#xA;            </representation>&#xA;        </adaptationset>&#xA;        <adaptationset contenttype="audio" startwithsap="1" segmentalignment="true" bitstreamswitching="true" lang="eng">&#xA;            <representation mimetype="audio/mp4" codecs="mp4a.40.2" bandwidth="128000" audiosamplingrate="44100">&#xA;                <audiochannelconfiguration schemeiduri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2"></audiochannelconfiguration>&#xA;                <baseurl>dash-stream3.mp4</baseurl>&#xA;                <segmentlist timescale="1000000" duration="5000000" startnumber="1">&#xA;                    <initialization range="0-764"></initialization>&#xA;                    <segmenturl mediarange="765-82409" indexrange="765-816"></segmenturl>&#xA;                    <segmenturl mediarange="82410-163592" indexrange="82410-82461"></segmenturl>&#xA;                    <segmenturl mediarange="163593-244493" indexrange="163593-163644"></segmenturl>&#xA;                    <segmenturl mediarange="244494-325181" indexrange="244494-244545"></segmenturl>&#xA;                    <segmenturl mediarange="325182-406218" indexrange="325182-325233"></segmenturl>&#xA;                    <segmenturl mediarange="406219-487174" indexrange="406219-406270"></segmenturl>&#xA;                    <segmenturl mediarange="487175-568100" indexrange="487175-487226"></segmenturl>&#xA;                    <segmenturl mediarange="568101-649853" indexrange="568101-568152"></segmenturl>&#xA;                    <segmenturl mediarange="649854-732519" indexrange="649854-649905"></segmenturl>&#xA;                    <segmenturl mediarange="732520-813751" indexrange="732520-732571"></segmenturl>&#xA;                    <segmenturl mediarange="813752-895429" indexrange="813752-813803"></segmenturl>&#xA;                    <segmenturl mediarange="895430-976537" indexrange="895430-895481"></segmenturl>&#xA;                    <segmenturl mediarange="976538-1058579" indexrange="976538-976589"></segmenturl>&#xA;                    <segmenturl mediarange="1058580-1139556" indexrange="1058580-1058631"></segmenturl>&#xA;                    <segmenturl mediarange="1139557-1220802" indexrange="1139557-1139608"></segmenturl>&#xA;                    <segmenturl mediarange="1220803-1301723" indexrange="1220803-1220854"></segmenturl>&#xA;                    <segmenturl mediarange="1301724-1382546" indexrange="1301724-1301775"></segmenturl>&#xA;                    <segmenturl mediarange="1382547-1464086" indexrange="1382547-1382598"></segmenturl>&#xA;                    <segmenturl mediarange="1464087-1546573" indexrange="1464087-1464138"></segmenturl>&#xA;                    <segmenturl mediarange="1546574-1627881" indexrange="1546574-1546625"></segmenturl>&#xA;                    <segmenturl mediarange="1627882-1710185" indexrange="1627882-1627933"></segmenturl>&#xA;                    <segmenturl mediarange="1710186-1791593" indexrange="1710186-1710237"></segmenturl>&#xA;                    <segmenturl mediarange="1791594-1872889" indexrange="1791594-1791645"></segmenturl>&#xA;                    <segmenturl mediarange="1872890-1954238" indexrange="1872890-1872941"></segmenturl>&#xA;                    <segmenturl mediarange="1954239-2036069" indexrange="1954239-1954290"></segmenturl>&#xA;                    <segmenturl mediarange="2036070-2117365" indexrange="2036070-2036121"></segmenturl>&#xA;                    <segmenturl mediarange="2117366-2198435" indexrange="2117366-2117417"></segmenturl>&#xA;                    <segmenturl mediarange="2198436-2279764" indexrange="2198436-2198487"></segmenturl>&#xA;                    <segmenturl mediarange="2279765-2362061" indexrange="2279765-2279816"></segmenturl>&#xA;                    <segmenturl mediarange="2362062-2443751" indexrange="2362062-2362113"></segmenturl>&#xA;                    <segmenturl mediarange="2443752-2446358" indexrange="2443752-2443803"></segmenturl>&#xA;                </segmentlist>&#xA;            </representation>&#xA;        </adaptationset>&#xA;    </period>&#xA;</mpd>&#xA;

    &#xA;

    File structure created by the lib

    &#xA;

    <mpd xmlns="urn:mpeg:dash:schema:mpd:2011" profiles="urn:mpeg:dash:profile:isoff-live:2011" type="static" mediapresentationduration="PT5M24.4S" maxsegmentduration="PT5.0S" minbuffertime="PT10.8S">&#xA;    <programinformation>&#xA;    </programinformation>&#xA;    <servicedescription>&#xA;    </servicedescription>&#xA;    <period start="PT0.0S">&#xA;        <adaptationset contenttype="video" startwithsap="1" segmentalignment="true" bitstreamswitching="true" framerate="30/1" maxwidth="854" maxheight="480" par="16:9" lang="und">&#xA;            <representation mimetype="video/mp4" codecs="avc1.64001f" bandwidth="750000" width="854" height="480" sar="1280:1281">&#xA;                <segmenttemplate timescale="15360" initialization="dash_init_$RepresentationID$.m4s" media="dash_chunk_$RepresentationID$_$Number%05d$.m4s" startnumber="1">&#xA;                    <segmenttimeline>&#xA;                        <s t="0" d="95744"></s>&#xA;                        <s d="93696"></s>&#xA;                        <s d="117760"></s>&#xA;                        <s d="126976"></s>&#xA;                        <s d="152064"></s>&#xA;                        <s d="109056"></s>&#xA;                        <s d="128000" r="1"></s>&#xA;                        <s d="110080"></s>&#xA;                        <s d="105984" r="1"></s>&#xA;                        <s d="96256"></s>&#xA;                        <s d="114688"></s>&#xA;                        <s d="122880"></s>&#xA;                        <s d="106496"></s>&#xA;                        <s d="113152"></s>&#xA;                        <s d="126464"></s>&#xA;                        <s d="91136"></s>&#xA;                        <s d="77824"></s>&#xA;                        <s d="115712"></s>&#xA;                        <s d="93184"></s>&#xA;                        <s d="154624"></s>&#xA;                        <s d="129024"></s>&#xA;                        <s d="141824"></s>&#xA;                        <s d="116736"></s>&#xA;                        <s d="92672"></s>&#xA;                        <s d="106496"></s>&#xA;                        <s d="153088"></s>&#xA;                        <s d="121344"></s>&#xA;                        <s d="130560"></s>&#xA;                        <s d="87040"></s>&#xA;                        <s d="81920"></s>&#xA;                        <s d="128000"></s>&#xA;                        <s d="99328"></s>&#xA;                        <s d="128000"></s>&#xA;                        <s d="159232"></s>&#xA;                        <s d="158208"></s>&#xA;                        <s d="78848"></s>&#xA;                        <s d="112640"></s>&#xA;                        <s d="95232"></s>&#xA;                        <s d="168448"></s>&#xA;                        <s d="167424"></s>&#xA;                        <s d="40960"></s>&#xA;                    </segmenttimeline>&#xA;                </segmenttemplate>&#xA;            </representation>&#xA;        </adaptationset>&#xA;        <adaptationset contenttype="audio" startwithsap="1" segmentalignment="true" bitstreamswitching="true" lang="eng">&#xA;            <representation mimetype="audio/mp4" codecs="mp4a.40.2" bandwidth="192000" audiosamplingrate="44100">&#xA;                <audiochannelconfiguration schemeiduri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2"></audiochannelconfiguration>&#xA;                <segmenttemplate timescale="44100" initialization="dash_init_$RepresentationID$.m4s" media="dash_chunk_$RepresentationID$_$Number%05d$.m4s" startnumber="1">&#xA;                    <segmenttimeline>&#xA;                        <s t="0" d="220160"></s>&#xA;                        <s d="221184" r="62"></s>&#xA;                        <s d="151552"></s>&#xA;                    </segmenttimeline>&#xA;                </segmenttemplate>&#xA;            </representation>&#xA;        </adaptationset>&#xA;        <adaptationset contenttype="video" startwithsap="1" segmentalignment="true" bitstreamswitching="true" framerate="30/1" maxwidth="1280" maxheight="720" par="16:9" lang="und">&#xA;            <representation mimetype="video/mp4" codecs="avc1.64001f" bandwidth="2048000" width="1280" height="720" sar="1:1">&#xA;                <segmenttemplate timescale="15360" initialization="dash_init_$RepresentationID$.m4s" media="dash_chunk_$RepresentationID$_$Number%05d$.m4s" startnumber="1">&#xA;                    <segmenttimeline>&#xA;                        <s t="0" d="96256"></s>&#xA;                        <s d="93184"></s>&#xA;                        <s d="117760"></s>&#xA;                        <s d="78336"></s>&#xA;                        <s d="106496"></s>&#xA;                        <s d="123392"></s>&#xA;                        <s d="80384"></s>&#xA;                        <s d="128000" r="1"></s>&#xA;                        <s d="109568"></s>&#xA;                        <s d="164864"></s>&#xA;                        <s d="128000"></s>&#xA;                        <s d="181760"></s>&#xA;                        <s d="91136"></s>&#xA;                        <s d="84992"></s>&#xA;                        <s d="127488"></s>&#xA;                        <s d="103936"></s>&#xA;                        <s d="101376"></s>&#xA;                        <s d="77312"></s>&#xA;                        <s d="115712"></s>&#xA;                        <s d="93184"></s>&#xA;                        <s d="154624"></s>&#xA;                        <s d="129024"></s>&#xA;                        <s d="132096"></s>&#xA;                        <s d="126464"></s>&#xA;                        <s d="92672"></s>&#xA;                        <s d="107008"></s>&#xA;                        <s d="152064"></s>&#xA;                        <s d="122368"></s>&#xA;                        <s d="130560"></s>&#xA;                        <s d="85504"></s>&#xA;                        <s d="82944"></s>&#xA;                        <s d="128000"></s>&#xA;                        <s d="99328"></s>&#xA;                        <s d="128000"></s>&#xA;                        <s d="161792"></s>&#xA;                        <s d="155648"></s>&#xA;                        <s d="78848"></s>&#xA;                        <s d="113152"></s>&#xA;                        <s d="119808"></s>&#xA;                        <s d="144896"></s>&#xA;                        <s d="116224"></s>&#xA;                        <s d="83456"></s>&#xA;                        <s d="7168"></s>&#xA;                    </segmenttimeline>&#xA;                </segmenttemplate>&#xA;            </representation>&#xA;        </adaptationset>&#xA;        <adaptationset contenttype="audio" startwithsap="1" segmentalignment="true" bitstreamswitching="true" lang="eng">&#xA;            <representation mimetype="audio/mp4" codecs="mp4a.40.2" bandwidth="320000" audiosamplingrate="44100">&#xA;                <audiochannelconfiguration schemeiduri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2"></audiochannelconfiguration>&#xA;                <segmenttemplate timescale="44100" initialization="dash_init_$RepresentationID$.m4s" media="dash_chunk_$RepresentationID$_$Number%05d$.m4s" startnumber="1">&#xA;                    <segmenttimeline>&#xA;                        <s t="0" d="220160"></s>&#xA;                        <s d="221184" r="62"></s>&#xA;                        <s d="151552"></s>&#xA;                    </segmenttimeline>&#xA;                </segmenttemplate>&#xA;            </representation>&#xA;        </adaptationset>&#xA;        <adaptationset contenttype="video" startwithsap="1" segmentalignment="true" bitstreamswitching="true" framerate="30/1" maxwidth="1920" maxheight="1080" par="16:9" lang="und">&#xA;            <representation mimetype="video/mp4" codecs="avc1.640028" bandwidth="4096000" width="1920" height="1080" sar="1:1">&#xA;                <segmenttemplate timescale="15360" initialization="dash_init_$RepresentationID$.m4s" media="dash_chunk_$RepresentationID$_$Number%05d$.m4s" startnumber="1">&#xA;                    <segmenttimeline>&#xA;                        <s t="0" d="86016"></s>&#xA;                        <s d="103424"></s>&#xA;                        <s d="95232"></s>&#xA;                        <s d="95744"></s>&#xA;                        <s d="111616"></s>&#xA;                        <s d="123392"></s>&#xA;                        <s d="80384"></s>&#xA;                        <s d="128000" r="1"></s>&#xA;                        <s d="109568"></s>&#xA;                        <s d="157184"></s>&#xA;                        <s d="92160"></s>&#xA;                        <s d="145408"></s>&#xA;                        <s d="79872"></s>&#xA;                        <s d="85504"></s>&#xA;                        <s d="92160"></s>&#xA;                        <s d="82944"></s>&#xA;                        <s d="81408"></s>&#xA;                        <s d="168960"></s>&#xA;                        <s d="138240"></s>&#xA;                        <s d="83456"></s>&#xA;                        <s d="99328"></s>&#xA;                        <s d="120320"></s>&#xA;                        <s d="126464"></s>&#xA;                        <s d="132608"></s>&#xA;                        <s d="121856"></s>&#xA;                        <s d="96768"></s>&#xA;                        <s d="90112"></s>&#xA;                        <s d="169472"></s>&#xA;                        <s d="121856"></s>&#xA;                        <s d="137216"></s>&#xA;                        <s d="119808"></s>&#xA;                        <s d="177152"></s>&#xA;                        <s d="92160"></s>&#xA;                        <s d="128000"></s>&#xA;                        <s d="161792"></s>&#xA;                        <s d="156160"></s>&#xA;                        <s d="78336"></s>&#xA;                        <s d="77824"></s>&#xA;                        <s d="84480"></s>&#xA;                        <s d="104960"></s>&#xA;                        <s d="110592"></s>&#xA;                        <s d="98304"></s>&#xA;                        <s d="108544"></s>&#xA;                    </segmenttimeline>&#xA;                </segmenttemplate>&#xA;            </representation>&#xA;        </adaptationset>&#xA;        <adaptationset contenttype="audio" startwithsap="1" segmentalignment="true" bitstreamswitching="true" lang="eng">&#xA;            <representation mimetype="audio/mp4" codecs="mp4a.40.2" bandwidth="320000" audiosamplingrate="44100">&#xA;                <audiochannelconfiguration schemeiduri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2"></audiochannelconfiguration>&#xA;                <segmenttemplate timescale="44100" initialization="dash_init_$RepresentationID$.m4s" media="dash_chunk_$RepresentationID$_$Number%05d$.m4s" startnumber="1">&#xA;                    <segmenttimeline>&#xA;                        <s t="0" d="220160"></s>&#xA;                        <s d="221184" r="62"></s>&#xA;                        <s d="151552"></s>&#xA;                    </segmenttimeline>&#xA;                </segmenttemplate>&#xA;            </representation>&#xA;        </adaptationset>&#xA;    </period>&#xA;</mpd>&#xA;

    &#xA;

    Do I really need multiple video files in different resolutions ? If not, then how would I go about making the necessary files ? Thanks in advance !

    &#xA;

  • lavc/avcodec : improve AV_CODEC_FLAG_RECON_FRAME doxy

    10 janvier 2023, par Anton Khirnov
    lavc/avcodec : improve AV_CODEC_FLAG_RECON_FRAME doxy
    

    Do not break a sentence on a period after "i.e.".

    Link to the definition of AV_CODEC_CAP_ENCODER_RECON_FRAME.

    • [DH] libavcodec/avcodec.h
  • How can I fix a segmentation fault in a C program ? [duplicate]

    31 mars 2023, par ipegasus
    &#xA;

    Possible Duplicate :
    &#xA;Segmentation fault

    &#xA;

    &#xA;

    Currently I am upgrading an open source program used for HTTP streaming. It needs to support the latest FFmpeg.&#xA;The code compiles fine without any warnings, although I am getting a segmentation fault error.

    &#xA;

    How can I fix the issue ? And / or, what is the best way to debug ? Please find attached a portion of the code due to size. I will try to add the project to GitHub :)

    &#xA;

    Sample Usage

    &#xA;

    # segmenter --i out.ts --l 10 --o stream.m3u8 --d segments --f stream&#xA;

    &#xA;

    Makefile

    &#xA;

    FFLIBS=`pkg-config --libs libavformat libavcodec libavutil`&#xA;FFFLAGS=`pkg-config --cflags libavformat libavcodec libavutil`&#xA;&#xA;all:&#xA;    gcc -Wall -g segmenter.c -o segmenter ${FFFLAGS} ${FFLIBS}&#xA;

    &#xA;

    segmenter.c

    &#xA;

    /*&#xA; * Copyright (c) 2009 Chase Douglas&#xA; *&#xA; * This program is free software; you can redistribute it and/or&#xA; * modify it under the terms of the GNU General Public License version 2&#xA; * as published by the Free Software Foundation.&#xA; *&#xA; * This program is distributed in the hope that it will be useful,&#xA; * but WITHOUT ANY WARRANTY; without even the implied warranty of&#xA; * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the&#xA; * GNU General Public License for more details.&#xA; *&#xA; * You should have received a copy of the GNU General Public License&#xA; * along with this program; if not, write to the Free Software&#xA; * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.&#xA; */&#xA;#include &#xA;#include &#xA;#include &#xA;#include &#xA;#include &#xA;#include "libavformat/avformat.h"&#xA;&#xA;#include "libavformat/avio.h"&#xA;&#xA;#include <sys></sys>stat.h>&#xA;&#xA;#include "segmenter.h"&#xA;#include "libavformat/avformat.h"&#xA;&#xA;#define IMAGE_ID3_SIZE 9171&#xA;&#xA;void printUsage() {&#xA;    fprintf(stderr, "\nExample: segmenter --i infile --d baseDir --f baseFileName --o playListFile.m3u8 --l 10 \n");&#xA;    fprintf(stderr, "\nOptions: \n");&#xA;    fprintf(stderr, "--i <infile>.\n");&#xA;    fprintf(stderr, "--o <outfile>.\n");&#xA;    fprintf(stderr, "--d basedir, the base directory for files.\n");&#xA;    fprintf(stderr, "--f baseFileName, output files will be baseFileName-#.\n");&#xA;    fprintf(stderr, "--l segment length, the length of each segment.\n");&#xA;    fprintf(stderr, "--a,  audio only decode for &lt; 64k streams.\n");&#xA;    fprintf(stderr, "--v,  video only decode for &lt; 64k streams.\n");&#xA;    fprintf(stderr, "--version, print version details and exit.\n");&#xA;    fprintf(stderr, "\n\n");&#xA;}&#xA;&#xA;void ffmpeg_version() {&#xA;    // output build and version numbers&#xA;    fprintf(stderr, "  libavutil version:   %s\n", AV_STRINGIFY(LIBAVUTIL_VERSION));&#xA;    fprintf(stderr, "  libavutil build:     %d\n", LIBAVUTIL_BUILD);&#xA;    fprintf(stderr, "  libavcodec version:  %s\n", AV_STRINGIFY(LIBAVCODEC_VERSION));&#xA;    fprintf(stdout, "  libavcodec build:    %d\n", LIBAVCODEC_BUILD);&#xA;    fprintf(stderr, "  libavformat version: %s\n", AV_STRINGIFY(LIBAVFORMAT_VERSION));&#xA;    fprintf(stderr, "  libavformat build:   %d\n", LIBAVFORMAT_BUILD);&#xA;    fprintf(stderr, "  built on " __DATE__ " " __TIME__);&#xA;#ifdef __GNUC__&#xA;    fprintf(stderr, ", gcc: " __VERSION__ "\n");&#xA;#else&#xA;    fprintf(stderr, ", using a non-gcc compiler\n");&#xA;#endif&#xA;}&#xA;&#xA;&#xA;static AVStream *add_output_stream(AVFormatContext *output_format_context, AVStream *input_stream) {&#xA;    AVCodecContext *input_codec_context;&#xA;    AVCodecContext *output_codec_context;&#xA;    AVStream *output_stream;&#xA;&#xA;    output_stream = avformat_new_stream(output_format_context, 0);&#xA;    if (!output_stream) {&#xA;        fprintf(stderr, "Segmenter error: Could not allocate stream\n");&#xA;        exit(1);&#xA;    }&#xA;&#xA;    input_codec_context = input_stream->codec;&#xA;    output_codec_context = output_stream->codec;&#xA;&#xA;    output_codec_context->codec_id = input_codec_context->codec_id;&#xA;    output_codec_context->codec_type = input_codec_context->codec_type;&#xA;    output_codec_context->codec_tag = input_codec_context->codec_tag;&#xA;    output_codec_context->bit_rate = input_codec_context->bit_rate;&#xA;    output_codec_context->extradata = input_codec_context->extradata;&#xA;    output_codec_context->extradata_size = input_codec_context->extradata_size;&#xA;&#xA;    if (av_q2d(input_codec_context->time_base) * input_codec_context->ticks_per_frame > av_q2d(input_stream->time_base) &amp;&amp; av_q2d(input_stream->time_base) &lt; 1.0 / 1000) {&#xA;        output_codec_context->time_base = input_codec_context->time_base;&#xA;        output_codec_context->time_base.num *= input_codec_context->ticks_per_frame;&#xA;    } else {&#xA;        output_codec_context->time_base = input_stream->time_base;&#xA;    }&#xA;&#xA;    switch (input_codec_context->codec_type) {&#xA;#ifdef USE_OLD_FFMPEG&#xA;        case CODEC_TYPE_AUDIO:&#xA;#else&#xA;        case AVMEDIA_TYPE_AUDIO:&#xA;#endif&#xA;            output_codec_context->channel_layout = input_codec_context->channel_layout;&#xA;            output_codec_context->sample_rate = input_codec_context->sample_rate;&#xA;            output_codec_context->channels = input_codec_context->channels;&#xA;            output_codec_context->frame_size = input_codec_context->frame_size;&#xA;            if ((input_codec_context->block_align == 1 &amp;&amp; input_codec_context->codec_id == CODEC_ID_MP3) || input_codec_context->codec_id == CODEC_ID_AC3) {&#xA;                output_codec_context->block_align = 0;&#xA;            } else {&#xA;                output_codec_context->block_align = input_codec_context->block_align;&#xA;            }&#xA;            break;&#xA;#ifdef USE_OLD_FFMPEG&#xA;        case CODEC_TYPE_VIDEO:&#xA;#else&#xA;        case AVMEDIA_TYPE_VIDEO:&#xA;#endif&#xA;            output_codec_context->pix_fmt = input_codec_context->pix_fmt;&#xA;            output_codec_context->width = input_codec_context->width;&#xA;            output_codec_context->height = input_codec_context->height;&#xA;            output_codec_context->has_b_frames = input_codec_context->has_b_frames;&#xA;&#xA;            if (output_format_context->oformat->flags &amp; AVFMT_GLOBALHEADER) {&#xA;                output_codec_context->flags |= CODEC_FLAG_GLOBAL_HEADER;&#xA;            }&#xA;            break;&#xA;        default:&#xA;            break;&#xA;    }&#xA;&#xA;    return output_stream;&#xA;}&#xA;&#xA;int write_index_file(const char index[], const char tmp_index[], const unsigned int planned_segment_duration, const unsigned int actual_segment_duration[],&#xA;        const char output_directory[], const char output_prefix[], const char output_file_extension[],&#xA;        const unsigned int first_segment, const unsigned int last_segment) {&#xA;    FILE *index_fp;&#xA;    char *write_buf;&#xA;    unsigned int i;&#xA;&#xA;    index_fp = fopen(tmp_index, "w");&#xA;    if (!index_fp) {&#xA;        fprintf(stderr, "Could not open temporary m3u8 index file (%s), no index file will be created\n", tmp_index);&#xA;        return -1;&#xA;    }&#xA;&#xA;    write_buf = malloc(sizeof (char) * 1024);&#xA;    if (!write_buf) {&#xA;        fprintf(stderr, "Could not allocate write buffer for index file, index file will be invalid\n");&#xA;        fclose(index_fp);&#xA;        return -1;&#xA;    }&#xA;&#xA;    unsigned int maxDuration = planned_segment_duration;&#xA;&#xA;    for (i = first_segment; i &lt;= last_segment; i&#x2B;&#x2B;)&#xA;        if (actual_segment_duration[i] > maxDuration)&#xA;            maxDuration = actual_segment_duration[i];&#xA;&#xA;&#xA;&#xA;    snprintf(write_buf, 1024, "#EXTM3U\n#EXT-X-TARGETDURATION:%u\n", maxDuration);&#xA;&#xA;    if (fwrite(write_buf, strlen(write_buf), 1, index_fp) != 1) {&#xA;        fprintf(stderr, "Could not write to m3u8 index file, will not continue writing to index file\n");&#xA;        free(write_buf);&#xA;        fclose(index_fp);&#xA;        return -1;&#xA;    }&#xA;&#xA;    for (i = first_segment; i &lt;= last_segment; i&#x2B;&#x2B;) {&#xA;        snprintf(write_buf, 1024, "#EXTINF:%u,\n%s-%u%s\n", actual_segment_duration[i], output_prefix, i, output_file_extension);&#xA;        if (fwrite(write_buf, strlen(write_buf), 1, index_fp) != 1) {&#xA;            fprintf(stderr, "Could not write to m3u8 index file, will not continue writing to index file\n");&#xA;            free(write_buf);&#xA;            fclose(index_fp);&#xA;            return -1;&#xA;        }&#xA;    }&#xA;&#xA;    snprintf(write_buf, 1024, "#EXT-X-ENDLIST\n");&#xA;    if (fwrite(write_buf, strlen(write_buf), 1, index_fp) != 1) {&#xA;        fprintf(stderr, "Could not write last file and endlist tag to m3u8 index file\n");&#xA;        free(write_buf);&#xA;        fclose(index_fp);&#xA;        return -1;&#xA;    }&#xA;&#xA;    free(write_buf);&#xA;    fclose(index_fp);&#xA;&#xA;    return rename(tmp_index, index);&#xA;}&#xA;&#xA;int main(int argc, const char *argv[]) {&#xA;    //input parameters&#xA;    char inputFilename[MAX_FILENAME_LENGTH], playlistFilename[MAX_FILENAME_LENGTH], baseDirName[MAX_FILENAME_LENGTH], baseFileName[MAX_FILENAME_LENGTH];&#xA;    char baseFileExtension[5]; //either "ts", "aac" or "mp3"&#xA;    int segmentLength, outputStreams, verbosity, version;&#xA;&#xA;&#xA;&#xA;    char currentOutputFileName[MAX_FILENAME_LENGTH];&#xA;    char tempPlaylistName[MAX_FILENAME_LENGTH];&#xA;&#xA;&#xA;    //these are used to determine the exact length of the current segment&#xA;    double prev_segment_time = 0;&#xA;    double segment_time;&#xA;    unsigned int actual_segment_durations[2048];&#xA;    double packet_time = 0;&#xA;&#xA;    //new variables to keep track of output size&#xA;    double output_bytes = 0;&#xA;&#xA;    unsigned int output_index = 1;&#xA;    AVOutputFormat *ofmt;&#xA;    AVFormatContext *ic = NULL;&#xA;    AVFormatContext *oc;&#xA;    AVStream *video_st = NULL;&#xA;    AVStream *audio_st = NULL;&#xA;    AVCodec *codec;&#xA;    int video_index;&#xA;    int audio_index;&#xA;    unsigned int first_segment = 1;&#xA;    unsigned int last_segment = 0;&#xA;    int write_index = 1;&#xA;    int decode_done;&#xA;    int ret;&#xA;    int i;&#xA;&#xA;    unsigned char id3_tag[128];&#xA;    unsigned char * image_id3_tag;&#xA;&#xA;    size_t id3_tag_size = 73;&#xA;    int newFile = 1; //a boolean value to flag when a new file needs id3 tag info in it&#xA;&#xA;    if (parseCommandLine(inputFilename, playlistFilename, baseDirName, baseFileName, baseFileExtension, &amp;outputStreams, &amp;segmentLength, &amp;verbosity, &amp;version, argc, argv) != 0)&#xA;        return 0;&#xA;&#xA;    if (version) {&#xA;        ffmpeg_version();&#xA;        return 0;&#xA;    }&#xA;&#xA;&#xA;    fprintf(stderr, "%s %s\n", playlistFilename, tempPlaylistName);&#xA;&#xA;&#xA;    image_id3_tag = malloc(IMAGE_ID3_SIZE);&#xA;    if (outputStreams == OUTPUT_STREAM_AUDIO)&#xA;        build_image_id3_tag(image_id3_tag);&#xA;    build_id3_tag((char *) id3_tag, id3_tag_size);&#xA;&#xA;    snprintf(tempPlaylistName, strlen(playlistFilename) &#x2B; strlen(baseDirName) &#x2B; 1, "%s%s", baseDirName, playlistFilename);&#xA;    strncpy(playlistFilename, tempPlaylistName, strlen(tempPlaylistName));&#xA;    strncpy(tempPlaylistName, playlistFilename, MAX_FILENAME_LENGTH);&#xA;    strncat(tempPlaylistName, ".", 1);&#xA;&#xA;    //decide if this is an aac file or a mpegts file.&#xA;    //postpone deciding format until later&#xA;    /*    ifmt = av_find_input_format("mpegts");&#xA;    if (!ifmt)&#xA;    {&#xA;    fprintf(stderr, "Could not find MPEG-TS demuxer.\n");&#xA;    exit(1);&#xA;    } */&#xA;&#xA;    av_log_set_level(AV_LOG_DEBUG);&#xA;&#xA;    av_register_all();&#xA;    ret = avformat_open_input(&amp;ic, inputFilename, NULL, NULL);&#xA;    if (ret != 0) {&#xA;        fprintf(stderr, "Could not open input file %s. Error %d.\n", inputFilename, ret);&#xA;        exit(1);&#xA;    }&#xA;&#xA;    if (avformat_find_stream_info(ic, NULL) &lt; 0) {&#xA;        fprintf(stderr, "Could not read stream information.\n");&#xA;        exit(1);&#xA;    }&#xA;&#xA;    oc = avformat_alloc_context();&#xA;    if (!oc) {&#xA;        fprintf(stderr, "Could not allocate output context.");&#xA;        exit(1);&#xA;    }&#xA;&#xA;    video_index = -1;&#xA;    audio_index = -1;&#xA;&#xA;    for (i = 0; i &lt; ic->nb_streams &amp;&amp; (video_index &lt; 0 || audio_index &lt; 0); i&#x2B;&#x2B;) {&#xA;        switch (ic->streams[i]->codec->codec_type) {&#xA;&#xA;#ifdef USE_OLD_FFMPEG&#xA;            case CODEC_TYPE_VIDEO:&#xA;#else&#xA;            case AVMEDIA_TYPE_VIDEO:&#xA;#endif&#xA;                video_index = i;&#xA;                ic->streams[i]->discard = AVDISCARD_NONE;&#xA;                if (outputStreams &amp; OUTPUT_STREAM_VIDEO)&#xA;                    video_st = add_output_stream(oc, ic->streams[i]);&#xA;                break;&#xA;#ifdef USE_OLD_FFMPEG&#xA;            case CODEC_TYPE_AUDIO:&#xA;#else&#xA;            case AVMEDIA_TYPE_AUDIO:&#xA;#endif&#xA;                audio_index = i;&#xA;                ic->streams[i]->discard = AVDISCARD_NONE;&#xA;                if (outputStreams &amp; OUTPUT_STREAM_AUDIO)&#xA;                    audio_st = add_output_stream(oc, ic->streams[i]);&#xA;                break;&#xA;            default:&#xA;                ic->streams[i]->discard = AVDISCARD_ALL;&#xA;                break;&#xA;        }&#xA;    }&#xA;&#xA;    if (video_index == -1) {&#xA;        fprintf(stderr, "Stream must have video component.\n");&#xA;        exit(1);&#xA;    }&#xA;&#xA;    //now that we know the audio and video output streams&#xA;    //we can decide on an output format.&#xA;    if (outputStreams == OUTPUT_STREAM_AUDIO) {&#xA;        //the audio output format should be the same as the audio input format&#xA;        switch (ic->streams[audio_index]->codec->codec_id) {&#xA;            case CODEC_ID_MP3:&#xA;                fprintf(stderr, "Setting output audio to mp3.");&#xA;                strncpy(baseFileExtension, ".mp3", strlen(".mp3"));&#xA;                ofmt = av_guess_format("mp3", NULL, NULL);&#xA;                break;&#xA;            case CODEC_ID_AAC:&#xA;                fprintf(stderr, "Setting output audio to aac.");&#xA;                ofmt = av_guess_format("adts", NULL, NULL);&#xA;                break;&#xA;            default:&#xA;                fprintf(stderr, "Codec id %d not supported.\n", ic->streams[audio_index]->id);&#xA;        }&#xA;        if (!ofmt) {&#xA;            fprintf(stderr, "Could not find audio muxer.\n");&#xA;            exit(1);&#xA;        }&#xA;    } else {&#xA;        ofmt = av_guess_format("mpegts", NULL, NULL);&#xA;        if (!ofmt) {&#xA;            fprintf(stderr, "Could not find MPEG-TS muxer.\n");&#xA;            exit(1);&#xA;        }&#xA;    }&#xA;    oc->oformat = ofmt;&#xA;&#xA;    if (outputStreams &amp; OUTPUT_STREAM_VIDEO &amp;&amp; oc->oformat->flags &amp; AVFMT_GLOBALHEADER) {&#xA;        oc->flags |= CODEC_FLAG_GLOBAL_HEADER;&#xA;    }&#xA;&#xA;&#xA;    /*  Deprecated: pass the options to avformat_write_header directly.&#xA;        if (av_set_parameters(oc, NULL) &lt; 0) {&#xA;            fprintf(stderr, "Invalid output format parameters.\n");&#xA;            exit(1);&#xA;        }&#xA;     */&#xA;&#xA;    av_dump_format(oc, 0, baseFileName, 1);&#xA;&#xA;&#xA;    //open the video codec only if there is video data&#xA;    if (video_index != -1) {&#xA;        if (outputStreams &amp; OUTPUT_STREAM_VIDEO)&#xA;            codec = avcodec_find_decoder(video_st->codec->codec_id);&#xA;        else&#xA;            codec = avcodec_find_decoder(ic->streams[video_index]->codec->codec_id);&#xA;        if (!codec) {&#xA;            fprintf(stderr, "Could not find video decoder, key frames will not be honored.\n");&#xA;        }&#xA;&#xA;        if (outputStreams &amp; OUTPUT_STREAM_VIDEO)&#xA;            ret = avcodec_open2(video_st->codec, codec, NULL);&#xA;        else&#xA;            avcodec_open2(ic->streams[video_index]->codec, codec, NULL);&#xA;        if (ret &lt; 0) {&#xA;            fprintf(stderr, "Could not open video decoder, key frames will not be honored.\n");&#xA;        }&#xA;    }&#xA;&#xA;    snprintf(currentOutputFileName, strlen(baseDirName) &#x2B; strlen(baseFileName) &#x2B; strlen(baseFileExtension) &#x2B; 10, "%s%s-%u%s", baseDirName, baseFileName, output_index&#x2B;&#x2B;, baseFileExtension);&#xA;&#xA;    if (avio_open(&amp;oc->pb, currentOutputFileName, URL_WRONLY) &lt; 0) {&#xA;        fprintf(stderr, "Could not open &#x27;%s&#x27;.\n", currentOutputFileName);&#xA;        exit(1);&#xA;    }&#xA;    newFile = 1;&#xA;&#xA;    int r = avformat_write_header(oc,NULL);&#xA;    if (r) {&#xA;        fprintf(stderr, "Could not write mpegts header to first output file.\n");&#xA;        debugReturnCode(r);&#xA;        exit(1);&#xA;    }&#xA;&#xA;    //no segment info is written here. This just creates the shell of the playlist file&#xA;    write_index = !write_index_file(playlistFilename, tempPlaylistName, segmentLength, actual_segment_durations, baseDirName, baseFileName, baseFileExtension, first_segment, last_segment);&#xA;&#xA;    do {&#xA;        AVPacket packet;&#xA;&#xA;        decode_done = av_read_frame(ic, &amp;packet);&#xA;&#xA;        if (decode_done &lt; 0) {&#xA;            break;&#xA;        }&#xA;&#xA;        if (av_dup_packet(&amp;packet) &lt; 0) {&#xA;            fprintf(stderr, "Could not duplicate packet.");&#xA;            av_free_packet(&amp;packet);&#xA;            break;&#xA;        }&#xA;&#xA;        //this time is used to check for a break in the segments&#xA;        //    if (packet.stream_index == video_index &amp;&amp; (packet.flags &amp; PKT_FLAG_KEY))&#xA;        //    {&#xA;        //    segment_time = (double)video_st->pts.val * video_st->time_base.num / video_st->time_base.den;&#xA;        //    }&#xA;#if USE_OLD_FFMPEG&#xA;        if (packet.stream_index == video_index &amp;&amp; (packet.flags &amp; PKT_FLAG_KEY))&#xA;#else&#xA;        if (packet.stream_index == video_index &amp;&amp; (packet.flags &amp; AV_PKT_FLAG_KEY))&#xA;#endif&#xA;        {&#xA;            segment_time = (double) packet.pts * ic->streams[video_index]->time_base.num / ic->streams[video_index]->time_base.den;&#xA;        }&#xA;        //  else if (video_index &lt; 0)&#xA;        //    {&#xA;        //        segment_time = (double)audio_st->pts.val * audio_st->time_base.num / audio_st->time_base.den;&#xA;        //    }&#xA;&#xA;        //get the most recent packet time&#xA;        //this time is used when the time for the final segment is printed. It may not be on the edge of&#xA;        //of a keyframe!&#xA;        if (packet.stream_index == video_index)&#xA;            packet_time = (double) packet.pts * ic->streams[video_index]->time_base.num / ic->streams[video_index]->time_base.den; //(double)video_st->pts.val * video_st->time_base.num / video_st->time_base.den;&#xA;        else if (outputStreams &amp; OUTPUT_STREAM_AUDIO)&#xA;            packet_time = (double) audio_st->pts.val * audio_st->time_base.num / audio_st->time_base.den;&#xA;        else&#xA;            continue;&#xA;        //start looking for segment splits for videos one half second before segment duration expires. This is because the&#xA;        //segments are split on key frames so we cannot expect all segments to be split exactly equally.&#xA;        if (segment_time - prev_segment_time >= segmentLength - 0.5) {&#xA;            fprintf(stderr, "looking to print index file at time %lf\n", segment_time);&#xA;            avio_flush(oc->pb);&#xA;            avio_close(oc->pb);&#xA;&#xA;            if (write_index) {&#xA;                actual_segment_durations[&#x2B;&#x2B;last_segment] = (unsigned int) rint(segment_time - prev_segment_time);&#xA;                write_index = !write_index_file(playlistFilename, tempPlaylistName, segmentLength, actual_segment_durations, baseDirName, baseFileName, baseFileExtension, first_segment, last_segment);&#xA;                fprintf(stderr, "Writing index file at time %lf\n", packet_time);&#xA;            }&#xA;&#xA;            struct stat st;&#xA;            stat(currentOutputFileName, &amp;st);&#xA;            output_bytes &#x2B;= st.st_size;&#xA;&#xA;            snprintf(currentOutputFileName, strlen(baseDirName) &#x2B; strlen(baseFileName) &#x2B; strlen(baseFileExtension) &#x2B; 10, "%s%s-%u%s", baseDirName, baseFileName, output_index&#x2B;&#x2B;, baseFileExtension);&#xA;            if (avio_open(&amp;oc->pb, currentOutputFileName, URL_WRONLY) &lt; 0) {&#xA;                fprintf(stderr, "Could not open &#x27;%s&#x27;\n", currentOutputFileName);&#xA;                break;&#xA;            }&#xA;&#xA;            newFile = 1;&#xA;            prev_segment_time = segment_time;&#xA;        }&#xA;&#xA;        if (outputStreams == OUTPUT_STREAM_AUDIO &amp;&amp; packet.stream_index == audio_index) {&#xA;            if (newFile &amp;&amp; outputStreams == OUTPUT_STREAM_AUDIO) {&#xA;                //add id3 tag info&#xA;                //fprintf(stderr, "adding id3tag to file %s\n", currentOutputFileName);&#xA;                //printf("%lf %lld %lld %lld %lld %lld %lf\n", segment_time, audio_st->pts.val, audio_st->cur_dts, audio_st->cur_pkt.pts, packet.pts, packet.dts, packet.dts * av_q2d(ic->streams[audio_index]->time_base) );&#xA;                fill_id3_tag((char*) id3_tag, id3_tag_size, packet.dts);&#xA;                avio_write(oc->pb, id3_tag, id3_tag_size);&#xA;                avio_write(oc->pb, image_id3_tag, IMAGE_ID3_SIZE);&#xA;                avio_flush(oc->pb);&#xA;                newFile = 0;&#xA;            }&#xA;&#xA;            packet.stream_index = 0; //only one stream in audio only segments&#xA;            ret = av_interleaved_write_frame(oc, &amp;packet);&#xA;        } else if (outputStreams &amp; OUTPUT_STREAM_VIDEO) {&#xA;            if (newFile) {&#xA;                //fprintf(stderr, "New File: %lld %lld %lld\n", packet.pts, video_st->pts.val, audio_st->pts.val);&#xA;                //printf("%lf %lld %lld %lld %lld %lld %lf\n", segment_time, audio_st->pts.val, audio_st->cur_dts, audio_st->cur_pkt.pts, packet.pts, packet.dts, packet.dts * av_q2d(ic->streams[audio_index]->time_base) );&#xA;                newFile = 0;&#xA;            }&#xA;            if (outputStreams == OUTPUT_STREAM_VIDEO)&#xA;                ret = av_write_frame(oc, &amp;packet);&#xA;            else&#xA;                ret = av_interleaved_write_frame(oc, &amp;packet);&#xA;        }&#xA;&#xA;        if (ret &lt; 0) {&#xA;            fprintf(stderr, "Warning: Could not write frame of stream.\n");&#xA;        } else if (ret > 0) {&#xA;            fprintf(stderr, "End of stream requested.\n");&#xA;            av_free_packet(&amp;packet);&#xA;            break;&#xA;        }&#xA;&#xA;        av_free_packet(&amp;packet);&#xA;    } while (!decode_done);&#xA;&#xA;    //make sure all packets are written and then close the last file.&#xA;    avio_flush(oc->pb);&#xA;    av_write_trailer(oc);&#xA;&#xA;    if (video_st &amp;&amp; video_st->codec)&#xA;        avcodec_close(video_st->codec);&#xA;&#xA;    if (audio_st &amp;&amp; audio_st->codec)&#xA;        avcodec_close(audio_st->codec);&#xA;&#xA;    for (i = 0; i &lt; oc->nb_streams; i&#x2B;&#x2B;) {&#xA;        av_freep(&amp;oc->streams[i]->codec);&#xA;        av_freep(&amp;oc->streams[i]);&#xA;    }&#xA;&#xA;    avio_close(oc->pb);&#xA;    av_free(oc);&#xA;&#xA;    struct stat st;&#xA;    stat(currentOutputFileName, &amp;st);&#xA;    output_bytes &#x2B;= st.st_size;&#xA;&#xA;&#xA;    if (write_index) {&#xA;        actual_segment_durations[&#x2B;&#x2B;last_segment] = (unsigned int) rint(packet_time - prev_segment_time);&#xA;&#xA;        //make sure that the last segment length is not zero&#xA;        if (actual_segment_durations[last_segment] == 0)&#xA;            actual_segment_durations[last_segment] = 1;&#xA;&#xA;        write_index_file(playlistFilename, tempPlaylistName, segmentLength, actual_segment_durations, baseDirName, baseFileName, baseFileExtension, first_segment, last_segment);&#xA;&#xA;    }&#xA;&#xA;    write_stream_size_file(baseDirName, baseFileName, output_bytes * 8 / segment_time);&#xA;&#xA;    return 0;&#xA;}&#xA;</outfile></infile>

    &#xA;