Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ensure create_hls runs only after all encodings finish #1095

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions files/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,16 +427,25 @@ def create_hls(friendly_token):

p = media.uid.hex
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:
existing_output_dir = None
if os.path.exists(output_dir):
existing_output_dir = output_dir
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])
cmd = [settings.MP4HLS_COMMAND, '--segment-duration=4', f'--output-dir={output_dir}', files]
files = [f.media_file.path for f in encodings if f.media_file]
cmd = [settings.MP4HLS_COMMAND, '--segment-duration=4', f'--output-dir={output_dir}', *files]
run_command(cmd)

if 'out' not in result:
logger.error(f'bento failed: {result["error"]}')
return False

if existing_output_dir:
# override content with -T !
cmd = ["cp", "-rT", output_dir, existing_output_dir]
Expand Down
Loading