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

Piping to stdout writes to a file instead of stdout with some format specifier #11029

Open
desbma opened this issue Oct 25, 2016 · 3 comments
Open
Labels
bug

Comments

@desbma
Copy link

@desbma desbma commented Oct 25, 2016

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 that [x])
  • Use Preview tab to see how your issue will actually look like

Make sure you are using the latest version: run youtube-dl --version and ensure your version is 2016.10.25. 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 2016.10.25

Before submitting an issue make sure you have:

  • At least skimmed through README and most notably 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

Piping to stdout does not work when using format bestvideo+bestaudio/best. It downloads to a file named -.ext.

For example :
$ youtube-dl -v -f bestvideo+bestaudio/best -o - 'https://www.youtube.com/watch?v=0YSEagC7tsI' | mpv

It works without the above format specifier although ironically it is documented to be the default.

I noticed this because I have -f bestvideo[width<=?1920]+bestaudio/best in my youtube-dl config file, but I expected it to use the format which does not require merging when piping.

@yan12125 yan12125 added the bug label Oct 28, 2016
@Skymirrh
Copy link

@Skymirrh Skymirrh commented Oct 30, 2016

I am not sure this is actually a bug. Excerpt from the FAQ:

Note that if you use youtube-dl to stream to stdout (and most likely to pipe it to your media player then), i.e. you explicitly specify output template as -o -, youtube-dl still uses -f best format selection in order to start content delivery immediately to your player and not to wait until bestvideo and bestaudio are downloaded and muxed.

If my understanding is correct, this means youtube-dl will always use -f best when -o - is set. If that is the case, then this issue is void but I think we do have uncovered another one.

Here is the behaviour I reproduce using version 2016.10.26:

  • Source video: https://www.youtube.com/watch?v=a0pVCoOHXkA (best quality available: 2160p)
  • Not setting any format nor -o - will correctly download bestvideo+bestaudio (aka 2160p) and mux using ffmpeg. [Sample 1]
  • Not setting any format but setting -o - will correctly download best (aka 720p) and stream it to an external player. [Sample 2]
  • Trying to force any format with -o - set apparently overrides the above -o - detection pattern:
    • If chosen format requires muxing, then it will mux to a file named -.ext. [Sample 3]
    • If chosen format does not require muxing, then it will stream correctly. [Sample 4]

Sample 1

C:\Users\Skymirrh>youtube-dl -v https://www.youtube.com/watch?v=a0pVCoOHXkA
[debug] System config: []
[debug] User config: []
[debug] Command-line args: [u'-v', u'https://www.youtube.com/watch?v=a0pVCoOHXkA']
[debug] Encodings: locale cp1252, fs mbcs, out cp850, pref cp1252
[debug] youtube-dl version 2016.10.26
[debug] Python version 2.7.10 - Windows-8-6.2.9200
[debug] exe versions: ffmpeg 3.1.5, ffprobe 3.1.5
[debug] Proxy map: {}
[youtube] a0pVCoOHXkA: Downloading webpage
[youtube] a0pVCoOHXkA: Downloading video info webpage
[youtube] a0pVCoOHXkA: Extracting video information
[youtube] a0pVCoOHXkA: Downloading MPD manifest
[debug] Invoking downloader on u'https://r3---sn-n4g-ouxl.googlevideo.com/videoplayback?id=6b4a550a83875e40&itag=266&source=youtube&requiressl=yes&mv=m&initcwndbps=2612500&pl=26&ms=au&mm=31&mn=sn-n4g-ouxl&ratebypass=yes&mime=video/mp4&gir=yes&clen=494559241&lmt=1475244314252943&dur=182.415&upn=gYfexa4Njnw&key=dg_yt0&mt=1477807007&signature=0AA0A7CD3DBEAE6701A58F2F5AD66EA65A534960.70050BE21BFEBA9EA7E8C68F82FC59BF675857B8&ip=109.8.218.98&ipbits=0&expire=1477828691&sparams=ip,ipbits,expire,id,itag,source,requiressl,mv,initcwndbps,pl,ms,mm,mn,ratebypass,mime,gir,clen,lmt,dur'
[download] Destination: Titanfall 2 - Official Nvidia 4K PC Multiplayer Gameplay-a0pVCoOHXkA.f266.mp4
[download] 100% of 471.65MiB in 00:41
[debug] Invoking downloader on u'https://r3---sn-n4g-ouxl.googlevideo.com/videoplayback?id=6b4a550a83875e40&itag=140&source=youtube&requiressl=yes&mv=m&initcwndbps=2612500&pl=26&ms=au&mm=31&mn=sn-n4g-ouxl&ratebypass=yes&mime=audio/mp4&gir=yes&clen=2899389&lmt=1475244461425945&dur=182.508&upn=gYfexa4Njnw&key=dg_yt0&mt=1477807007&signature=8ECD8C007E50FF46C5FDCF47AB1DEA3782F00A7B.35FF07F707719A1B31B030F440E311CF74E025CC&ip=109.8.218.98&ipbits=0&expire=1477828691&sparams=ip,ipbits,expire,id,itag,source,requiressl,mv,initcwndbps,pl,ms,mm,mn,ratebypass,mime,gir,clen,lmt,dur'
[download] Destination: Titanfall 2 - Official Nvidia 4K PC Multiplayer Gameplay-a0pVCoOHXkA.f140.m4a
[download] 100% of 2.77MiB in 00:00
[ffmpeg] Merging formats into "Titanfall 2 - Official Nvidia 4K PC Multiplayer Gameplay-a0pVCoOHXkA.mp4"
[debug] ffmpeg command line: ffmpeg -y -i 'file:Titanfall 2 - Official Nvidia 4K PC Multiplayer Gameplay-a0pVCoOHXkA.f266.mp4' -i 'file:Titanfall 2 - Official Nvidia 4K PC Multiplayer Gameplay-a0pVCoOHXkA.f140.m4a' -c copy -map 0:v:0 -map 1:a:0 'file:Titanfall 2 - Official Nvidia 4K PC Multiplayer Gameplay-a0pVCoOHXkA.temp.mp4'
Deleting original file Titanfall 2 - Official Nvidia 4K PC Multiplayer Gameplay-a0pVCoOHXkA.f266.mp4 (pass -k to keep)
Deleting original file Titanfall 2 - Official Nvidia 4K PC Multiplayer Gameplay-a0pVCoOHXkA.f140.m4a (pass -k to keep)

Sample 2

C:\Users\Skymirrh>youtube-dl -v https://www.youtube.com/watch?v=a0pVCoOHXkA -o - | mpc-hc64 -
[debug] System config: []
[debug] User config: []
[debug] Command-line args: [u'-v', u'https://www.youtube.com/watch?v=a0pVCoOHXkA', u'-o', u'-']
[debug] Encodings: locale cp1252, fs mbcs, out None, pref cp1252
[debug] youtube-dl version 2016.10.26
[debug] Python version 2.7.10 - Windows-8-6.2.9200
[debug] exe versions: ffmpeg 3.1.5, ffprobe 3.1.5
[debug] Proxy map: {}
[youtube] a0pVCoOHXkA: Downloading webpage
[youtube] a0pVCoOHXkA: Downloading video info webpage
[youtube] a0pVCoOHXkA: Extracting video information
[youtube] a0pVCoOHXkA: Downloading MPD manifest
[debug] Invoking downloader on u'https://r3---sn-n4g-ouxl.googlevideo.com/videoplayback?signature=3116C14A6EE185A242DD7FEECF5BAAC68F01EF12.BEECE2FFE40F90E2EE756A5E8A0D44BA395F7CC0&id=o-ANWfOlbIKJTq0tylZrijw6D9rOhiZk16Y8S5N8ASY-xJ&mv=m&upn=EoR1c0xD36Q&mt=1477806378&ms=au&mn=sn-n4g-ouxl&ip=109.8.218.98&mm=31&itag=22&pl=26&key=yt6&mime=video%2Fmp4&dur=182.508&ratebypass=yes&requiressl=yes&initcwndbps=2625000&source=youtube&ei=84kVWKPZH-T8iAbXk7fQAg&lmt=1475245834826510&sparams=dur%2Cei%2Cid%2Cinitcwndbps%2Cip%2Cipbits%2Citag%2Clmt%2Cmime%2Cmm%2Cmn%2Cms%2Cmv%2Cpl%2Cratebypass%2Crequiressl%2Csource%2Cupn%2Cexpire&ipbits=0&expire=1477828179'
[download] Destination: -
[download]  11.7% of 50.56MiB at 457.21KiB/s ETA 01:39

Sample 3

C:\Users\Skymirrh>youtube-dl -v -f bestvideo+bestaudio/best https://www.youtube.com/watch?v=a0pVCoOHXkA -o - | mpc-hc64 -
[debug] System config: []
[debug] User config: []
[debug] Command-line args: [u'-v', u'-f', u'bestvideo+bestaudio/best', u'https://www.youtube.com/watch?v=a0pVCoOHXkA', u'-o', u'-']
[debug] Encodings: locale cp1252, fs mbcs, out None, pref cp1252
[debug] youtube-dl version 2016.10.26
[debug] Python version 2.7.10 - Windows-8-6.2.9200
[debug] exe versions: ffmpeg 3.1.5, ffprobe 3.1.5
[debug] Proxy map: {}
[youtube] a0pVCoOHXkA: Downloading webpage
[youtube] a0pVCoOHXkA: Downloading video info webpage
[youtube] a0pVCoOHXkA: Extracting video information
[youtube] a0pVCoOHXkA: Downloading MPD manifest
[debug] Invoking downloader on u'https://r3---sn-n4g-ouxl.googlevideo.com/videoplayback?id=6b4a550a83875e40&itag=266&source=youtube&requiressl=yes&mn=sn-n4g-ouxl&mm=31&initcwndbps=2625000&ms=au&mv=m&pl=26&ratebypass=yes&mime=video/mp4&gir=yes&clen=494559241&lmt=1475244314252943&dur=182.415&key=dg_yt0&signature=488EB2E72958A968E3AA6788368F230CBFAA2D1A.0FA06621EED28C7C425A596C25E1A3300FD6CC01&upn=xx-JdUdzEBQ&mt=1477806378&ip=109.8.218.98&ipbits=0&expire=1477828026&sparams=ip,ipbits,expire,id,itag,source,requiressl,mn,mm,initcwndbps,ms,mv,pl,ratebypass,mime,gir,clen,lmt,dur'
[download] Destination: -.f266
[download] 100% of 471.65MiB in 00:41
[debug] Invoking downloader on u'https://r3---sn-n4g-ouxl.googlevideo.com/videoplayback?id=6b4a550a83875e40&itag=140&source=youtube&requiressl=yes&mn=sn-n4g-ouxl&mm=31&initcwndbps=2625000&ms=au&mv=m&pl=26&ratebypass=yes&mime=audio/mp4&gir=yes&clen=2899389&lmt=1475244461425945&dur=182.508&key=dg_yt0&signature=501276A18181AEACB6C36B40035F83F0397D7E37.814C82F0A6648DFCD6C47137027947445E898F74&upn=xx-JdUdzEBQ&mt=1477806378&ip=109.8.218.98&ipbits=0&expire=1477828026&sparams=ip,ipbits,expire,id,itag,source,requiressl,mn,mm,initcwndbps,ms,mv,pl,ratebypass,mime,gir,clen,lmt,dur'
[download] Destination: -.f140
[download] 100% of 2.77MiB in 00:00
[ffmpeg] Merging formats into "-.mp4"
[debug] ffmpeg command line: ffmpeg -y -i file:-.f266 -i file:-.f140 -c copy -map 0:v:0 -map 1:a:0 file:-.temp.mp4
Deleting original file -.f266 (pass -k to keep)
Deleting original file -.f140 (pass -k to keep)

Sample 4

C:\Users\Skymirrh>youtube-dl -v -f best/bestvideo+bestaudio https://www.youtube.com/watch?v=a0pVCoOHXkA -o - | mpc-hc64 -
[debug] System config: []
[debug] User config: []
[debug] Command-line args: [u'-v', u'-f', u'best/bestvideo+bestaudio', u'https://www.youtube.com/watch?v=a0pVCoOHXkA', u'-o', u'-']
[debug] Encodings: locale cp1252, fs mbcs, out None, pref cp1252
[debug] youtube-dl version 2016.10.26
[debug] Python version 2.7.10 - Windows-8-6.2.9200
[debug] exe versions: ffmpeg 3.1.5, ffprobe 3.1.5
[debug] Proxy map: {}
[youtube] a0pVCoOHXkA: Downloading webpage
[youtube] a0pVCoOHXkA: Downloading video info webpage
[youtube] a0pVCoOHXkA: Extracting video information
[youtube] a0pVCoOHXkA: Downloading MPD manifest
[debug] Invoking downloader on u'https://r3---sn-n4g-ouxl.googlevideo.com/videoplayback?mn=sn-n4g-ouxl&mm=31&id=o-ABz5YfILDOlJMpua1ehbOslGQSoP5qU4WIMOvzDQ7dlq&pl=26&mv=m&ipbits=0&ms=au&ei=QJAVWKjKC-zAiQaToJagDA&ip=109.8.218.98&source=youtube&signature=AA95CFD912FB030D5340424763658D2B8123FF66.5C358740E8E8CB8F27D1B8ACB917CA1F828A1707&sparams=dur%2Cei%2Cid%2Cinitcwndbps%2Cip%2Cipbits%2Citag%2Clmt%2Cmime%2Cmm%2Cmn%2Cms%2Cmv%2Cpl%2Cratebypass%2Crequiressl%2Csource%2Cupn%2Cexpire&itag=22&expire=1477829792&upn=FpOnSHcadQs&key=yt6&mime=video%2Fmp4&initcwndbps=2863750&requiressl=yes&ratebypass=yes&lmt=1475245834826510&dur=182.508&mt=1477808082'
[download] Destination: -
[download]   4.0% of 50.56MiB at  1.58MiB/s ETA 00:30
@yan12125
Copy link
Collaborator

@yan12125 yan12125 commented Oct 30, 2016

this means youtube-dl will always use -f best when -o - is set

The current behavior is: the default value for -f is best use best when -o - is set, and youtube-dl does not check whether merging is suitable or not if -f is specified manually. That's a bug.

@desbma
Copy link
Author

@desbma desbma commented Oct 30, 2016

In my opinion youtube-dl should either:

  • throw an explicit error ("output format incompatible with streaming")
  • automatically choose the first format that does not require merging

Anyway it should never write to a -.ext file if -o - is passed.

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.