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

Stream to vlc #2124

Closed
ston3o opened this Issue Jan 9, 2014 · 26 comments

Comments

Projects
None yet
@ston3o

ston3o commented Jan 9, 2014

Streaming video to vlc.

@phihag

This comment has been minimized.

Collaborator

phihag commented Jan 9, 2014

Sorry, I don't understand. Could you elaborate and provide some context? You can run vlc just fine on the downloaded files, or output the video to stdout with -o -.

@ingwinlu

This comment has been minimized.

ingwinlu commented Jan 11, 2014

if you want to stream youtube directly to vlc, without a temporary file, just use the built in support for it in vlc:
"vlc youtubelink"

for example:
vlc http://www.youtube.com/watch?v=C0DPdy98e4c

@nodiscc

This comment has been minimized.

nodiscc commented Jan 15, 2014

If you are running a GNU/Linux system, you can stream videos directly to your favorite media player by using youtube-dl -o - "http://your.media/url" | mplayer -

You can also set up a function in your ~/.bash_aliases file like

function streamer() {
youtube-dl -o - "$1" | mplayer - 
}

and run it like streamer http://your.media/url. You can of course replace mplayer with another player command, like vlc.

Side note to the devs: maybe this should be made a command line switch? Like youtube-dl --stream? Let the user set a favorite player in the confg file, or try a list of known players?

If you're not interested maybe this ticket can be closed.

@joeschmoe40

This comment has been minimized.

joeschmoe40 commented Jan 24, 2014

[quote]
if you want to stream youtube directly to vlc, without a temporary file, just use the built in support for it in vlc:
"vlc youtubelink"

for example:
vlc http://www.youtube.com/watch?v=C0DPdy98e4c
[/quote]

I believe that you have to use the "real" URL with VLC, not the "Web URL".
So, you have to run youtube-dl with the "-j" option, to translate the web url to the "real" URL, then pass that URL to VLC.

@pvdl

This comment has been minimized.

Contributor

pvdl commented Mar 7, 2015

The "point" is to use youtube-dl as a wrapper for streams which uses a token.
@nodiscc made a really a nice solution to manage that!

@Avbrella

This comment has been minimized.

Avbrella commented Apr 30, 2015

I second @nodiscc regarding the --stream option, and had a particular use-case in mind.

@walidsa3d

This comment has been minimized.

walidsa3d commented Jul 19, 2015

A --stream option would be great

@Vrihub

This comment has been minimized.

Contributor

Vrihub commented Nov 30, 2015

I'm trying the "-o -" solution, but with some websites (e.g. periscope) it doesn't work: I get the stream saved to a file named "-". Is this expected behaviour (due to limitations of some website or video format), or is it a bug in that particular extractor?

@moorchegue

This comment has been minimized.

moorchegue commented Mar 31, 2016

+1 to the last question

@yan12125

This comment has been minimized.

Collaborator

yan12125 commented Mar 31, 2016

This feature indeed needs some extra codes for live streams. (m3u8 from periscope, etc.)

@yan12125 yan12125 added the request label Mar 31, 2016

@remitamine

This comment has been minimized.

Collaborator

remitamine commented Mar 31, 2016

this patch will make them work as well:

diff --git a/youtube_dl/downloader/external.py b/youtube_dl/downloader/external.py
index 30277dc..cda39fe 100644
--- a/youtube_dl/downloader/external.py
+++ b/youtube_dl/downloader/external.py
@@ -225,7 +225,7 @@ class FFmpegFD(ExternalFD):

         args += ['-i', url, '-c', 'copy']
         if protocol == 'm3u8':
-            if self.params.get('hls_use_mpegts', False):
+            if self.params.get('hls_use_mpegts', False) or tmpfilename == '-':
                 args += ['-f', 'mpegts']
             else:
                 args += ['-f', 'mp4', '-bsf:a', 'aac_adtstoasc']
@@ -235,7 +235,10 @@ class FFmpegFD(ExternalFD):
             args += ['-f', EXT_TO_OUT_FORMATS.get(info_dict['ext'], info_dict['ext'])]

         args = [encodeArgument(opt) for opt in args]
-        args.append(encodeFilename(ffpp._ffmpeg_filename_argument(tmpfilename), True))
+        if tmpfilename == '-':
+            args.append('pipe:1')
+        else:
+            args.append(encodeFilename(ffpp._ffmpeg_filename_argument(tmpfilename), True))

         self._debug_cmd(args)

tested with mplayer, mpv in urls that return encrypted or live m3u8 manifests (should work with others):

python __main__.py -q -o - video_url | mplayer -

@yan12125 yan12125 referenced this issue Apr 14, 2016

Closed

-o - (stdout) not working for twitch.tv #9183

4 of 8 tasks complete

remitamine added a commit that referenced this issue Apr 16, 2016

Merge pull request #9195 from remitamine/ffmpeg-pipe
[downloader/external] enable piping for FFmpegFD(closes #2124)
@besweeet

This comment has been minimized.

besweeet commented May 26, 2016

Any updates about this? Would love to get 60FPS livestreams pumped directly into VLC, as livestreamer doesn't support DASH.

@yan12125

This comment has been minimized.

Collaborator

yan12125 commented May 26, 2016

DASH should be supported. Any problems/errors?

@besweeet

This comment has been minimized.

besweeet commented May 26, 2016

For livestreamer? I'm just not sure of any way to select qualities other than the usual "audio_webm, audio_mp4, 144p (worst), 240p, 360p, 720p (best)" options. These are all the general <30FPS choices.

@yan12125

This comment has been minimized.

Collaborator

yan12125 commented May 26, 2016

Which video are you trying? Please give a concrete URL.

@besweeet

This comment has been minimized.

besweeet commented May 26, 2016

@yan12125

This comment has been minimized.

Collaborator

yan12125 commented May 26, 2016

I was wrong - such DASH support is not implemented yet. Please follow #5563 instead for that.

@gravyboat gravyboat referenced this issue Sep 17, 2016

Closed

youtube-dl? #7

@baptx

This comment has been minimized.

baptx commented Nov 13, 2016

Is there no option to stream and save the video at the same time?
The output .mp4.part files can't be played while there are downloaded so I have to use a hack like this:
youtube-dl "https://www.youtube.com/c/FRANCE24English/live" -o - | cat - > replay.mp4

@yan12125

This comment has been minimized.

Collaborator

yan12125 commented Nov 13, 2016

The output .mp4.part files can't be played

Could you try: --hls-use-mpegts

@baptx

This comment has been minimized.

baptx commented Nov 14, 2016

@yan12125 thanks, it works but I would like the output file named "replay.mp4" instead of "replay.mp4.part" while I stream. Is there a way to do this?
Edit: resolved, I just found we can use --part option so it becomes youtube-dl "https://www.youtube.com/c/FRANCE24English/live" --hls-use-mpegts --no-part -o replay.mp4 :)

@tuxayo

This comment has been minimized.

tuxayo commented Dec 14, 2016

@baptx Thanks, that what I needed, it seems that your solution is the only one that:

  • downloads the audio and video at the same time which makes it usable before it finishes downloading (--hls-use-mpegts --no-part doesn't)
  • creates a file so one can move forward and backward in the video (youtube-dl URL_HERE -o - | vlc - doesn't )

It can be shortened to:
youtube-dl https://www.youtube.com/watch?v=oHg5SJYRHA0 -o - > replay.mp4

Does anyone know how to not have to start VLC separately while keeping the two beforementioned properties?

@yan12125

This comment has been minimized.

Collaborator

yan12125 commented Dec 14, 2016

Try this: youtube-dl URL_HERE -o - | tee replay.mp4 | vlc -

@tuxayo

This comment has been minimized.

tuxayo commented Dec 14, 2016

@yan12125 VLC is still reading only from stdin and therefore can't move forward and backward in the video.

@yan12125

This comment has been minimized.

Collaborator

yan12125 commented Dec 14, 2016

@tuxayo I see your problem. Such a need is complicated and I guess a script is inevitable:

import subprocess
import youtube_dl


player_run = False
p = None


def hook(status):
    global player_run, p

    if not player_run:
        player_run = True
        p = subprocess.Popen(['vlc', status['filename']])


opts = {
    'format': 'best',
    'nopart': True,
    'progress_hooks': [hook],
    'verbose': True,
}

with youtube_dl.YoutubeDL(opts) as ydl:
    ydl.download(['https://www.youtube.com/watch?v=oHg5SJYRHA0'])

p.wait()
@tuxayo

This comment has been minimized.

tuxayo commented Dec 16, 2016

@yan12125 Awesome thanks! Great to see that youtube_dl is so flexible.

@siutin

This comment has been minimized.

siutin commented Aug 11, 2018

Hi everyone, I wondering if it is possible to stream a playlist to vlc?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment