chrippa / livestreamer

Command-line utility that extracts streams from various services and pipes them into a video player of choice. No longer maintained, use streamlink or youtube-dl instead.
http://livestreamer.io/
BSD 2-Clause "Simplified" License
3.88k stars 585 forks source link

I want to stream m3u8 stream to youtube live #1553

Closed attiqfsd closed 7 years ago

attiqfsd commented 7 years ago

I am looking for a solution to stream m3u8 stream to youtube live stream. I found a reddit link where a user mentioned a command that can accomplish that.

Here is the command,

livestreamer -O "hlsvariant://http://hlslive-l3c.med2.med.nhl.com/ls04/nhl/2016/04/16/NHL_GAME_VIDEO_NYRPIT_M2_NATIONAL_20160416/master_wired60.m3u8 name_key=bitrate" best --http-no-ssl-verify | ffmpeg -re -i - -c:v copy -c:a aac -ar 44100 -ab 128k -ac 2 -flags +global_header -bsf:a aac_adtstoasc -bufsize 3000k -f flv "rtmp://a.rtmp.youtube.com/live2/<STREAMNAME/KEY>"

I have ffmpeg and livestreamer installed on my machine and when I am using this command with my m3u link and stream key, it is showing this error.

livestreamer -O "http://abclive.abcnews.com/i/abc_live4@136330/index_1200_av-b.m3u8?sd=10&b=1200&rebase=on name_key=bitrate" best --http-no-ssl-verify | ffmpeg -re -i - -c:v copy -c:a aac -ar 44100 -ab 128k -ac 2 -flags +global_header -bsf:a aac_adtstoasc -bufsize 2000k -f flv "rtmp://a.rtmp.youtube.com/live2/<STREAMNAME/KEY>"
ffmpeg version 2.4.3-1ubuntu1~trusty6 Copyright (c) 2000-2014 the FFmpeg developers
  built on Nov 22 2014 17:07:19 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
  configuration: --prefix=/usr --extra-version='1ubuntu1~trusty6' --build-suffix=-ffmpeg --toolchain=hardened --extra-cflags= --extra-cxxflags= --libdir=/usr/lib/x86_64-linux-gnu --shlibdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --enable-shared --disable-stripping --enable-avresample --enable-avisynth --enable-fontconfig --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-opengl --enable-x11grab --enable-libxvid --enable-libx265 --enable-libdc1394 --enable-libiec61883 --enable-libzvbi --enable-libzmq --enable-frei0r --enable-libx264 --enable-libsoxr --enable-openal --enable-libopencv
  libavutil      54.  7.100 / 54.  7.100
  libavcodec     56.  1.100 / 56.  1.100
  libavformat    56.  4.101 / 56.  4.101
  libavdevice    56.  0.100 / 56.  0.100
  libavfilter     5.  1.100 /  5.  1.100
  libavresample   2.  1.  0 /  2.  1.  0
  libswscale      3.  0.100 /  3.  0.100
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  0.100 / 53.  0.100
pipe:: Invalid data found when processing input

Could you please tell me what wrong I am doing?

attiqfsd commented 7 years ago

If I use a static video file URL instead of the M3U8 link, the out error is same.

flijloku commented 7 years ago

Maybe you just try ffmpeg -i "http://abclive.abcnews.com/i/abc_live4@136330/index_1200_av-b.m3u8?sd=10&b=1200&rebase=on" -c:v copy -c:a aac ....... without the livestreamer?

attiqfsd commented 7 years ago

Can you please tell me complete command? I am completely unknown of the format of the commands.

flijloku commented 7 years ago

ffmpeg -re -i "http://abclive.abcnews.com/i/abc_live4@136330/index_1200_av-b.m3u8?sd=10&b=1200&rebase=on" -c:v copy -c:a aac -ar 44100 -ab 128k -ac 2 -flags +global_header -bsf:a aac_adtstoasc -bufsize 3000k -f flv "rtmp://a.rtmp.youtube.com/live2/<STREAMNAME/KEY>" Not sure whether it is necessary "-re" I am no expert on this, so you'd better read this: http://trac.ffmpeg.org/wiki/StreamingGuide and similar.

attiqfsd commented 7 years ago

Thanks, I was able to start the streaming by adding -strict -2 after a couple in the command but the stream is breaking after every couple of seconds.

encoder         : Lavc56.1.100 aac
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
skipping 1 segments ahead, expired from playlists0:00:29.74 bitrate=1272.1kbits/s    
skipping 1 segments ahead, expired from playlists0:01:08.59 bitrate=1103.2kbits/s    
[flv @ 0x17b15c0] Failed to update header with correct duration.ate= 983.0kbits/s    
[flv @ 0x17b15c0] Failed to update header with correct filesize.
frame= 1827 fps= 23 q=-1.0 Lsize=    9479kB time=00:01:18.94 bitrate= 983.7kbits/s    
video:8440kB audio:954kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.906219%
Received signal 2: terminating.

Can you please tell me what could be the reason behind it?

flijloku commented 7 years ago

Apparently, this is due to the format M3U8. Probably you really need livestreamer or vlc or something similar. Perhaps you'd better ask the same question in a streamlink theme https://github.com/streamlink/streamlink/issues because https://github.com/chrippa/livestreamer/issues/1550

flijloku commented 7 years ago

Found this: https://www.reddit.com/r/NHLStreams/comments/3o5x3j/quick_tutorial_on_using_ffmpeg_to_restream/ so restream of m3u8-playlist with only ffmpeg is possible. BTW I can not open your playlist: http://hlslive-l3c.med2.med.nhl.com/ls04/nhl/2016/04/16/NHL_GAME_VIDEO_NYRPIT_M2_NATIONAL_20160416/master_wired60.m3u8 in vlc-player. It is working for you?

attiqfsd commented 7 years ago

Yes that playlist is not working. But that ABC news link is working and I tried to restream that.

Can I restream to fb live?

10mins commented 7 years ago

This is livestreamer issue tracker. You might want go check ffmpeg documentation.

flijloku commented 7 years ago

If you only use ffmpeg without livestreamer you can ask questions in this forum: http://ffmpeg.gusari.org/index.php

attiqfsd commented 7 years ago

Thanks 👍

Octolus commented 7 years ago

@attiqfsd any solution?

I want to do the exactly same thing. Basically stream from a m3u8 to YouTube... And facebook if possible.