generate thumbnail of the recorder file
This commit is contained in:
parent
1dc81ecba4
commit
bd2ef69a7d
3 changed files with 26 additions and 12 deletions
1
init.sh
1
init.sh
|
@ -6,6 +6,7 @@ mkdir -v -p data/restreamer/data
|
|||
|
||||
mkdir -v -p data/recorder/vod
|
||||
mkdir -v -p data/recorder/live
|
||||
mkdir -v -p data/recorder/thumb
|
||||
|
||||
mkdir -v -p data/archive
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ async def on_ready():
|
|||
@bot.command(name='hello', help='Say hello to the bot')
|
||||
async def hello(ctx):
|
||||
author_name = ctx.author.name
|
||||
await ctx.channel.send(f'```hi, {author_name} >^.^<```')
|
||||
await ctx.channel.send(f'hi, `{author_name}` :blush:')
|
||||
|
||||
@bot.command(name='epg', help='Lists scheduled streams')
|
||||
async def epg(ctx):
|
||||
|
@ -70,7 +70,7 @@ async def epg(ctx):
|
|||
|
||||
@bot.command(name='time', help='Show current time')
|
||||
async def time(ctx):
|
||||
await ctx.channel.send(f'```The time is: {datetime.now()} UTC```')
|
||||
await ctx.channel.send(f'The time is: `{datetime.now()} UTC`')
|
||||
|
||||
@bot.command(name='now', help='Displays whats playing right now')
|
||||
async def now(ctx):
|
||||
|
@ -88,7 +88,7 @@ async def query_playhead():
|
|||
logger_discord.error('Cannot connect to the playhead!')
|
||||
head_name = playhead['name']
|
||||
head_prio = playhead['prio']
|
||||
return f'```Now playing {head_name}. priority={head_prio}```'
|
||||
return f'Now playing {head_name}'
|
||||
|
||||
async def query_database():
|
||||
global database
|
||||
|
@ -138,9 +138,9 @@ async def query_database():
|
|||
vod_filename = rechead['file']
|
||||
rechead = {}
|
||||
vod_url = f'https://{vod_hostname}/storage/{vod_filename}'
|
||||
offline_msg = f'Live stream is offline. VOD: {vod_url}'
|
||||
offline_msg = f'Live stream is now offline. [Download VoD recording]({vod_url})'
|
||||
else:
|
||||
offline_msg = f'Live stream is offline.'
|
||||
offline_msg = f'Live stream is now offline.'
|
||||
logger_discord.info(offline_msg)
|
||||
if live_channel_id != 0:
|
||||
live_channel = bot.get_channel(int(live_channel_id))
|
||||
|
|
|
@ -164,29 +164,42 @@ def exec_stream(stream_id, stream_name, stream_prio, stream_hls_url):
|
|||
def exec_recorder(stream_id, stream_hls_url):
|
||||
global rechead
|
||||
current_datetime = datetime.now().strftime("%Y-%m-%d_%H-%M-%S-%f")
|
||||
output_file = current_datetime + ".mp4"
|
||||
video_file = current_datetime + ".mp4"
|
||||
thumb_file = current_datetime + ".png"
|
||||
if rechead != {}:
|
||||
logger_job.error('Recorder is already started. Refusing to start another job.')
|
||||
else:
|
||||
logger_job.warning(f'Recording {output_file} started.')
|
||||
rechead = { 'id': stream_id,
|
||||
'file': output_file }
|
||||
output = f'{rec_path}/live/{output_file}'
|
||||
'video': video_file,
|
||||
'thumb': thumb_file }
|
||||
video_output = f'{rec_path}/live/{video_file}'
|
||||
thumb_output = f'{rec_path}/live/{thumb_file}'
|
||||
ffmpeg = (
|
||||
FFmpeg()
|
||||
.option("y")
|
||||
.input(stream_hls_url)
|
||||
.output(output,
|
||||
.output(video_output,
|
||||
{"codec:v": "copy", "codec:a": "copy", "bsf:a": "aac_adtstoasc"},
|
||||
))
|
||||
|
||||
@ffmpeg.on("progress")
|
||||
def on_progress(progress: Progress):
|
||||
print(progress)
|
||||
|
||||
ffmpeg.execute()
|
||||
logger_job.warning(f'Recording {output_file} finished. Moving file to {rec_path}/vod')
|
||||
os.rename(f'{rec_path}/live/{output_file}', f'{rec_path}/vod/{output_file}')
|
||||
|
||||
ffmpeg = (
|
||||
FFmpeg()
|
||||
.input(video_output)
|
||||
.output(thumb_output,
|
||||
{"vf": "thumbnail", "frames:v": "1"})
|
||||
)
|
||||
ffmpeg.execute()
|
||||
|
||||
logger_job.warning(f'Recording {video_file} finished.')
|
||||
os.rename(f'{video_output}', f'{rec_path}/vod/{video_file}')
|
||||
os.rename(f'{thumb_output}', f'{rec_path}/thumb/{thumb_file}}')
|
||||
|
||||
rechead = {}
|
||||
|
||||
# Datarhei CORE API sync
|
||||
|
|
Loading…
Reference in a new issue