mirror of
https://github.com/mediacms-io/mediacms.git
synced 2024-11-25 09:44:32 +01:00
ensure create_hls runs only after all encodings finish
This commit is contained in:
parent
673ddeb5bd
commit
3da38989a4
@ -428,20 +428,29 @@ def create_hls(friendly_token):
|
|||||||
|
|
||||||
p = media.uid.hex
|
p = media.uid.hex
|
||||||
output_dir = os.path.join(settings.HLS_DIR, p)
|
output_dir = os.path.join(settings.HLS_DIR, p)
|
||||||
encodings = media.encodings.filter(profile__extension="mp4", status="success", chunk=False, profile__codec="h264")
|
encodings = media.encodings.filter(profile__extension="mp4", chunk=False, profile__codec="h264")
|
||||||
|
|
||||||
|
if not all((x.status == "success" for x in encodings)):
|
||||||
|
logger.info('not all encodings are finished')
|
||||||
|
return False
|
||||||
|
|
||||||
if encodings:
|
if encodings:
|
||||||
existing_output_dir = None
|
existing_output_dir = None
|
||||||
if os.path.exists(output_dir):
|
if os.path.exists(output_dir):
|
||||||
existing_output_dir = output_dir
|
existing_output_dir = output_dir
|
||||||
output_dir = os.path.join(settings.HLS_DIR, p + produce_friendly_token())
|
output_dir = os.path.join(settings.HLS_DIR, p + produce_friendly_token())
|
||||||
files = " ".join([f.media_file.path for f in encodings if f.media_file])
|
files = [f.media_file.path for f in encodings if f.media_file]
|
||||||
cmd = [
|
cmd = [
|
||||||
settings.MP4HLS_COMMAND,
|
settings.MP4HLS_COMMAND,
|
||||||
'--segment-duration=4',
|
'--segment-duration=4',
|
||||||
f'--output-dir={output_dir}',
|
f'--output-dir={output_dir}',
|
||||||
files
|
*files
|
||||||
]
|
]
|
||||||
run_command(cmd)
|
result = run_command(cmd)
|
||||||
|
|
||||||
|
if 'out' not in result:
|
||||||
|
logger.error(f'bento failed: {result["error"]}')
|
||||||
|
return False
|
||||||
|
|
||||||
if existing_output_dir:
|
if existing_output_dir:
|
||||||
# override content with -T !
|
# override content with -T !
|
||||||
|
Loading…
Reference in New Issue
Block a user