Make ffmpeg operate directly on temp file #162
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In an attempt to figure out why .m4a files were resulting in empty transcripts, I tried running ffmpeg via the command line, and it had no problem converting it to a .wav file with the audio intact. My understanding is that the main reason .m4a files are different is that their metadata gets stored at the end of the file. Since our
load_audio
function was piping audio into ffmpeg, I think this was defeating ffmpeg's file format detection; it had no file extension since it was reading from stdin, and it could not determine the file type by looking at the beginning of the stream.I tried passing the filename instead of a file stream into the ffmpeg library, and sure enough, .m4a files are detected and handled properly. Since we use temp files to pass the audio from the web service to the worker, we're already guaranteed to have a file on disk for our use cases. So, I adapted
load_audio
to accept either a file object or a filename string, and made our web service pass the filename instead. Fixes #160