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

Allow combining formats while writing to stdout #28146

Closed
3 tasks done
redbrain opened this issue Feb 12, 2021 · 6 comments
Closed
3 tasks done

Allow combining formats while writing to stdout #28146

redbrain opened this issue Feb 12, 2021 · 6 comments
Labels

Comments

@redbrain
Copy link

Checklist

  • I'm reporting a feature request
  • I've verified that I'm running youtube-dl version 2021.02.10
  • I've searched the bugtracker for similar feature requests including closed ones

Description

Currently, youtube-dl wil only stream true "best" to stdout.
If a flag like -f bestvideo+bestaudio is specified as well as -o -, it actually makes a file called -.webm instead of streaming.
A quick search shows that this was briefly discussed in #27265.
However, it was quickly dismissed, with the argument that making temp-files (for combining formats) makes stdout worthless.
I believe it's important to allow temp files with stdout, for example, to pipe the output to another program.
Objectively, it seems as if this would be trivial to program as well.
Please let me know if this can/will be implemented.
Also, thanks for your tireless upkeep of youtube-dl, especially through all the legal issues; you don't get enough credit for that.

@redbrain redbrain changed the title [Feature request] Allow combining formats while writing to stdout Allow combining formats while writing to stdout Feb 12, 2021
@pukkandan
Copy link
Contributor

pukkandan commented Feb 16, 2021

Could you explain what is the use-case for this? According to your proposal, youtube-dl will download the files to disk, merge them with ffmpeg and then write the final file to stdout. In that case, why not just use --exec?

@redbrain
Copy link
Author

How could --exec be used to accomplish this?

@pukkandan
Copy link
Contributor

Well, I don't know if your use-case is possible with --exec since you didn't bother to explain it. The uses I can think of does work with it. For example, if you want to pass the file to ffplay, you can do: --exec "ffplay -i {}"

@redbrain
Copy link
Author

My apologies, when opening this feature request I didn't think to explain any specific cases. Here's a contrived example for you.
youtube-dl could be used in Apache+PHP to send the stdout to the web response without filling up disk space over time.
youtube-dl [LINK] -q -f "bestvideo+bestaudio/best" --recode-video mp4 --exec "cat {} && rm {}" works in bash but not in PHP.
Meanwhile, youtube-dl [LINK] -q -f "mp4" -o - works in both bash and PHP.
I'm assuming that php won't read the exec-ed cat as the output, which is what causes it to fail.

@rautamiekka
Copy link
Contributor

rautamiekka commented Feb 17, 2021

^ The one with --exec "cat fails cuz PHP protects against using shell commands for wrong purposes (for any purposes, really). I'm pretty sure even that can be conffed to be allowed, but it's extremely dangerous, so unless you're able to secure the PHP, the Web Server, and the host OS, you shouldn't try that.

You can sorta circumvent the problem of using files by using a queue instead of processing multiple files at once, and placing the file into a RAM disk, meaning a semi-virtual area by mounting a folder using the ramfs filesystem. Apart from the filesystem-independent mount options there're none (I use size=4G,errors=continue,nosuid,async,noatime,nodev,noexec,nodiratime,noiversion,nofail,noguid, but the size= flag doesn't exist in man mount despite working). I don't recommend using tmpfs (https://www.kernel.org/doc/html/latest/filesystems/tmpfs.html) cuz it'll use your swap for backing up the data, at which point you might as well use an actual HDD/SSD for storing the files. I've never tested tmpfs, so I can't tell if the backing up affects the performance, but I guess not cuz some ppl recommend it for speed reasons.

@redbrain
Copy link
Author

Now it's easier to see why muxing doesn't already support stdout; it appears to be more painful than I initially thought.
Temporary storage is probably best for that sort of webserver anyways; after all it was a hypothetical example.
Closing the feature request; it now appears that it's best this is left unchanged.

pukkandan added a commit to yt-dlp/yt-dlp that referenced this issue Aug 1, 2021
For this to work:
1. The downloader must be ffmpeg
2. The selected formats must have the same protocol
3. The formats must be downloadable by ffmpeg to stdout

Partial solution for: ytdl-org/youtube-dl#28146, ytdl-org/youtube-dl#27265
nixxo pushed a commit to nixxo/yt-dlp that referenced this issue Nov 22, 2021
For this to work:
1. The downloader must be ffmpeg
2. The selected formats must have the same protocol
3. The formats must be downloadable by ffmpeg to stdout

Partial solution for: ytdl-org/youtube-dl#28146, ytdl-org/youtube-dl#27265
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants