Compare commits

..

No commits in common. "af5a7a4b17c987972c3e2b521e00b3627feeb142" and "eec8482df310fb64c126f96d2b70a6810ea57d42" have entirely different histories.

View file

@ -179,64 +179,57 @@ def exec_recorder(stream_id, stream_name, stream_hls_url):
video_output = f'{rec_path}/live/{video_file}' video_output = f'{rec_path}/live/{video_file}'
thumb_output = f'{rec_path}/live/{thumb_file}' thumb_output = f'{rec_path}/live/{thumb_file}'
try: # Record a mp4 file
# Record a mp4 file ffmpeg = (
ffmpeg = ( FFmpeg()
FFmpeg() .option("y")
.option("y") .input(stream_hls_url)
.input(stream_hls_url) .output(video_output,
.output(video_output, {"codec:v": "copy", "codec:a": "copy", "bsf:a": "aac_adtstoasc"},
{"codec:v": "copy", "codec:a": "copy", "bsf:a": "aac_adtstoasc"}, ))
)) @ffmpeg.on("progress")
@ffmpeg.on("progress") def on_progress(progress: Progress):
def on_progress(progress: Progress): print(progress)
print(progress) ffmpeg.execute()
ffmpeg.execute() logger_job.warning(f'Recording {video_file} finished.')
logger_job.warning(f'Recording of {video_file} finished.')
except Exception as joberror:
logger_job.error(f'Recording of {video_file} failed!')
logger_job.error(joberror)
else:
# Show Metadata
ffmpeg_metadata = (
FFmpeg(executable="ffprobe")
.input(video_output,
print_format="json",
show_streams=None,)
)
media = json.loads(ffmpeg_metadata.execute())
logger_job.warning(f"# Video")
logger_job.warning(f"- Codec: {media['streams'][0]['codec_name']}")
logger_job.warning(f"- Resolution: {media['streams'][0]['width']} X {media['streams'][0]['height']}")
logger_job.warning(f"- Duration: {media['streams'][0]['duration']}")
logger_job.warning(f"# Audio")
logger_job.warning(f"- Codec: {media['streams'][1]['codec_name']}")
logger_job.warning(f"- Sample Rate: {media['streams'][1]['sample_rate']}")
logger_job.warning(f"- Duration: {media['streams'][1]['duration']}")
thumb_skip_time = float(media['streams'][0]['duration']) // 2 # Show Metadata
thumb_width = media['streams'][0]['width'] ffmpeg_metadata = (
FFmpeg(executable="ffprobe")
.input(video_output,
print_format="json",
show_streams=None,)
)
media = json.loads(ffmpeg_metadata.execute())
logger_job.warning(f"# Video")
logger_job.warning(f"- Codec: {media['streams'][0]['codec_name']}")
logger_job.warning(f"- Resolution: {media['streams'][0]['width']} X {media['streams'][0]['height']}")
logger_job.warning(f"- Duration: {media['streams'][0]['duration']}")
logger_job.warning(f"# Audio")
logger_job.warning(f"- Codec: {media['streams'][1]['codec_name']}")
logger_job.warning(f"- Sample Rate: {media['streams'][1]['sample_rate']}")
logger_job.warning(f"- Duration: {media['streams'][1]['duration']}")
thumb_skip_time = float(media['streams'][0]['duration']) // 2
thumb_width = media['streams'][0]['width']
# Generate thumbnail image from the recorded mp4 file # Generate thumbnail image from the recorded mp4 file
ffmpeg_thumb = ( ffmpeg_thumb = (
FFmpeg() FFmpeg()
.input(video_output, ss=thumb_skip_time) .input(video_output, ss=thumb_skip_time)
.output(thumb_output, vf='scale={}:{}'.format(thumb_width, -1), vframes=1) .output(thumb_output, vf='scale={}:{}'.format(thumb_width, -1), vframes=1)
) )
ffmpeg_thumb.execute() ffmpeg_thumb.execute()
logger_job.warning(f'Thumbnail {thumb_file} created.') logger_job.warning(f'Thumbnail {thumb_file} created.')
# When ready, move the recorded from the live dir to the archives and reset the rec head # When ready, move the recorded from the live dir to the archives and reset the rec head
os.rename(f'{video_output}', f'{rec_path}/vod/{video_file}') os.rename(f'{video_output}', f'{rec_path}/vod/{video_file}')
os.rename(f'{thumb_output}', f'{rec_path}/thumb/{thumb_file}') os.rename(f'{thumb_output}', f'{rec_path}/thumb/{thumb_file}')
finally: # Reset the rechead
# Reset the rechead time.sleep(5)
time.sleep(5) rechead = {}
rechead = {} logger_job.warning(f'Rechead reset.')
logger_job.warning(f'Rechead reset.')
# Datarhei CORE API sync # Datarhei CORE API sync
def core_api_sync(): def core_api_sync():