ytdl-org / youtube-dl

Command-line program to download videos from YouTube.com and other video sites
http://ytdl-org.github.io/youtube-dl/
The Unlicense
131.98k stars 10.01k forks source link

youtube-dl should be able to execute last ffmpeg command in stream #8269

Open bertho-zero opened 8 years ago

bertho-zero commented 8 years ago

I would like to know if is possible to add a parameter (e.g: --stream) for execute the last ffmpeg command with the argument pipe:1 instead of file:xxx.

The utility of this argument is that we can make on-the-fly conversion.

For example:

python main.py -v -x --audio-format mp3 'https://www.youtube.com/watch?v=oavMtUWDBTM' [debug] System config: [] [debug] User config: [] [debug] Command-line args: [u'-v', u'-x', u'--audio-format', u'mp3', u'https://www.youtube.com/watch?v=oavMtUWDBTM'] [debug] Encodings: locale UTF-8, fs UTF-8, out UTF-8, pref UTF-8 [debug] youtube-dl version 2016.01.15 [debug] Git HEAD: a2badb1 [debug] Python version 2.7.10 - Linux-4.2.0-23-generic-x86_64-with-Ubuntu-15.10-wily [debug] exe versions: ffmpeg 2.7.4-0ubuntu0.15.10.1, ffprobe 2.7.4-0ubuntu0.15.10.1 [debug] Proxy map: {} [youtube] oavMtUWDBTM: Downloading webpage [youtube] oavMtUWDBTM: Downloading video info webpage [youtube] oavMtUWDBTM: Extracting video information [youtube] oavMtUWDBTM: Downloading DASH manifest [youtube] oavMtUWDBTM: Downloading DASH manifest [debug] Invoking downloader on ... [.........] [download] Mr. Trololo original upload-oavMtUWDBTM.m4a has already been downloaded [download] 100% of 4.91MiB [ffmpeg] Correcting container in "Mr. Trololo original upload-oavMtUWDBTM.m4a" [debug] ffmpeg command line: ffmpeg -y -i 'file:Mr. Trololo original upload-oavMtUWDBTM.m4a' -c copy -f mp4 'file:Mr. Trololo original upload-oavMtUWDBTM.temp.m4a' [debug] ffmpeg command line: ffprobe -showstreams 'file:Mr. Trololo original upload-oavMtUWDBTM.m4a' [ffmpeg] Destination: Mr. Trololo original upload-oavMtUWDBTM.mp3 [debug] ffmpeg command line: ffmpeg -y -i 'pipe:1'_ -vn -acodec libmp3lame -q:a 5 'file:Mr. Trololo original upload-oavMtUWDBTM.mp3' Deleting original file Mr. Trololo original upload-oavMtUWDBTM.m4a (pass -k to keep)

become:

python main.py -v -x --audio-format mp3 'https://www.youtube.com/watch?v=oavMtUWDBTM' [debug] System config: [] [debug] User config: [] [debug] Command-line args: [u'-v', u'-x', u'--audio-format', u'mp3', u'https://www.youtube.com/watch?v=oavMtUWDBTM'] [debug] Encodings: locale UTF-8, fs UTF-8, out UTF-8, pref UTF-8 [debug] youtube-dl version 2016.01.15 [debug] Git HEAD: a2badb1 [debug] Python version 2.7.10 - Linux-4.2.0-23-generic-x8664-with-Ubuntu-15.10-wily [debug] exe versions: ffmpeg 2.7.4-0ubuntu0.15.10.1, ffprobe 2.7.4-0ubuntu0.15.10.1 [debug] Proxy map: {} [youtube] oavMtUWDBTM: Downloading webpage [youtube] oavMtUWDBTM: Downloading video info webpage [youtube] oavMtUWDBTM: Extracting video information [youtube] oavMtUWDBTM: Downloading DASH manifest [youtube] oavMtUWDBTM: Downloading DASH manifest [debug] Invoking downloader on ... [.........] [debug] ffmpeg command line: ffmpeg -y -i 'pipe:1'_ -vn -acodec libmp3lame -q:a 5 'pipe:1' Deleting original file Mr. Trololo original upload-oavMtUWDBTM.m4a (pass -k to keep)

That would be really cool and it would help me a lot for a personal project, thank you in advance.

bertho-zero commented 8 years ago

It's a little like -o - parameter but for ffmpeg.

asdfgasdfsafgsdfa commented 8 years ago

I'd need that as well. Is it possible yet to let youtube-dl stream directly into ffmpeg to write a .mp3 file directly (mp3 is just an example).

I really cant use youtube-dl like I want because the -x only operates on a finished file. But its not possible to completely download a radio stream or twitch or so because they are practically infinite length.

youtube-dl should use ffmpeg to convert, using stdin/stdout so it continously writes to the file and we can start using the audio file while data is still being written to it.

Please make this possible! @rg3

bertho-zero commented 7 years ago

Any news of this ?

jnm2 commented 6 years ago

I'd find this very helpful as well.

a-x- commented 5 years ago

I want to extract audio from video streams too.

youtube-dl -x -o - vAKtNV8KcWg | node pipe.js

youtube-dl: error: Cannot download a video and extract audio into the same file! Use "-.%(ext)s" instead of "-" as the output template
pipe.js isn't interesting here, but... ```js express = require('express') const app = express() const port = 5556 app.get('/', (req, res) => process.stdin.pipe(res)) app.listen(port, () => console.log(`Example app listening on port ${port}!`)) ```