Audio/video stream recording forums (http://stream-recorder.com/forum/index.php)
-   Video stream recording (http://stream-recorder.com/forum/forumdisplay.php?f=4)
-   -  

How to dump youtube live TV stream to file using commandline?

(http://stream-recorder.com/forum/showthread.php?t=15019)

southz 03-21-2013 09:39 AM

Re: How to dump youtube live TV stream to file using commandline?


 
this seems to be a nice Tool. Due to law restrictions in Germany I have to use a proxy for Live Broadcasts. This Proxy uses authentication with username/pw. Using this toll throws "Error downloading webpage: 407 - Proxy Authentication Required". I haven't found any possible way to authenticate in cmd

magichandz 03-21-2013 07:24 PM

Re: How to dump youtube live TV stream to file using commandline?


 
occasionally i get this message using ffmpeg
"skipping 11 segments ahead, expired from playlists"

do anyone know how to get the right m3u8 file so i get all segments in the final video?

magichandz 03-22-2013 09:37 AM

Re: How to dump youtube live TV stream to file using commandline?


 
Quote:

Originally Posted by southz (Post 60822)
this seems to be a nice Tool. Due to law restrictions in Germany I have to use a proxy for Live Broadcasts. This Proxy uses authentication with username/pw. Using this toll throws "Error downloading webpage: 407 - Proxy Authentication Required". I haven't found any possible way to authenticate in cmd

have you tried "user : pass @ proxyaddress" ?

magichandz 03-22-2013 09:39 AM

Re: How to dump youtube live TV stream to file using commandline?


 
Quote:

Originally Posted by chap (Post 60683)
try
Code:

ffmpeg -i "bla,bla,bla" -c copy -absf aac_adtstoasc t.mp4

this works for changing containers from ts to mp4 after the fact but capturing on the fly i get mixed results.

southz 03-22-2013 09:24 PM

Re: How to dump youtube live TV stream to file using commandline?


 
Quote:

Originally Posted by magichandz (Post 60856)
have you tried "user : pass @ proxyaddress" ?

yeah.. win won't do this... im tryin this on my debian machine right now.. youtube-dl aborts with ERROR: no conn or url_encoded_fmt_stream_map information found in video info

Quote:

Originally Posted by shell
File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/usr/bin/youtube-dl/__main__.py", line 17, in <module>
youtube_dl.main()
File "/usr/bin/youtube-dl/youtube_dl/__init__.py", line 514, in main
_real_main()
File "/usr/bin/youtube-dl/youtube_dl/__init__.py", line 498, in _real_main
retcode = fd.download(all_urls)
File "/usr/bin/youtube-dl/youtube_dl/FileDownloader.py", line 508, in download
videos = ie.extract(url)
File "/usr/bin/youtube-dl/youtube_dl/InfoExtractors.py", line 93, in extract
return self._real_extract(url)
File "/usr/bin/youtube-dl/youtube_dl/InfoExtractors.py", line 560, in _real_extract
self._downloader.trouble(u'ERROR: no conn or url_encoded_fmt_stream_map information found in video info')
File "/usr/bin/youtube-dl/youtube_dl/FileDownloader.py", line 230, in trouble
tb_data = traceback.format_list(traceback.extract_stack())

and this shell script does much other weird stuff:

Quote:

Originally Posted by youtube.sh
decode ()
{
read $1 < <(sed 's % \\\\x g' <<< ${!2} | xargs printf)
}
usage ()
{
echo usage: $0 [ITAG] URL;
exit
}
warn ()
{
printf '\e[36m%s\e[m\n' "$*"
}
printf: fehlender Operand
„printf --help“ gibt weitere Informationen.
/home/southz/youtube.sh: Zeile 65: [: 18: Einstelliger (unärer) Operator erwartet.
/home/southz/youtube.sh: Zeile 83: [: =: Einstelliger (unärer) Operator erwartet.
--2013-03-23 04:21:29-- http://&signature=/
Auflösen des Hostnamen »XXXXXXXXX (XXXXXXXXXX)«... XXX.XXX.XXX.XXX, XXX.XXX.XXX.XXX
Verbindungsaufbau zu XXXXXXXXXX (XXXXXXXXXX)|XXXXXXXXXX|:80... verbunden.
Proxy-Anforderung gesendet, warte auf Antwort... 502 Proxy Error
2013-03-23 04:21:32 FEHLER 502: Proxy Error.


doitamd 06-19-2013 10:44 AM

Re: How to dump youtube live TV stream to file using commandline?


 
Hi Elgero,

I just ran into your tool few hours ago and found it very useful.
May I ask you to add one option - your current release exits right away if the live stream is not yet active. Is it possible to add something like 'wait until program starts' command line option, preferably with interval? e.g. "c:\>youtubedl -w 60 -u http://blah.", which means, try to download a program from blah, if the program is not active, wait 60 seconds and retry.
I need this option because I don't want to get stuck in front of my PC to start recording. How's this sound like?


BR

doitamd


Quote:

Originally Posted by Elgero (Post 59172)
Here's a new version.

https://rapidshare.com/files/18912184/YouTubeDL.zip

- Highest quality stream will be downloaded when format argument is omitted.
- Full url must be specified.
- Stream can be redirected to stdout and played with VLC.

I haven't done anything about the live stream getting stuck (yet). I have no idea what youtube-dl does and I'm not going to dig through the source code of youtube-dl or experiment for hours trying to find that out. If somebody can tell me how youtube-dl does it, then I might be able to fix it.

Code:

-u <url>      YouTube url (e.g. http://www.youtube.com/watch?v=HcwTxRuq-uk).
 -l            Lists the available formats for this video.
 -f <number>    Video format to download (see -l).
                Highest quality available will be downloaded when omitted.
 -o <filepath>  FLV output path, if the filepath is - print stream to stdout.
                Video will be downloaded to the same folder as executable and
                YouTube page title will be used as filename when omitted.

Example #1 - List available formats:
  youtubedl -l -u http://www.youtube.com/watch?v=HcwTxRuq-uk

Example #2 - Download to current folder with page title as file name:
  youtubedl -f 34 -u http://www.youtube.com/watch?v=HcwTxRuq-uk

Example #3 - Dowload with path specified:
  youtubedl -f 34 -u http://www.youtube.com/watch?v=HcwTxRuq-uk -o "C:\a.flv"

Example #4 - Print stream to stdout and play in VLC:
  youtubedl -f 34 -u http://www.youtube.com/watch?v=HcwTxRuq-uk -o - | "C:\Program Files\VideoLAN\VLC\vlc.exe" -



Elgero 06-19-2013 08:40 PM

Re: How to dump youtube live TV stream to file using commandline?


 
Quote:

Originally Posted by doitamd (Post 62586)
Hi Elgero,

I just ran into your tool few hours ago and found it very useful.
May I ask you to add one option - your current release exits right away if the live stream is not yet active. Is it possible to add something like 'wait until program starts' command line option, preferably with interval? e.g. "c:\>youtubedl -w 60 -u http://blah.", which means, try to download a program from blah, if the program is not active, wait 60 seconds and retry.
I need this option because I don't want to get stuck in front of my PC to start recording. How's this sound like?


BR

doitamd

Sorry, but I can't add any new options, because I don't have the source code and the compiled executable anymore. There wasn't much interest in the tool, so I deleted everything.

Spinnaker2001 06-22-2013 12:19 PM

Re: How to dump youtube live TV stream to file using commandline?


 
I'm surprised nobody has mentioned the youtube-dl CLI tool. I personally use it on Ubuntu Linux but it also is supported by Windows and OSX, here is a link to their site: http://rg3.github.io/youtube-dl/

Its insanely simply to use, here is a usage example:
In this example, I will use this YouTube video: http://www.youtube.com/watch?v=bV9L5Ht9LgY

Note: For me this downloaded the video's 1080p resolution with h.264/aac codecs (iTag 37 which Ill explain later).

The filename of the video was that of the URL's video, simply bV9L5Ht9LgY.mp4 if you want to download the video with the video's title as the file name simply use this command:

Code:

youtube-dl http://www.youtube.com/watch?v=bV9L5Ht9LgY -o %\(stitle\)s\.%\(ext\)s
The filename that was downloaded was: Download_Youtube_Playlist_with_Youtube-dl.mp4

If you want to specify the resolution or codec type for the video you can easily do so by using the iTag value that YouTube uses. To view a list of the video's iTag values (without downloading the video) use the -F flag in the command:
Code:

youtube-dl -F http://www.youtube.com/watch?v=bV9L5Ht9LgY -o %\(stitle\)s\.%\(ext\)s
The result will look as such:
Code:

[youtube] Setting language
[youtube] bV9L5Ht9LgY: Downloading video webpage
[youtube] bV9L5Ht9LgY: Downloading video info webpage
[youtube] bV9L5Ht9LgY: Extracting video information
Available formats:
37        :        mp4        [1080x1920]
46        :        webm        [1080x1920]
22        :        mp4        [720x1280]
45        :        webm        [720x1280]
35        :        flv        [480x854]
34        :        flv        [360x640]
18        :        mp4        [360x640]
43        :        webm        [360x640]
5        :        flv        [240x400]
17        :        mp4        [144x176]

Since I'm a geek for mp4 I'm going to go with the the 37 iTag value and use the video's title as its' file name:
Code:

youtube-dl -f 37 http://www.youtube.com/watch?v=bV9L5Ht9LgY -o %\(stitle\)s\.%\(ext\)s
If your curious, all of YouTube's iTag values are listed here: http://en.wikipedia.org/wiki/YouTube#Quality_and_codecs

Lastly, this awesome tool is not limited to just YouTube. It also works on a list of other sites like Vimeo, DailyMotion, DepositFiles, CollegeHumor, etc etc. A list of all sites this works with is available here: http://rg3.github.io/youtube-dl/documentation.html#d4

magichandz 09-27-2013 06:20 PM

Re: How to dump youtube live TV stream to file using commandline?


 
trying to download live stream
http://www.youtube.com/watch?v=Bht5_9sUg3k&hd=1

seems youtube has changed the url format. ffmpeg method not working like before. getting a 403 error.

Code:

ffmpeg -i "http://www.youtube.com/api/manifest/hls_playlist/id/Bht5_9sUg3k.1/itag/95/source/yt_live_broadcast/ratebypass/yes/live/1/cmbypass/yes/newshard/yes/hls_chunk_host/www.youtube.com/gir/yes/dg_shard/Bht5_9sUg3k.1_95/cp/U0hXRVNQT19NSkNON19LSlNEOk9MNkh6Z0xWUDZz/pmbypass/yes/playlist_type/DVR/maudio/1/upn/AtW_LbeiVCA/sver/3/fexp/926400,906946,932242,916807,916625,929305,924606,916914,929117,929121,929906,929907,929922,929923,929127,929129,929131,929930,936403,925724,925726,936310,925720,925722,925718,936401,925714,929917,929933,929935,929937,929939,939602,939604,937102,906842,913428,912715,919811,932309,913563,919373,930803,908536,908538,938701,931924,940501,936308,909549,900816,912711,934507,907231,936312,906001/cpn/RKjJU5hq-RpziBMV/ip/174.109.39.220/ipbits/8/expire/1380351380/sparams/ip,ipbits,expire,id,itag,source,ratebypass,live,cmbypass,newshard,hls_chunk_host,gir,dg_shard,cp,pmbypass,playlist_type,maudio/signature/18FFB16ACCD670DD64CC90D58AEFC0EB61CD5750.1E71A2A68A0EE0A09E64B21F2522D00860DCC20B/key/dg_yt0/file/index.m3u8?start_seq=967" -c copy stream3.ts
ffmpeg version 1.2.1 Copyright (c) 2000-2013 the FFmpeg developers
  built on May 20 2013 05:39:32 with gcc 4.2.1 (GCC) (Apple Inc. build 5666) (dot 3)
  configuration: --prefix=/opt/local --enable-swscale --enable-avfilter --enable-libmp3lame --enable-libvorbis --enable-libopus --enable-libtheora --enable-libschroedinger --enable-libopenjpeg --enable-libmodplug --enable-libvpx --enable-libspeex --enable-libfreetype --mandir=/opt/local/share/man --enable-shared --enable-pthreads --cc=/usr/bin/gcc-4.2 --arch=x86_64 --enable-yasm --enable-gpl --enable-postproc --enable-libx264 --enable-libxvid
  libavutil      52. 18.100 / 52. 18.100
  libavcodec    54. 92.100 / 54. 92.100
  libavformat    54. 63.104 / 54. 63.104
  libavdevice    54.  3.103 / 54.  3.103
  libavfilter    3. 42.103 /  3. 42.103
  libswscale      2.  2.100 /  2.  2.100
  libswresample  0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100
[http @ 0x102013a00] HTTP error 403 Forbidden
[hls,applehttp @ 0x10202a000] Error when loading first segment 'http://www.youtube.com/videoplayback/id/Bht5_9sUg3k.1/itag/95/source/yt_live_broadcast/sq/967/file/seg.ts?ratebypass=yes&cmbypass=yes&newshard=yes&hls_chunk_host=www.youtube.com&gir=yes&dg_shard=Bht5_9sUg3k.1_95&cp=U0hXRVNQT19NSkNON19LSlNEOk9MNkh6Z0xWUDZz&pmbypass=yes&playlist_type=DVR&maudio=1&upn=AtW_LbeiVCA&sver=3&fexp=926400,906946,932242,916807,916625,929305,924606,916914,929117,929121,929906,929907,929922,929923,929127,929129,929131,929930,936403,925724,925726,936310,925720,925722,925718,936401,925714,929917,929933,929935,929937,929939,939602,939604,937102,906842,913428,912715,919811,932309,913563,919373,930803,908536,908538,938701,931924,940501,936308,909549,900816,912711,934507,907231,936312,906001&cpn=RKjJU5hq-RpziBMV&ip=174.109.39.220&ipbits=8&expire=1380351380&sparams=ip,ipbits,expire,id,itag,source,ratebypass,live,cmbypass,newshard,hls_chunk_host,gir,dg_shard,cp,pmbypass,playlist_type,maudio&signature=18FFB16ACCD670DD64CC90D58AEFC0EB61CD5750.1E71A2A68A0EE0A09E64Bhttp://www.youtube.com/api/manifest/hls_playlist/id/Bht5_9sUg3k.1/itag/95/source/yt_live_broadcast/ratebypass/yes/live/1/cmbypass/yes/newshard/yes/hls_chunk_host/www.youtube.com/gir/yes/dg_shard/Bht5_9sUg3k.1_95/cp/U0hXRVNQT19NSkNON19LSlNEOk9MNkh6Z0xWUDZz/pmbypass/yes/playlist_type/DVR/maudio/1/upn/AtW_LbeiVCA/sver/3/fexp/926400,906946,932242,916807,916625,929305,924606,916914,929117,929121,929906,929907,929922,929923,929127,929129,929131,929930,936403,925724,925726,936310,925720,925722,925718,936401,925714,929917,929933,929935,929937,929939,939602,939604,937102,906842,913428,912715,919811,932309,913563,919373,930803,908536,908538,938701,931924,940501,936308,909549,900816,912711,934507,907231,936312,906001/cpn/RKjJU5hq-RpziBMV/ip/174.109.39.220/ipbits/8/expire/1380351380/sparams/ip,ipbits,expire,id,itag,source,ratebypass,live,cmbypass,newshard,hls_chunk_host,gir,dg_shard,cp,pmbypass,playlist_type,maudio/signature/18FFB16ACCD670DD64CC90D58AEFC0EB61CD5750.1E71A2A68A0EE0A09E64B21F2522D00860DCC20B/key/dg_yt0/fil


chap 09-27-2013 11:10 PM

Re: How to dump youtube live TV stream to file using commandline?


 
use latest ffmpeg

fix
http://trac.ffmpeg.org/ticket/2976


All times are GMT -6. The time now is 07:01 AM.