Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selecting the video quality #49

Open
limaalef opened this issue Feb 25, 2024 · 2 comments
Open

Selecting the video quality #49

limaalef opened this issue Feb 25, 2024 · 2 comments

Comments

@limaalef
Copy link

limaalef commented Feb 25, 2024

Hello!

First of all, thank you. Your program helped me a lot!

So I have some problems to selecting the best video quality in some cases.

The manifest is like this:

Streams in period #1, duration 8940.932s:
audio mp4a.40.2         |    93 Kbps |  lang=por
audio mp4a.40.2         |    93 Kbps |  lang=org
video avc1.640029       |   512 Kbps |   480x270
video avc1.640029       |  1126 Kbps |   768x432
video avc1.640029       |  1843 Kbps |  1024x576
video avc1.640029       |  4091 Kbps |  1280x720
video avc1.640029       |  6348 Kbps |  1280x720
video avc1.640029       |   512 Kbps |   480x270 role=alternate
video avc1.640029       |  1126 Kbps |   768x432 role=alternate
video avc1.640029       |  1843 Kbps |  1024x576 role=alternate
video avc1.640029       |  4091 Kbps |  1280x720 role=alternate
video avc1.640029       |  6348 Kbps |  1280x720 role=alternate

When i use just --quality best the program download one of two 1280x720@6348 Kbps (@ 59,94 fps), but i dont know what, if the main option or the alternate

When i add --prefer-video-width 1280 the program download one of two 1280x720@4091 Kbps (@ 29,97 fps) , but again i dont know what, if the main option or the alternate

In this case, there are two options of each quality because the service provide main streams as expected and the other option is something like a sequence of screenshots and isnt the normal videostream (i really dont know why)

I got the information that yt-dlp provide to try explain this case

ID                EXT RESOLUTION FPS │   TBR PROTO │ VCODEC        VBR ACODEC     ABR ASR MORE INFO
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
dyHiAZ8.          m4a audio only     │   96k dash  │ audio only        mp4a.40.2  96k 24k [por] DRM, DASH audio, m4a_dash
dyHjAZ8.          m4a audio only     │   96k dash  │ audio only        mp4a.40.2  96k 24k [org] DRM, DASH audio, m4a_dash
dzEAAAif          mp4 480x270        │  524k dash  │ avc1.640029  524k video only         DRM, DASH video, mp4_dash
trickmodedzEAAAif mp4 480x270      1 │  524k dash  │ avc1.640029  524k video only         DRM, DASH video, mp4_dash
dzGZmRGf          mp4 768x432        │ 1153k dash  │ avc1.640029 1153k video only         DRM, DASH video, mp4_dash
trickmodedzGZmRGf mp4 768x432      1 │ 1153k dash  │ avc1.640029 1153k video only         DRM, DASH video, mp4_dash
dzHMzByf          mp4 1024x576       │ 1887k dash  │ avc1.640029 1887k video only         DRM, DASH video, mp4_dash
trickmodedzHMzByf mp4 1024x576     1 │ 1887k dash  │ avc1.640029 1887k video only         DRM, DASH video, mp4_dash
dzEw7z-f          mp4 1280x720       │ 4190k dash  │ avc1.640029 4190k video only         DRM, DASH video, mp4_dash
dzEzM2Of          mp4 1280x720       │ 6501k dash  │ avc1.640029 6501k video only         DRM, DASH video, mp4_dash
trickmodedzEw7z-f mp4 1280x720     1 │ 4190k dash  │ avc1.640029 4190k video only         DRM, DASH video, mp4_dash
trickmodedzEzM2Of mp4 1280x720     1 │ 6501k dash  │ avc1.640029 6501k video only         DRM, DASH video, mp4_dash

So, is there any way that I can select the exact option I want to download?

PS: adding the raw MPD

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--Created with VSPP Streamer version 9.2.0.0 build  Commit_id: d537ec715e771249b4933ee5f30b36c6710cc258 Commit_time: 1681376738 context FHCIAPIAHHLNKNFG-ICPIKBAAHHLNKNFG-->
<MPD xmlns="urn:mpeg:dash:schema:mpd:2011"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xmlns:cenc="urn:mpeg:cenc:2013"
     xmlns:mspr="urn:microsoft:playready"
     profiles="urn:mpeg:dash:profile:isoff-live:2011"
     type="static"
     mediaPresentationDuration="PT2H29M0.932S"
     maxSegmentDuration="PT6.017S"
     minBufferTime="PT6.017S">
    <Period>
        <AdaptationSet id="1"
                        group="1"
                        bitstreamSwitching="true"
                        segmentAlignment="true"
                        contentType="video"
                        mimeType="video/mp4"
                        maxWidth="1280"
                        maxHeight="720"
                        par="16:9"
                        maxFrameRate="30000/1001"
                        startWithSAP="1">
            <ContentProtection schemeIdUri="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"
                                value="Widevine">
                <cenc:pssh>XXXXX</cenc:pssh>
            </ContentProtection>
            <ContentProtection schemeIdUri="urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95"
                                value="MSPR 2.0">
                <mspr:pro>XXXXX</mspr:pro>
            </ContentProtection>
            <ContentProtection schemeIdUri="urn:mpeg:dash:mp4protection:2011"
                                value="cenc"/>
            <SegmentTemplate timescale="10000000"
                             media="S!dxIHQxhXtctE8Jy1yzbhSbdnEkdWUC1EQVNILURSTV9CUi1QTngg6gMVAQoLrw__/QualityLevels($Bandwidth$)/Fragments(video=$Time$)"
                             initialization="S!dxIHQxhXtctE8Jy1yzbhSbdnEkdWUC1EQVNILURSTV9CUi1QTngg6gMVAQoLrw__/QualityLevels($Bandwidth$)/Fragments(video=Init)"
                             presentationTimeOffset="17088295804034560">
                <SegmentTimeline>
                    <S t="17088295804034560"
                       d="60060000"
                       r="1487"/>
                    <S d="40040000"/>
                </SegmentTimeline>
            </SegmentTemplate>
            <Representation id="dzEAAAif"
                            bandwidth="524288"
                            codecs="avc1.640029"
                            width="480"
                            height="270"
                            frameRate="30000/1001"
                            sar="1:1"/>
            <Representation id="dzGZmRGf"
                            bandwidth="1153433"
                            codecs="avc1.640029"
                            width="768"
                            height="432"
                            frameRate="30000/1001"
                            sar="1:1"/>
            <Representation id="dzHMzByf"
                            bandwidth="1887436"
                            codecs="avc1.640029"
                            width="1024"
                            height="576"
                            frameRate="30000/1001"
                            sar="1:1"/>
            <Representation id="dzEw7z-f"
                            bandwidth="4190000"
                            codecs="avc1.640029"
                            width="1280"
                            height="720"
                            frameRate="30000/1001"
                            sar="1:1"/>
            <Representation id="dzEzM2Of"
                            bandwidth="6501171"
                            codecs="avc1.640029"
                            width="1280"
                            height="720"
                            frameRate="30000/1001"
                            sar="1:1"/>
        </AdaptationSet>
        <AdaptationSet id="2"
                        group="32"
                        bitstreamSwitching="true"
                        segmentAlignment="true"
                        contentType="video"
                        mimeType="video/mp4"
                        maxWidth="1280"
                        maxHeight="720"
                        par="16:9"
                        maxFrameRate="30000/1001"
                        startWithSAP="1"
                        codingDependency="false">
            <ContentProtection schemeIdUri="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"
                                value="Widevine">
                <cenc:pssh>XXXXX</cenc:pssh>
            </ContentProtection>
            <ContentProtection schemeIdUri="urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95"
                                value="MSPR 2.0">
                <mspr:pro>XXXXX</mspr:pro>
            </ContentProtection>
            <ContentProtection schemeIdUri="urn:mpeg:dash:mp4protection:2011"
                                value="cenc"/>
            <EssentialProperty schemeIdUri="http://dashif.org/guidelines/trickmode"
                               value="1"/>
            <Role schemeIdUri="urn:mpeg:dash:role:2011"
                  value="alternate"/>
            <SegmentTemplate timescale="10000000"
                             media="S!dxIHQxhXtctE8Jy1yzbhSbdnEkdWUC1EQVNILURSTV9CUi1QTngg6gMVAQoLrw__/QualityLevels($Bandwidth$)/Fragments(trickmode=$Time$)"
                             initialization="S!dxIHQxhXtctE8Jy1yzbhSbdnEkdWUC1EQVNILURSTV9CUi1QTngg6gMVAQoLrw__/QualityLevels($Bandwidth$)/Fragments(trickmode=Init)"
                             presentationTimeOffset="17088295804034560">
                <SegmentTimeline>
                    <S t="17088295804034560"
                       d="60060000"
                       r="1487"/>
                    <S d="40040000"/>
                </SegmentTimeline>
            </SegmentTemplate>
            <Representation id="trickmodedzEAAAif"
                            bandwidth="524288"
                            codecs="avc1.640029"
                            width="480"
                            height="270"
                            frameRate="1"
                            sar="1:1"
                            maxPlayoutRate="29.97"/>
            <Representation id="trickmodedzGZmRGf"
                            bandwidth="1153433"
                            codecs="avc1.640029"
                            width="768"
                            height="432"
                            frameRate="1"
                            sar="1:1"
                            maxPlayoutRate="29.97"/>
            <Representation id="trickmodedzHMzByf"
                            bandwidth="1887436"
                            codecs="avc1.640029"
                            width="1024"
                            height="576"
                            frameRate="1"
                            sar="1:1"
                            maxPlayoutRate="29.97"/>
            <Representation id="trickmodedzEw7z-f"
                            bandwidth="4190000"
                            codecs="avc1.640029"
                            width="1280"
                            height="720"
                            frameRate="1"
                            sar="1:1"
                            maxPlayoutRate="29.97"/>
            <Representation id="trickmodedzEzM2Of"
                            bandwidth="6501171"
                            codecs="avc1.640029"
                            width="1280"
                            height="720"
                            frameRate="1"
                            sar="1:1"
                            maxPlayoutRate="29.97"/>
        </AdaptationSet>
        <AdaptationSet id="3"
                        group="2"
                        bitstreamSwitching="true"
                        segmentAlignment="true"
                        contentType="audio"
                        mimeType="audio/mp4"
                        lang="por">
            <AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011"
                                       value="2"/>
            <ContentProtection schemeIdUri="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"
                                value="Widevine">
                <cenc:pssh>XXXXX</cenc:pssh>
            </ContentProtection>
            <ContentProtection schemeIdUri="urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95"
                                value="MSPR 2.0">
                <mspr:pro>XXXXX</mspr:pro>
            </ContentProtection>
            <ContentProtection schemeIdUri="urn:mpeg:dash:mp4protection:2011"
                                value="cenc"/>
        </AdaptationSet>
    </Period>
</MPD>...

PS 2: I downloaded the version 0.2.8 ans worked as I wanted, saving my target version (id=dzEzM2Of).

@emarsden
Copy link
Owner

When you say "--quality best" and the MPD includes a bandwidth attribute, as is the case here, the stream with the highest bandwidth will be chosen.

There should probably be an option to allow you to specify the ids of the streams you want explicitly, but you can solve your problem using the XSLT rewriting functionality. You want to "drop" the AdaptationSet elements which have a Role child with value="alternate". You need to write an XPath expression to identify those AdaptationSet elements (see the doc, you will also need to make sure the xsltproc commandline application is installed). Probably something like

--drop-elements "//mpd:AdaptationSet[.//mpd:Role[@value='alternate']]"

@limaalef
Copy link
Author

When you say "--quality best" and the MPD includes a bandwidth attribute, as is the case here, the stream with the highest bandwidth will be chosen.

There should probably be an option to allow you to specify the ids of the streams you want explicitly, but you can solve your problem using the XSLT rewriting functionality. You want to "drop" the AdaptationSet elements which have a Role child with value="alternate". You need to write an XPath expression to identify those AdaptationSet elements (see the doc, you will also need to make sure the xsltproc commandline application is installed). Probably something like

--drop-elements "//mpd:AdaptationSet[.//mpd:Role[@value='alternate']]"

Thank you so much

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants