简体   繁体   English

ffmpeg连接被对等方重置

[英]ffmpeg connection reset by peer

I have a problem when using ffmpeg: 使用ffmpeg时出现问题:

quite often my clients will have slightly dodgy internet connections but they subscribe to a service which is designed to record a stream that they are hosting, and record it for hosting on something like a wordpress site. 通常,我的客户的互联网连接会稍显不明朗,但他们订阅了一项服务,该服务旨在记录其托管的流,并将其记录以托管在诸如wordpress网站之类的内容上。

ffmpeg is called by a python script. ffmpeg由python脚本调用。 I would like, ideally, to know if ffmpeg will throw an exception or return a value that can be accessed by the python script and used as a variable to determine if there was a problem recording the audio. 理想情况下,我想知道ffmpeg是否会引发异常或返回可由python脚本访问的值,并用作变量来确定录制音频是否有问题。

at the moment python calls ffmpeg using: 目前python使用以下命令调用ffmpeg:

os.system('ffmpeg -i [stream address] -t 1:00 -acodec copy ')

when I simulate a connection loss (turning off the NIC on the virtual machine) ffmpeg prints to the terminal 当我模拟连接丢失(关闭虚拟机上的NIC)时,ffmpeg打印到终端

Connection reset by peer

So not a direct answer, but a suitable method for getting the desired response, written in pseudocode in order to make it easily understandable: 因此,不是直接的答案,而是获得期望的响应的合适方法,以伪代码编写以便使其易于理解:

finishTime = timeNow + recordingDuration
call RecordFunction (source, destination, finishTime)

def RecordFunction (source, destination, finishTime):

    calculate recording duration with simple arithmetic

    ffString([Build the ffrecording strin])
    run.commandLine(ffstring)
    timeLeft = finishTime - timNow
    if timeLeft > tollerance:
        call RecordFunction(source, destination, finishTime)

optionally one can check the ffmpeg log and pass that to a log file. 可以选择检查ffmpeg日志并将其传递到日志文件。 Or one can set a limit on the number of disconnects occurring. 或者,可以对发生的断开连接数量设置限制。

As per documentation of os.system: 根据os.system的文档:

"On Unix, the return value is the exit status of the process encoded in the format specified for wait(). Note that POSIX does not specify the meaning of the return value of the C system() function, so the return value of the Python function is system-dependent." “在Unix上, 返回值是以为wait()指定的格式编码的进程的退出状态 。请注意,POSIX没有指定C system()函数的返回值的含义,因此, Python函数取决于系统。”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM