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

ytdl falls back to 'best' format even for JSON output when no ffmpeg/avconv #7289

Open
ChrisK2 opened this issue Oct 24, 2015 · 9 comments
Open

Comments

@ChrisK2
Copy link

@ChrisK2 ChrisK2 commented Oct 24, 2015

Title says pretty much everything. This is a problem for mpv. We want to use the youtube DASH streams by default, but the user only gets them if they happen to have ffmpeg or avconv installed.

@ChrisK2 ChrisK2 changed the title ytdl falls back to 'best' format even for JSON output when no ffmpeg/libav ytdl falls back to 'best' format even for JSON output when no ffmpeg/avconv Oct 24, 2015
@dstftw
Copy link
Collaborator

@dstftw dstftw commented Oct 24, 2015

This is expected. Why don't you specify -f explicitly?

@ChrisK2
Copy link
Author

@ChrisK2 ChrisK2 commented Oct 25, 2015

Because youtube-dl's default is already what we want (except when it isn't for reasons that make no sense), so we would like to avoid forcing anything that doesn't need forcing.

@dstftw
Copy link
Collaborator

@dstftw dstftw commented Oct 25, 2015

bestvideo+bestaudio/best is only default when merging is possible from youtube-dl's POV (i.e. ffmpeg or avconv is available), otherwise it's best. That's documented (probably a little ambiguous) in format selection section and makes perfect sense - obviously we don't want end up with separate video and audio after download when no merging possible. JSON for default format is always bound to format selected that's why best is in JSON output when no ffmpeg/avconv available.

@ChrisK2
Copy link
Author

@ChrisK2 ChrisK2 commented Oct 25, 2015

Yes, I totally understand how it comes to this. But since it makes no sense for the JSON output to be influenced by completely irrelevant factors, I'd like you to improve this.

According to the documentation:
bestvideo+bestaudio/bestis the default,
best is the fallback for when the default can't be used.
But for the JSON output the default can always be used just fine.

@dstftw
Copy link
Collaborator

@dstftw dstftw commented Oct 25, 2015

No, that makes no sense. How one would guess what format(s) has(ve) been downloaded by default when no ffmpeg/avconv is available if JSON will contain data for bestvideo+bestaudio? As I've already mentioned JSON data for default format(s) is always bound to downloaded format(s) and changing this behavior will break clients relying on this.

@ChrisK2
Copy link
Author

@ChrisK2 ChrisK2 commented Oct 25, 2015

After some discussion with @dstftw via IRC PM ...

The point @dstftw was trying to make was that the JSON info should match the actual download behaviour, since 3rd party applications may use the JSON output to gather further information on what youtube-dl downloaded.

However, if we just added or not download to YoutubeDL.py#L1320 , everything should still be fine, since the bestvideo+bestaudio format would only kick in if nothing is downloaded (as with -J, which mpv uses). 3rd party front-end applications would hopefully be using --print-json or --write-info-json to gather the info in the same run as the download, in which case the JSON info would be consistent with the download behaviour.

HOWEVER, the manual specifically states "Simulate" for the -J (and all other "info only") option, which implies identical behaviour to an actual download. The simple solution would be to just re-word the manual to use something like "don't download" instead of "simulate". Otherwise we'd need a second -J option which does format-selection free from any downloading constraints (like the presence of ffmpeg).

 

Ooor ... we can just always force bestvideo+bestaudio/best in mpv, but seeing how in that above code section youtube-dl itself invokes bestvideo+bestaudio only for specific extractors, We'd like to leave the format-selection to youtube-dl as far as possible.

@jaimeMF
Copy link
Collaborator

@jaimeMF jaimeMF commented Oct 25, 2015

However, if we just added or not download to YoutubeDL.py#L1320 , everything should still be fine

Is not that simple, download is always True when calling youtube-dl you have to look into params['simulate'] instead (it's not too intuitive, but that's how it currently works). We could just set it to False if you use -J, but personally I think that -J should have a similar behaviour to -j, which should be like --print-json but without downloading the video.

Ooor ... we can just always force bestvideo+bestaudio/best in mpv, but seeing how in that above code section youtube-dl itself invokes bestvideo+bestaudio only for specific extractors, We'd like to leave the format-selection to youtube-dl as far as possible.

I would probably safe to use bestvideo+bestaudio/best, but as you said it would be quite reasonable if youtube-dl exposed a way to use the same logic. Maybe add a flag --allow-dash-formats which would force it even if ffmpeg/avconv is not installed?

@ChrisK2
Copy link
Author

@ChrisK2 ChrisK2 commented Oct 25, 2015

Maybe add a flag --allow-dash-formats which would force it even if ffmpeg/avconv is not installed?

Would be fine, but maybe label it the other way round like --no-postprocessor-check, in case the ffmpeg check might affect other parts in the future. Or maybe more generally: --player-mode, which makes it clear that youtube-dl is not invoked with the intention of downloading/postprocessing anything and that we pretty much just want the extractor info as-is.

@wp9015362
Copy link

@wp9015362 wp9015362 commented Nov 5, 2015

+1

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
4 participants
You can’t perform that action at this time.