Skip to content

Commit

Permalink
🐛 Fix reencode progress calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
phlmn committed Dec 9, 2023
1 parent dd56e5c commit c2ff7f3
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions worker/transcribee_worker/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ def media_has_video(path: Path):
return False


def is_video_profile(profile_name: str):
return profile_name.startswith("video:")


class Worker:
base_url: str
token: str
Expand Down Expand Up @@ -269,17 +273,17 @@ async def reencode(
duration = get_duration(document_audio)
self.set_duration(task, duration)

n_profiles = len(settings.REENCODE_PROFILES)

has_video = media_has_video(document_audio)

for i, (profile, parameters) in enumerate(settings.REENCODE_PROFILES.items()):
applicable_profiles = {
profile_name: parameters
for profile_name, parameters in settings.REENCODE_PROFILES.items()
if has_video or not is_video_profile(profile_name)
}
n_profiles = len(applicable_profiles)

for i, (profile, parameters) in enumerate(applicable_profiles.items()):
output_path = self._get_tmpfile(f"reencode_{profile.replace(':', '_')}")

video_profile = profile.startswith("video:")

if video_profile and not has_video:
continue
video_profile = is_video_profile(profile)

await reencode(
document_audio,
Expand Down

0 comments on commit c2ff7f3

Please sign in to comment.