mirror of
https://github.com/fHDHR/fHDHR_NextPVR.git
synced 2025-12-06 18:26:57 -05:00
Fix ffmpeg
This commit is contained in:
parent
06df50d941
commit
36b4078c62
@ -7,7 +7,6 @@ import json
|
|||||||
import time
|
import time
|
||||||
import requests
|
import requests
|
||||||
import subprocess
|
import subprocess
|
||||||
import errno
|
|
||||||
import PIL.Image
|
import PIL.Image
|
||||||
import PIL.ImageDraw
|
import PIL.ImageDraw
|
||||||
import PIL.ImageFont
|
import PIL.ImageFont
|
||||||
@ -111,7 +110,7 @@ class HDHR_Hub():
|
|||||||
"TunerCount": self.config["fakehdhr"]["tuner_count"],
|
"TunerCount": self.config["fakehdhr"]["tuner_count"],
|
||||||
"FirmwareVersion": self.config["dev"]["reporting_firmware_ver"],
|
"FirmwareVersion": self.config["dev"]["reporting_firmware_ver"],
|
||||||
"DeviceID": self.config["main"]["uuid"],
|
"DeviceID": self.config["main"]["uuid"],
|
||||||
"DeviceAuth": "nextpvrproxy",
|
"DeviceAuth": "fHDHR",
|
||||||
"BaseURL": "http://" + base_url,
|
"BaseURL": "http://" + base_url,
|
||||||
"LineupURL": "http://" + base_url + "/lineup.json"
|
"LineupURL": "http://" + base_url + "/lineup.json"
|
||||||
}
|
}
|
||||||
@ -247,7 +246,7 @@ class HDHR_HTTP_Server():
|
|||||||
return Response(image, content_type='image/png', direct_passthrough=True)
|
return Response(image, content_type='image/png', direct_passthrough=True)
|
||||||
|
|
||||||
@app.route('/watch', methods=['GET'])
|
@app.route('/watch', methods=['GET'])
|
||||||
def watch_nothing():
|
def watch():
|
||||||
if 'method' in list(request.args.keys()):
|
if 'method' in list(request.args.keys()):
|
||||||
if 'channel' in list(request.args.keys()):
|
if 'channel' in list(request.args.keys()):
|
||||||
|
|
||||||
@ -283,39 +282,25 @@ class HDHR_HTTP_Server():
|
|||||||
"-loglevel", "warning",
|
"-loglevel", "warning",
|
||||||
"pipe:stdout"
|
"pipe:stdout"
|
||||||
]
|
]
|
||||||
|
|
||||||
ffmpeg_proc = subprocess.Popen(ffmpeg_command, stdout=subprocess.PIPE)
|
ffmpeg_proc = subprocess.Popen(ffmpeg_command, stdout=subprocess.PIPE)
|
||||||
|
|
||||||
def generate():
|
def generate():
|
||||||
|
try:
|
||||||
videoData = ffmpeg_proc.stdout.read(int(hdhr.config["ffmpeg"]["bytes_per_read"]))
|
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
videoData = ffmpeg_proc.stdout.read(int(hdhr.config["ffmpeg"]["bytes_per_read"]))
|
||||||
if not videoData:
|
if not videoData:
|
||||||
break
|
break
|
||||||
else:
|
|
||||||
# from https://stackoverflow.com/questions/9932332
|
|
||||||
try:
|
try:
|
||||||
yield videoData
|
yield videoData
|
||||||
time.sleep(0.1)
|
except Exception as e:
|
||||||
except IOError as e:
|
|
||||||
# Check we hit a broken pipe when trying to write back to the client
|
|
||||||
if e.errno == errno.EPIPE:
|
|
||||||
# Send SIGTERM to shutdown ffmpeg
|
|
||||||
ffmpeg_proc.terminate()
|
ffmpeg_proc.terminate()
|
||||||
# ffmpeg writes a bit of data out to stderr after it terminates,
|
|
||||||
# need to read any hanging data to prevent a zombie process.
|
|
||||||
ffmpeg_proc.communicate()
|
ffmpeg_proc.communicate()
|
||||||
break
|
print("Connection Closed: " + str(e))
|
||||||
else:
|
except GeneratorExit:
|
||||||
raise
|
|
||||||
|
|
||||||
videoData = ffmpeg_proc.stdout.read(int(hdhr.config["ffmpeg"]["bytes_per_read"]))
|
|
||||||
|
|
||||||
ffmpeg_proc.terminate()
|
ffmpeg_proc.terminate()
|
||||||
try:
|
|
||||||
ffmpeg_proc.communicate()
|
ffmpeg_proc.communicate()
|
||||||
except ValueError:
|
print("Connection Closed.")
|
||||||
print("Connection Closed")
|
|
||||||
|
|
||||||
return Response(stream_with_context(generate()), mimetype="audio/mpeg")
|
return Response(stream_with_context(generate()), mimetype="audio/mpeg")
|
||||||
abort(404)
|
abort(404)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user