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

Reliable way of getting video and audio containing formats from JSON #4373

Closed
5 of 7 tasks
christoph-heinrich opened this issue Jul 18, 2022 · 4 comments
Closed
5 of 7 tasks
Labels
docs/meta/cleanup related to docs, code cleanup, templates, devscripts etc question Question

Comments

@christoph-heinrich
Copy link
Contributor

christoph-heinrich commented Jul 18, 2022

Checklist

  • I'm asking a question and not reporting a bug or requesting a feature
  • I've looked through the README
  • I've verified that I'm running yt-dlp version 2022.06.29 (update instructions) or later (specify commit)
  • I've searched the bugtracker for similar questions including closed ones. DO NOT post duplicates
  • I've read the guidelines for opening an issue

Please make sure the question is worded well enough to be understood

I am currently working on the ytdl_hook from mpv.
It runs yt-dlp with -J and then parses the JSON.
Currently it just assumes that everything that doesn't have a vcodec set (== null or == 'none') is an audio format. The problem with that is that things like storyboards from YouTube also get recognized as audio formats.

The README says:

ba, bestaudio: Select the best quality audio-only format. Equivalent to best*[vcodec=none]

Indicating that logic to be true.
But the README also says:

ba*, bestaudio*: Select the best quality format that contains audio. It may also contain video. Equivalent to best*[acodec!=none]

Implying that all formats that have audio are guaranteed to have acodec != null and acodec != 'none'.

The README however never states that != null and != none are guaranteed for vcodec or acodec if the format contains video or audio respectively.

Is there a reliable way of getting all the formats containing video and all the formats containing audio without also getting any other formats (e.g. storyboards from YouTube) from the JSON? Also it would be good to know if you know that solution to also work for youtube-dl.

P.S. I'm not a native english speaker, so maybe I'm wrong on this.
The README contains

b*, best*: Select the best quality format that contains either a video or an audio

but I think the word 'either' indicates xor, where as this should be a logical or. I suggest changing it to 'video and/or audio' to make it less ambiguous.

Provide verbose output that clearly demonstrates the problem

  • Run your yt-dlp command with -vU flag added (yt-dlp -vU <your command line>)
  • Copy the WHOLE output (starting with [debug] Command-line config) and insert it below

Complete Verbose Output

No response

@christoph-heinrich christoph-heinrich added the question Question label Jul 18, 2022
@pukkandan
Copy link
Member

if acodec!='none', the format has an audio. Similar for video

Eg:
video-only = vcodec!='none' && acodec=='none'
audio-only = vcodec=='none' && acodec!='none'
pre-merged = vcodec!='none' && acodec!='none'
storyboard = vcodec=='none' && acodec=='none'

PS: null represents that we don't know what the codec is, and is not the same as 'none'


Don't close the issue. I'll take a look at your suggestions about the README later

@pukkandan pukkandan added the docs/meta/cleanup related to docs, code cleanup, templates, devscripts etc label Jul 18, 2022
@christoph-heinrich
Copy link
Contributor Author

Wow that was fast, thank you.

@christoph-heinrich
Copy link
Contributor Author

I just tested it, and unfortunately this still recognizes non video formats from this json as videos. But I guess that just means that yt-dlp just doesn't know that they are not videos.

As a solution to that, I ended up also checking resolution != null and resolution != "audio only", but I guess that wouldn't be a good general solution then.

@pukkandan
Copy link
Member

According to the json given in the issue, yt-dlp thinks they are videos. But I cannot reproduce their result and would need more info to say what exactly is hapenning

christoph-heinrich added a commit to christoph-heinrich/mpv that referenced this issue Jul 18, 2022
Every format that was not detected as a video format was added to the
audio tracks. This resulted in e.g. YouTube storyboards from ending up
in the list of audio tracks.

Now formats that are already known to be neither video formats nor audio
formats, will also not end up in any track list.

yt-dlp/yt-dlp#4373 (comment)
christoph-heinrich added a commit to christoph-heinrich/mpv that referenced this issue Jul 18, 2022
Every format that was not detected as a video format was added to the
audio tracks. This resulted in e.g. YouTube storyboards from ending up
in the list of audio tracks.

Now formats that are already known to be neither video formats nor audio
formats, will also not end up in any track list.

yt-dlp/yt-dlp#4373 (comment)
christoph-heinrich added a commit to christoph-heinrich/mpv-quality-menu that referenced this issue Jul 18, 2022
christoph-heinrich added a commit to christoph-heinrich/mpv that referenced this issue Jul 20, 2022
Every format that was not detected as a video format was added to the
audio tracks. This resulted in e.g. YouTube storyboards from ending up
in the list of audio tracks.

Now formats that are already known to be neither video formats nor audio
formats, will also not end up in any track list.

Formats where it is unknown if they are video or audio get added to
tracks if `force_all_formats` is used, otherwise only
formats that are known to contain video or audio become video or audio
tracks respectively.

yt-dlp/yt-dlp#4373 (comment)
christoph-heinrich added a commit to christoph-heinrich/mpv that referenced this issue Aug 15, 2022
Every format that was not detected as a video format was added to the
audio tracks. This resulted in e.g. YouTube storyboards from ending up
in the list of audio tracks.

Now formats that are already known to be neither video formats nor audio
formats, will also not end up in any track list.

Formats where it is unknown if they are video or audio get added to
tracks if `force_all_formats` is used, otherwise only
formats that are known to contain video or audio become video or audio
tracks respectively.

yt-dlp/yt-dlp#4373 (comment)
Dudemanguy pushed a commit to mpv-player/mpv that referenced this issue Aug 17, 2022
Every format that was not detected as a video format was added to the
audio tracks. This resulted in e.g. YouTube storyboards from ending up
in the list of audio tracks.

Now formats that are already known to be neither video formats nor audio
formats, will also not end up in any track list.

Formats where it is unknown if they are video or audio get added to
tracks if `force_all_formats` is used, otherwise only
formats that are known to contain video or audio become video or audio
tracks respectively.

yt-dlp/yt-dlp#4373 (comment)
Vladdrako pushed a commit to Vladdrako/mpv that referenced this issue Aug 20, 2022
Every format that was not detected as a video format was added to the
audio tracks. This resulted in e.g. YouTube storyboards from ending up
in the list of audio tracks.

Now formats that are already known to be neither video formats nor audio
formats, will also not end up in any track list.

Formats where it is unknown if they are video or audio get added to
tracks if `force_all_formats` is used, otherwise only
formats that are known to contain video or audio become video or audio
tracks respectively.

yt-dlp/yt-dlp#4373 (comment)
alexiscn pushed a commit to alexiscn/mpv that referenced this issue Oct 25, 2022
Every format that was not detected as a video format was added to the
audio tracks. This resulted in e.g. YouTube storyboards from ending up
in the list of audio tracks.

Now formats that are already known to be neither video formats nor audio
formats, will also not end up in any track list.

Formats where it is unknown if they are video or audio get added to
tracks if `force_all_formats` is used, otherwise only
formats that are known to contain video or audio become video or audio
tracks respectively.

yt-dlp/yt-dlp#4373 (comment)
dyphire pushed a commit to dyphire/mpv that referenced this issue Feb 22, 2023
Every format that was not detected as a video format was added to the
audio tracks. This resulted in e.g. YouTube storyboards from ending up
in the list of audio tracks.

Now formats that are already known to be neither video formats nor audio
formats, will also not end up in any track list.

Formats where it is unknown if they are video or audio get added to
tracks if `force_all_formats` is used, otherwise only
formats that are known to contain video or audio become video or audio
tracks respectively.

yt-dlp/yt-dlp#4373 (comment)
dyphire pushed a commit to dyphire/mpv that referenced this issue Feb 22, 2023
Every format that was not detected as a video format was added to the
audio tracks. This resulted in e.g. YouTube storyboards from ending up
in the list of audio tracks.

Now formats that are already known to be neither video formats nor audio
formats, will also not end up in any track list.

Formats where it is unknown if they are video or audio get added to
tracks if `force_all_formats` is used, otherwise only
formats that are known to contain video or audio become video or audio
tracks respectively.

yt-dlp/yt-dlp#4373 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs/meta/cleanup related to docs, code cleanup, templates, devscripts etc question Question
Projects
None yet
Development

No branches or pull requests

2 participants