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

Video filetype check #2

Open
Hafpaf opened this issue Oct 31, 2023 · 0 comments
Open

Video filetype check #2

Hafpaf opened this issue Oct 31, 2023 · 0 comments

Comments

@Hafpaf
Copy link
Owner

Hafpaf commented Oct 31, 2023

Verify audio if available in file format, and handle error of by lack thereof, ie. skip file processing if not video file.

Approaches:

  • Check for filetype magic bytes by using a library interfacing with libmagic (preferable)
  • Read file name extension.

One could make a list of accepted filetypes or simply skip SRT files

Error shown:

video file: ../videofiles/import-56124-eng-Goodbye_World_hd.mp4.srt                                                 
Traceback (most recent call last):                                                                                  
  File "/ASR_subtitles/venv/lib/python3.9/site-packages/whisper/audio.py", line 59, in load_audio   
    out = run(cmd, capture_output=True, check=True).stdout                                                          
  File "/usr/lib/python3.9/subprocess.py", line 528, in run                                                         
    raise CalledProcessError(retcode, process.args,                                                                 
subprocess.CalledProcessError: Command '['ffmpeg', '-nostdin', '-threads', '0', '-i', '../videofiles/import-56124-en
g-Goodbye_World_hd.mp4.srt', '-f', 's16le', '-ac', '1', '-acodec', 'pcm_s16le', '-ar', '16000', '-']' returned non-z
ero exit status 1.                                                                                                  
                                                                                                                    
The above exception was the direct cause of the following exception:                                                
                                                                                                                    
Traceback (most recent call last):                                                                                  
  File "/ASR_subtitles/app.py", line 38, in transcribe_audio                                            audio = whisper.load_audio(video_file_path)                                                                     
  File "/ASR_subtitles/venv/lib/python3.9/site-packages/whisper/audio.py", line 61, in load_audio       raise RuntimeError(f"Failed to load audio: {e.stderr.decode()}") from e
RuntimeError: Failed to load audio: ffmpeg version 4.2.7-0ubuntu0.1 Copyright (c) 2000-2022 the FFmpeg developers     built with gcc 9 (Ubuntu 9.4.0-1ubuntu1~20.04.1)  
...
Output file #0 does not contain any stream

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant