scivision / PyLivestream

Pure Python FFmpeg-based live video / audio streaming to YouTube, Facebook, Periscope, Twitch, and more
Apache License 2.0
710 stars 157 forks source link

stream to youtube from file stop randomly #3

Closed cdliou closed 6 years ago

cdliou commented 6 years ago

The procedure would stop randomly when stream to YouTube from file infinitely. Below is the screen print out. It seems that when ffmpeg end with an error will cause the program to stop.

Conversion failed!

Traceback (most recent call last): File "/home/admin1/Videos/Program2YouTubeLive.py", line 52, in PyLivestream.FileIn('stream.ini', 'youtube', f, loop=False) File "/home/admin1/Videos/PyLivestream-master/PyLivestream/init.py", line 385, in init stream.golive() File "/home/admin1/Videos/PyLivestream-master/PyLivestream/init.py", line 309, in golive sp.check_call(self.cmd, stdout=sp.DEVNULL) File "/home/admin1/anaconda3/lib/python3.6/subprocess.py", line 291, in check_call raise CalledProcessError(retcode, cmd)

scivision commented 6 years ago

Yes the Python program uses the FFmpeg setting that halt streaming if any one stream fails. This means for WiFi, cellular, etc. a persistent connection failure stops all streams.

In connections like that, the stream quality may be suffering in general. I can think if there's value to having PyLivestream attempt to restart a failed stream N times.

scivision commented 6 years ago

Unfortunately, FFmpeg emits very little information when it stops. I'd rather not parse the text output.

When the connection is good, I have streamed continuously for many hours with this program. In the case of a file, without messy text parsing of FFmpeg output, I wouldn't know where to restart streaming in the file upon restart.

My main use of this program is for Webcam or Screenshare livestreaming to mulitple streaming sites simultaneously.

cdliou commented 6 years ago

Could we set timeout to very big to prevent the connection reset by peer?

scivision commented 6 years ago

From http://ffmpeg.org/ffmpeg-protocols.html The rw_timeout option is for all network protocols, units of microseconds. Wonder if you try setting rw_timeout to say 30000000 (30 seconds). I.e. just copy and paste PyLivestream command line output, manually adding that option.