hayabhay / frogbase

Transform audio-visual content into navigable knowledge.
https://frogbase.dev
MIT License
781 stars 95 forks source link

File uploads fail to transcribe unless they are MP4 format. #12

Closed tuxpowered closed 1 year ago

tuxpowered commented 1 year ago

Trying to upload a PCM wav file, MP3 audio fail to process due to error. (Uploading a wav file gives a codec error) however converting the file to mp4 the process works.

  Metadata:
    encoder         : Lavf56.40.101
  Duration: 00:08:55.75, start: 0.138125, bitrate: 64 kb/s
  Stream #0:0: Audio: mp3, 8000 Hz, mono, fltp, 64 kb/s
[mp4 @ 0x7f970a304ec0] track 0: muxing mp3 at 8000hz is not standard, to mux anyway set strict to -1
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
Error initializing output stream 0:0 --
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
    Last message repeated 1 times
2023-01-25 11:30:51.555 Uncaught app exception
Traceback (most recent call last):
  File "/Users/ben/Developer/whisper-ui/.venv/lib/python3.10/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 565, in _run_script
    exec(code, module.__dict__)
  File "/Users/ben/Developer/whisper-ui/01_Transcribe.py", line 66, in <module>
    st.session_state.transcription = Transcription(name, input_file, "file", start, duration)
  File "/Users/ben/Developer/whisper-ui/transcriber.py", line 54, in __init__
    ffmpeg.run(audio, overwrite_output=True)
  File "/Users/ben/Developer/whisper-ui/.venv/lib/python3.10/site-packages/ffmpeg/_run.py", line 325, in run
    raise Error('ffmpeg', out, err)
ffmpeg._run.Error: ffmpeg error (see stderr output for detail)

The current work around is to convert the file to wav then back to mp4

ffmpeg -i src.mp3 audio.wav
ffmpeg -i audio.wav audio.mp4
hayabhay commented 1 year ago

This shouldn't surface now. Previously audio files were trimmed and now that feature is removed which means files are stored as-is. So this error shouldn't surface as long as Whisper can understand the native format. Please raise this issue again if it reappears (see #13)