moviepy
moviepy copied to clipboard
WriteVideoFile not working in compiled .app
Expected Behavior
When running moviepy from my script through the console the movie file writes correctly and without error. Here is the snippet below that writes my clip, then writes my moviefile.
Actual Behavior
When compiling the app with pyinstaller --noconsole, the app crashes when attempting to write the video file. Since this only occurs when in the no console app I wrote in a logger to catch the stdout. When opening the file it looks like the issue is occurring when trying yo write the audio back into the video. Here is the output:
MoviePy - Writing audio in tempTEMP_MPY_wvf_snd.mp4
Steps to Reproduce the Problem
The error only occurs in the no console mode after compiling the app. The code below works with the console open.
def save_clip(self):
clip = self.clip
if float(self.convert_to_seconds(self.end_time.get())) > clip.duration:
self.end_time.set(clip.duration)
if float(self.convert_to_seconds(self.start_time.get())) < 0:
self.start_time.set("0:00")
clip = clip.subclip(self.convert_to_seconds(self.start_time.get()),self.convert_to_seconds(self.end_time.get()))
return clip
def save_video(self):
clip = self.save_clip()
directory = filedialog.asksaveasfilename(filetypes=(("MP4", "*.mp4"),("All Files", "*.*")), defaultextension='.mp4', initialdir=f'{os.path.expanduser}/Downloads', title="Video Clip", initialfile="clip")
if not directory:
self.progress_bar_stop()
return
try:
path = self.downloads + '/logger.txt'
sys.stdout = open(path, 'w')
#shutil.move(f'{self.directory}/{self.video}', directory)
clip.write_videofile(f'{directory}', audio_codec='aac')
self.progress_bar_stop()
messagebox.showinfo(title="Success!", message=f'Clip Saved: {directory}')
except:
messagebox.showerror(message='Your clip was unable to be made. Please reupload your video and try again.')
Specifications
- Python Version: 3.12
- MoviePy Version: 1.0.3
- Platform Name: MAC OS
- Platform Version: 12.7.1
After adding a stderr logger I now see this error message:
chunk: 0%| | 0/111 [00:00<?, ?it/s, now=None]Exception ignored in: <function FFMPEG_AudioWriter.__del__ at 0x11538e340>
Traceback (most recent call last):
File "moviepy/audio/io/ffmpeg_audiowriter.py", line 132, in __del__
File "moviepy/audio/io/ffmpeg_audiowriter.py", line 121, in close
BrokenPipeError: [Errno 32] Broken pipe