Streaming Youtube to a file.

About encoding, codec settings, muxers and filter usage
sgparry
New Cone
New Cone
Posts: 9
Joined: 07 Feb 2013 00:20

Streaming Youtube to a file.

Postby sgparry » 07 Feb 2013 00:48

Hi,
Please help!
I am trying to write a simple batch file that will allow me to use VLC to stream a youtube video from a provided playlist to a file with no transcoding. The playlists contain the normal youtube http://www.youtube.com/watch? urls. They playback fine in VLC, but when I attempt to stream them, either through the GUI or the command line I get nothing. The videos are VP80/vorb based and it seems impossible to find a mux that will accept these. I've tried ts,ps,mp4,ffmpeg{mux=webm}, you name it. What mux should I be using? Here is a sample command line:

Code: Select all

vlc --intf=rc "http://www.youtube.com/watch?feature=player_detailpage&v=gXKRwv5xF5c" --sout #std{access=file,mux=ts,dst=test.mp4} vlc://quit
And here is typical output

Code: Select all

[004c6a30] oldrc interface: VLC media player - 2.0.5 Twoflower [004c6a30] oldrc interface: Copyright © 1996-2012 VLC authors and VideoLAN [004c6a30] oldrc interface: Warning: if you cannot access the GUI anymore, open a command-line window, go to the directory where you installed VLC and run "vlc -I qt" Remote control interface initialized. Type `help' for help. [004509c0] main playlist: stopping playback MKV/Ebml Parser: m_el[mi_level] == NULL MKV/Ebml Parser: Up cannot escape itself [00510700] main mux error: cannot add this stream [04[00510700] 5fmain mux error: 14cannot add this stream80] main decoder error: [cannot create packetizer output (vorb) 04631ca8] main decoder error: cannot create packetizer output (VP80)
Thanks in advance
sgparry

sgparry
New Cone
New Cone
Posts: 9
Joined: 07 Feb 2013 00:20

Re: Streaming Youtube to a file.

Postby sgparry » 07 Feb 2013 18:40

Update: after further investigation, it becomes clear the format VLC downloads in response to a Youtube URL by default is webm=VP80+ogg vorbis. However I can't find a mux that does not explode in trying to handle this. Typically both webm and ffmpeg{mux=webm} give errors like this:

Code: Select all

[webm @ 04ca8140] Codec for stream 0 does not use global headers but container f ormat requires global headers [webm @ 04ca8140] Aspect ratio mismatch between muxer (0/0) and encoder layer (0 /0) [04d4ede0] avcodec mux error: could not write header: Specified event object han dle is invalid
What am I doing wrong please?

sgparry
New Cone
New Cone
Posts: 9
Joined: 07 Feb 2013 00:20

Re: Streaming Youtube to a file.

Postby sgparry » 08 Feb 2013 03:33

OK, I have fixed this myself. The key here is the creative use of demuxers, without using sout at all:

Code: Select all

vlc --intf=rc someplaylist.xspf :demux=playlist,luaplaylist,dump :demuxdump-file=output.webm vlc://quit
The first demuxer (playlist) reads the xspf. The xspf contains the http://www.youtube.com/watch?... url
The second demuxer munges the watch url into a short-lived youtube streaming url
The third demuxer is the 'dump raw input' demuxer - this dumps the untouched stream to the webm file.
The hard part was realising you can chain demuxers using commas and finding the right demuxers. Fortunately I speak C++ and can use findstr!

You could use this approach with a url directly in the command-line, leaving out playlist from the list of muxers.

40k
New Cone
New Cone
Posts: 2
Joined: 14 Mar 2013 23:30

Re: Streaming Youtube to a file.

Postby 40k » 15 Mar 2013 09:06

OK, I have fixed this myself. The key here is the creative use of demuxers, without using sout at all:

Code: Select all

vlc --intf=rc someplaylist.xspf :demux=playlist,luaplaylist,dump :demuxdump-file=output.webm vlc://quit
The first demuxer (playlist) reads the xspf. The xspf contains the http://www.youtube.com/watch?... url
The second demuxer munges the watch url into a short-lived youtube streaming url
The third demuxer is the 'dump raw input' demuxer - this dumps the untouched stream to the webm file.
The hard part was realising you can chain demuxers using commas and finding the right demuxers. Fortunately I speak C++ and can use findstr!

You could use this approach with a url directly in the command-line, leaving out playlist from the list of muxers.
Thanks a lot for this information sgparry. Is there any chance you can explain a bit more about demuxers? The VLC wiki and documentation is strangely lacking about this. Is it possible to demux the metadata out of the raw Youtube stream?

40k
New Cone
New Cone
Posts: 2
Joined: 14 Mar 2013 23:30

Re: Streaming Youtube to a file.

Postby 40k » 29 Mar 2013 04:52

I have discovered that you can actually bypass the lua script for getting the Youtube video URL. By default the lua script only gets the highest quality video which is often in webm format.

Once you get the Youtube video URL you can use the streaming wizard in VLC to find what command line you will require to dump the stream to a file. You will probably have to use a scripting language that supports regular expressions because it takes a lot of operations to build the video URL from what you can find in the Youtube source code.

I'm developing a script that works with Xyplorer, a file manager for windows, that does the work for you.
http://www.xyplorer.com/xyfc/viewtopic. ... 694a102215

Jean-Baptiste Kempf
Site Administrator
Site Administrator
Posts: 37523
Joined: 22 Jul 2005 15:29
VLC version: 4.0.0-git
Operating System: Linux, Windows, Mac
Location: Cone, France
Contact:

Re: Streaming Youtube to a file.

Postby Jean-Baptiste Kempf » 01 Apr 2013 19:19

There is an option to select the quality, in VLC.
Jean-Baptiste Kempf
http://www.jbkempf.com/ - http://www.jbkempf.com/blog/category/Videolan
VLC media player developer, VideoLAN President and Sites administrator
If you want an answer to your question, just be specific and precise. Don't use Private Messages.


Return to “VLC stream-output (sout)”

Who is online

Users browsing this forum: No registered users and 14 guests