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

Case of "bestvideo" not selecting best video format on YouTube video #14010

Closed
ddawson opened this issue Aug 24, 2017 · 3 comments
Closed

Case of "bestvideo" not selecting best video format on YouTube video #14010

ddawson opened this issue Aug 24, 2017 · 3 comments

Comments

@ddawson
Copy link

@ddawson ddawson commented Aug 24, 2017

Please follow the guide below

  • You will be asked some questions and requested to provide some information, please read them carefully and answer honestly
  • Put an x into all the boxes [ ] relevant to your issue (like this: [x])
  • Use the Preview tab to see what your issue will actually look like

Make sure you are using the latest version: run youtube-dl --version and ensure your version is 2017.08.23. If it's not, read this FAQ entry and update. Issues with outdated version will be rejected.

  • I've verified and I assure that I'm running youtube-dl 2017.08.23

Before submitting an issue make sure you have:

  • At least skimmed through the README, most notably the FAQ and BUGS sections
  • Searched the bugtracker for similar issues including closed ones

What is the purpose of your issue?

  • Bug report (encountered problems with youtube-dl)
  • Site support request (request for adding support for a new site)
  • Feature request (request for a new functionality)
  • Question
  • Other

The following sections concretize particular purposed issues, you can erase any section (the contents between triple ---) not applicable to your issue


If the purpose of this issue is a bug report, site support request or you are not completely sure provide the full verbose output as follows:

Add the -v flag to your command line you run youtube-dl with (youtube-dl -v <your command line>), copy the whole output and insert it here. It should look similar to one below (replace it with your log inserted between triple ```):

[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: [u'-v', u'-o', u'test.mkv', u'--merge-output-format=mkv', u'https://www.youtube.com/watch?v=MUMlwUe-BCo']
[debug] Encodings: locale UTF-8, fs UTF-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2017.08.23
[debug] Python version 2.7.13 - Linux-4.12.4-gentoo-ddawson64-x86_64-Intel-R-_Core-TM-_i3-2120_CPU_@_3.30GHz-with-gentoo-2.4.1
[debug] exe versions: ffmpeg 3.3.3, ffprobe 3.3.3, rtmpdump 2.4
[debug] Proxy map: {}
[youtube] MUMlwUe-BCo: Downloading webpage
[youtube] MUMlwUe-BCo: Downloading video info webpage
[youtube] MUMlwUe-BCo: Extracting video information
[youtube] MUMlwUe-BCo: Downloading MPD manifest
[youtube] MUMlwUe-BCo: Downloading MPD manifest
[debug] Default format spec: bestvideo+bestaudio/best
[debug] Invoking downloader on u'https://r6---sn-nx5e6nez.googlevideo.com/videoplayback/id/314325c147be042a/itag/135/source/yt_otf/requiressl/yes/mv/m/initcwndbps/577500/mn/sn-nx5e6nez/mm/31/ms/au/ei/wGeeWZnYCsaK-gOz6IqABQ/pl/42/ratebypass/yes/mime/video%2Fmp4/otfp/1/otf/1/lmt/1503199280912704/mt/1503553359/key/dg_yt0/signature/5E9DD4CEB0B3BE20219357A61FD775E801CC2572.8D23AEAADA473218513380E17ED6D723F848CD51/ip/2602:61:7258:6700:922b:34ff:fe68:94db/ipbits/0/expire/1503575072/sparams/ip,ipbits,expire,id,itag,source,requiressl,mv,initcwndbps,mn,mm,ms,ei,pl,ratebypass,mime,otfp,otf,lmt/'
[dashsegments] Total fragments: 694
[download] Destination: test.mkv.f135
[download] 100% of 55.61MiB in 09:39
[debug] Invoking downloader on u'https://r6---sn-nx5e6nez.googlevideo.com/videoplayback/id/314325c147be042a/itag/140/source/youtube/requiressl/yes/mv/m/initcwndbps/577500/mn/sn-nx5e6nez/mm/31/ms/au/ei/wGeeWZnYCsaK-gOz6IqABQ/pl/42/ratebypass/yes/mime/audio%2Fmp4/otfp/1/gir/yes/clen/58752152/lmt/1503199336601346/dur/3696.454/mt/1503553359/key/dg_yt0/signature/7071082392243203ED387EB8D4748A779135E241.0EB6C6C08D1B7564B01323AF4674CC2B794B9FB6/ip/2602:61:7258:6700:922b:34ff:fe68:94db/ipbits/0/expire/1503575072/sparams/ip,ipbits,expire,id,itag,source,requiressl,mv,initcwndbps,mn,mm,ms,ei,pl,ratebypass,mime,otfp,gir,clen,lmt,dur/'
[dashsegments] Total fragments: 741
[download] Destination: test.mkv.f140
[download] 100% of 56.02MiB in 06:45
[ffmpeg] Merging formats into "test.mkv"
[debug] ffmpeg command line: ffmpeg -y -i 'file:test.mkv.f135' -i 'file:test.mkv.f140' -c copy -map '0:v:0' -map '1:a:0' 'file:test.temp.mkv'
Deleting original file test.mkv.f135 (pass -k to keep)
Deleting original file test.mkv.f140 (pass -k to keep)
<end of log>

Description of your issue, suggested solution and other information

Explanation of your issue in arbitrary form goes here. Please make sure the description is worded well enough to be understood. Provide as much context and examples as possible.
If work on your issue requires account credentials please provide them or explain how one can obtain them.

On one particular video, I find youtube-dl is not selecting the best available video format, despite being set to do so (by default). I haven't seen this happen on other videos; I don't know why this one is special. Here's the format list:

[info] Available formats for MUMlwUe-BCo:
format code  extension  resolution note
139          m4a        audio only DASH audio   63k , m4a_dash container, mp4a.40.5@ 48k (22050Hz)
140          m4a        audio only DASH audio  142k , m4a_dash container, mp4a.40.2@128k (44100Hz)
160          mp4        256x144    DASH video  108k , avc1.4d400b, 30fps, video only
133          mp4        426x240    DASH video  242k , avc1.4d400c, 30fps, video only
134          mp4        640x360    DASH video  297k , avc1.4d401e, 30fps, video only
136          mp4        1280x720   DASH video 1114k , avc1.4d401f, 30fps, video only
135          mp4        854x480    DASH video 1155k , avc1.4d4014, 30fps, video only
17           3gp        176x144    small , mp4v.20.3, mp4a.40.2@ 24k
36           3gp        320x180    small , mp4v.20.3, mp4a.40.2
43           webm       640x360    medium , vp8.0, vorbis@128k
18           mp4        640x360    medium , avc1.42001E, mp4a.40.2@ 96k
22           mp4        1280x720   hd720 , avc1.64001F, mp4a.40.2@192k (best)

Note the presence of format 136, which is better than the 135 youtube-dl selected. It's interesting that 136 comes before 135 in this list.

Also note that the video is a few hours old as I write this, so maybe that has some effect.

@ddawson ddawson changed the title Case of "bestvideo" not selecting the best video format on YouTube video Case of "bestvideo" not selecting best video format on YouTube video Aug 24, 2017
@yan12125
Copy link
Collaborator

@yan12125 yan12125 commented Aug 24, 2017

Currently youtube-dl use bitrates to sort formats instead of resolutions. In this case 135 has 1155k, a bitrate higher than 136's. For previous discussions, please follow #6018. A possible solution at #8125 may be helpful, too.

@yan12125 yan12125 closed this Aug 24, 2017
@glenn-slayden
Copy link
Contributor

@glenn-slayden glenn-slayden commented Sep 6, 2017

This seems very serious to me. Consider the youtube video Ot5jszj_ny8, for which youtube-dl reports the following formats:

format code  extension  resolution note
139          m4a        audio only DASH audio   49k , m4a_dash container, mp4a.40.5@ 48k (22050Hz)
140          m4a        audio only DASH audio  128k , m4a_dash container, mp4a.40.2@128k (44100Hz)
160          mp4        256x144    DASH video  108k , avc1.4d400b, 30fps, video only
134          mp4        640x360    DASH video  117k , avc1.4d401e, 30fps, video only
133          mp4        426x240    DASH video  242k , avc1.4d400c, 30fps, video only
136          mp4        1280x720   DASH video  365k , avc1.4d401f, 30fps, video only
135          mp4        854x480    DASH video 1155k , avc1.4d4014, 30fps, video only
17           3gp        176x144    small , mp4v.20.3, mp4a.40.2@ 24k
36           3gp        320x180    small , mp4v.20.3, mp4a.40.2
43           webm       640x360    medium , vp8.0, vorbis@128k
18           mp4        640x360    medium , avc1.42001E, mp4a.40.2@ 96k
22           mp4        1280x720   hd720 , avc1.64001F, mp4a.40.2@192k (best)

Again, -f bestvideo will download format 135, which, at 854×480, has an actual video bitrate of only 145 kb/s (according to MediaInfo), instead of format 136, which is indeed 1280×720 with a considerably better rate of 169 kb/s. The visual difference is noticeable, even when scaled to the smaller size for comparison.

In other words, the metadata figure of "1155k" is a patent lie, which originates not from YoutubeDL, of course, but rather from YouTube's JSON. Being stuck with these bugs, is there any way to detect these situations where the metadata makes blatantly incredulous claims such as in this case, a format with 55% fewer pixels supposedly having a bitrate 3x higher?

I notice that the OP's example also contains a bitrate report for format 135 which has the same value as mine, "1155k". Is this a specific bug value from YouTube that can always be discredited? Continuing with the OP example, I just checked, and the value "1114k" reported for format 136 is incorrect also: MUMlwUe-BCo.f136.mp4 has an actual bitrate of 128 kb/s, not "1114".

Again, is it possible that, for formats 135 and 136 (others?), any JSON tbr values that start with "11xx" should be ignored, thus causing the "bestvideo" selection to defer to another heuristic?

@glenn-slayden
Copy link
Contributor

@glenn-slayden glenn-slayden commented Sep 7, 2017

Created new issue for this (and further findings) #14143

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

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.