curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /usr/local/bin/youtube-dl
chmod a+rx /usr/local/bin/youtube-dl
youtube-dl --list-formats https://www.youtube.com/watch?v=9cQT4urTlXM
[youtube] 9cQT4urTlXM: Downloading webpage [youtube] 9cQT4urTlXM: Downloading video info webpage [youtube] 9cQT4urTlXM: Extracting video information [youtube] 9cQT4urTlXM: Downloading MPD manifest [info] Available formats for 9cQT4urTlXM: format code extension resolution note 171 webm audio only DASH audio 8k , vorbis@128k, 540.24KiB 249 webm audio only DASH audio 10k , opus @ 50k, 797.30KiB 250 webm audio only DASH audio 10k , opus @ 70k, 797.30KiB 251 webm audio only DASH audio 10k , opus @160k, 797.30KiB 139 m4a audio only DASH audio 53k , m4a_dash container, mp4a.40.5@ 48k (22050Hz), 10.36MiB 140 m4a audio only DASH audio 137k , m4a_dash container, mp4a.40.2@128k (44100Hz), 27.56MiB 278 webm 256x144 144p 41k , webm container, vp9, 30fps, video only, 6.54MiB 242 webm 426x240 240p 70k , vp9, 30fps, video only, 13.42MiB 243 webm 640x360 360p 101k , vp9, 30fps, video only, 20.55MiB 160 mp4 256x144 DASH video 123k , avc1.4d400c, 15fps, video only, 24.83MiB 134 mp4 640x360 DASH video 138k , avc1.4d401e, 30fps, video only, 28.07MiB 244 webm 854x480 480p 149k , vp9, 30fps, video only, 30.55MiB 135 mp4 854x480 DASH video 209k , avc1.4d401f, 30fps, video only, 42.42MiB 133 mp4 426x240 DASH video 274k , avc1.4d4015, 30fps, video only, 57.63MiB 247 webm 1280x720 720p 298k , vp9, 30fps, video only, 59.25MiB 136 mp4 1280x720 DASH video 307k , avc1.4d401f, 30fps, video only, 62.58MiB 17 3gp 176x144 small , mp4v.20.3, mp4a.40.2@ 24k 36 3gp 320x180 small , mp4v.20.3, mp4a.40.2 43 webm 640x360 medium , vp8.0, vorbis@128k 18 mp4 640x360 medium , avc1.42001E, mp4a.40.2@ 96k 22 mp4 1280x720 hd720 , avc1.64001F, mp4a.40.2@192k (best)
wget http://ffmpeg.org/releases/ffmpeg-3.3.4.tar.bz2 tar -xvjf ffmpeg-3.3.4.tar.bz2 cd ffmpeg-3.3.4 ./configure --enable-shared --disable-logging --enable-gpl --enable-pthreads --enable-libx264 --enable-librtmp make make install
ffmpeg -v
#!/usr/bin/python import subprocess import sys def show_help(): print 'Usage: ' print './streamer.py url streamName destination' print './streamer.py https://www.youtube.com/watch?v=9cQT4urTlXM streamName rtmp://192.168.88.59:1935/live' return def streamer() : url = sys.argv[1] if not url : print 'Error: url is empty' return stream_id = sys.argv[2] if not stream_id: print 'Error: stream name is empty' return destination = sys.argv[3] if not destination: print 'Error: destination is empty' return _youtube_process = subprocess.Popen(('youtube-dl','-f','','--prefer-ffmpeg', '--no-color', '--no-cache-dir', '--no-progress','-o', '-', '-f', '22/18', url, '--reject-title', stream_id),stdout=subprocess.PIPE) _ffmpeg_process = subprocess.Popen(('ffmpeg','-re','-i', '-','-preset', 'ultrafast','-vcodec', 'copy', '-acodec', 'copy','-threads','1', '-f', 'flv',destination + "/" + stream_id), stdin=_youtube_process.stdout) return if len(sys.argv) < 4: show_help() else: streamer()
python streamer.py https://www.youtube.com/watch?v=9cQT4urTlXM stream1 rtmp://192.168.88.59:1935/live
rtmp://wcs5-eu.flashphoner.com:1935/live
python streamer.py https://www.youtube.com/watch?v=9cQT4urTlXM stream1 rtmp://wcs5-eu.flashphoner.com:1935/live
# python streamer.py https://www.youtube.com/watch?v=9cQT4urTlXM stream1 rtmp://wcs5-eu.flashphoner.com:1935/live ffmpeg version 3.2.3 Copyright (c) 2000-2017 the FFmpeg developers built with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-11) configuration: --enable-shared --disable-logging --enable-gpl --enable-pthreads --enable-libx264 --enable-librtmp --disable-yasm libavutil 55. 34.101 / 55. 34.101 libavcodec 57. 64.101 / 57. 64.101 libavformat 57. 56.101 / 57. 56.101 libavdevice 57. 1.100 / 57. 1.100 libavfilter 6. 65.100 / 6. 65.100 libswscale 4. 2.100 / 4. 2.100 libswresample 2. 3.100 / 2. 3.100 libpostproc 54. 1.100 / 54. 1.100 ]# [youtube] 9cQT4urTlXM: Downloading webpage [youtube] 9cQT4urTlXM: Downloading video info webpage [youtube] 9cQT4urTlXM: Extracting video information [youtube] 9cQT4urTlXM: Downloading MPD manifest [download] Destination: - Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'pipe:': Metadata: major_brand : mp42 minor_version : 0 compatible_brands: isommp42 creation_time : 2016-08-23T12:21:06.000000Z Duration: 00:29:59.99, start: 0.000000, bitrate: N/A Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 288 kb/s, 30 fps, 30 tbr, 90k tbn, 60 tbc (default) Metadata: creation_time : 2016-08-23T12:21:06.000000Z handler_name : ISO Media file produced by Google Inc. Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 125 kb/s (default) Metadata: creation_time : 2016-08-23T12:21:06.000000Z handler_name : ISO Media file produced by Google Inc. Output #0, flv, to 'rtmp://192.168.88.59:1935/live/stream1': Metadata: major_brand : mp42 minor_version : 0 compatible_brands: isommp42 encoder : Lavf57.56.101 Stream #0:0(und): Video: h264 (Main) ([7][0][0][0] / 0x0007), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 288 kb/s, 30 fps, 30 tbr, 1k tbn, 90k tbc (default) Metadata: creation_time : 2016-08-23T12:21:06.000000Z handler_name : ISO Media file produced by Google Inc. Stream #0:1(und): Audio: aac (LC) ([10][0][0][0] / 0x000A), 44100 Hz, stereo, 125 kb/s (default) Metadata: creation_time : 2016-08-23T12:21:06.000000Z handler_name : ISO Media file produced by Google Inc. Stream mapping: Stream #0:0 -> #0:0 (copy) Stream #0:1 -> #0:1 (copy) frame= 383 fps= 30 q=-1.0 size= 654kB time=00:00:12.70 bitrate= 421.8kbits/s speed= 1x
Source: https://habr.com/ru/post/338098/
All Articles