MCPcopy
hub / github.com/Huanshere/VideoLingo / process_video

Function process_video

batch/utils/video_processor.py:19โ€“72  ยท  view source on GitHub โ†—
(file, dubbing=False, is_retry=False)

Source from the content-addressed store, hash-verified

17YTB_RESOLUTION_KEY = "ytb_resolution"
18
19def process_video(file, dubbing=False, is_retry=False):
20 if not is_retry:
21 prepare_output_folder(OUTPUT_DIR)
22
23 text_steps = [
24 ("๐ŸŽฅ Processing input file", partial(process_input_file, file)),
25 ("๐ŸŽ™๏ธ Transcribing with Whisper", partial(_2_asr.transcribe)),
26 ("โœ‚๏ธ Splitting sentences", split_sentences),
27 ("๐Ÿ“ Summarizing and translating", summarize_and_translate),
28 ("โšก Processing and aligning subtitles", process_and_align_subtitles),
29 ("๐ŸŽฌ Merging subtitles to video", _7_sub_into_vid.merge_subtitles_to_video),
30 ]
31
32 if dubbing:
33 dubbing_steps = [
34 ("๐Ÿ”Š Generating audio tasks", gen_audio_tasks),
35 ("๐ŸŽต Extracting reference audio", _9_refer_audio.extract_refer_audio_main),
36 ("๐Ÿ—ฃ๏ธ Generating audio", _10_gen_audio.gen_audio),
37 ("๐Ÿ”„ Merging full audio", _11_merge_audio.merge_full_audio),
38 ("๐ŸŽž๏ธ Merging dubbing to video", _12_dub_to_vid.merge_video_audio),
39 ]
40 text_steps.extend(dubbing_steps)
41
42 current_step = ""
43 for step_name, step_func in text_steps:
44 current_step = step_name
45 for attempt in range(3):
46 try:
47 console.print(Panel(
48 f"[bold green]{step_name}[/]",
49 subtitle=f"Attempt {attempt + 1}/3" if attempt > 0 else None,
50 border_style="blue"
51 ))
52 result = step_func()
53 if result is not None:
54 globals().update(result)
55 break
56 except Exception as e:
57 if attempt == 2:
58 error_panel = Panel(
59 f"[bold red]Error in step '{current_step}':[/]\n{str(e)}",
60 border_style="red"
61 )
62 console.print(error_panel)
63 cleanup(ERROR_OUTPUT_DIR)
64 return False, current_step, str(e)
65 console.print(Panel(
66 f"[yellow]Attempt {attempt + 1} failed. Retrying...[/]",
67 border_style="yellow"
68 ))
69
70 console.print(Panel("[bold green]All steps completed successfully! ๐ŸŽ‰[/]", border_style="green"))
71 cleanup(SAVE_DIR)
72 return True, "", ""
73
74def prepare_output_folder(output_folder):
75 if os.path.exists(output_folder):

Callers 1

process_batchFunction ยท 0.90

Calls 2

cleanupFunction ยท 0.90
prepare_output_folderFunction ยท 0.85

Tested by

no test coverage detected