New to using streamlit, and really enjoying how easy it is to get projects running.
I have a project I am building out to create videos from text using several of the OpenAI API’s (DALLE, TTS, 3.5T) and have made it work locally with no problems. However, when deploying to streamlit cloud, I receive the error “No such file or directory: ‘ffprobe’” although I have ffmpeg in my packages.txt and ffmpeg-python==0.2.0 ffprobe==0.5 in my requirements.txt. Anyone experience a problem like this and know a solution?
Yes. I actually see it being installed in the logs here:
Stored in directory: /tmp/pip-ephem-wheel-cache-mg566x2y/wheels/ba/39/54/c8f7ff9a88a644d3c58b4dec802d90b79a2e0fb2a6b884bf82
Building wheel for ffprobe (setup.py): started
Building wheel for ffprobe (setup.py): finished with status ‘done’
Stored in directory: /tmp/pip-ephem-wheel-cache-mg566x2y/wheels/77/95/42/ec9cdac2db6ff5c7fafb2f430715681009ddd232c7704f517f
I solved this problem by using ffmpeg python wrapper rather than calling the binary. I made this helper function and called it in place of subprocess.run(ffmpeg).
def merge_audio_video(avi_video_path, full_narration_path, output_file_path):
“”"
Merge AVI video and MP3 narration into a final MP4 video using ffmpeg-python.
Parameters:
- avi_video_path: Path to the AVI video file.
- full_narration_path: Path to the MP3 narration audio file.
- output_file_path: Path for the output MP4 video file.
"""
try:
# Input streams
video_input = ffmpeg.input(avi_video_path)
audio_input = ffmpeg.input(full_narration_path)
# Merge video and audio with the specified output format and codec options
(
ffmpeg
.output(video_input['v'], audio_input['a'], output_file_path, vcodec='copy', acodec='aac', strict='experimental', shortest=None)
.run(overwrite_output=True)
)
print("Video processing completed successfully.")
except ffmpeg.Error as e:
print(f"ffmpeg command failed: {e.stderr.decode()}")