question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

write_videofile() appears fundamentally broken

See original GitHub issue

Moviepy function write_videofile() works with static filename parameters, (i.e. "this_is_my_file.mp4") but does not work as intended when variables are passed into the filename parameter (i.e. my_variable = "a dynamic filename"). The resulting video possess audio, but is always frozen on the first frame.

Expected Behavior

production of video files with dynamic file names.

Actual Behavior

produces a video with the audio and the correct filename, but video is frozen on the first frame.

Steps to Reproduce the Problem

my_clip.write_videofile("meaty_chungus.mp4") #works

meaty_chungus = "meaty_chungus"
my_clip.write_videofile(meaty_chungus + ".mp4") #produces a video with the audio and the correct filename, but video is frozen on the first frame. 

Specifications

  • Python Version: 3.x
  • Moviepy Version: most recent
  • Platform Name: Windows
  • Platform Version: 10

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:21

github_iconTop GitHub Comments

2reactions
tburrows13commented, Feb 10, 2021

I’m going to close this unless anyone can provide anymore examples that should fail.

2reactions
tburrows13commented, Feb 10, 2021

Hey @LYLeon, like I said earlier in this thread, I’ve not been able to replicate it. If you’d be able to provide the exact code and input files that you used to demonstrate this bug then I’ll take a look 😃

I’m also experiencing this issue. Using the code and file you provided I was unable to reproduce the bug. However, with a small tweak in your code, that seemingly shouldn’t matter, I get the freezing issue in every output clip. Here is the code I was able to use to recreate the issue while also using your provided video file:

import moviepy

from moviepy.editor import VideoFileClip

name = "small.mp4"
my_clip = VideoFileClip(name)
my_clip.write_videofile(name)

some_file_name = "some_file_name"
my_clip.write_videofile(some_file_name + ".mp4")

some_file_name = "another_name"
my_clip.write_videofile(some_file_name + ".mp4")

Now can we look into it? or is there something I’m fundamentally not seeing that is wrong for overwriting.

@monkfacedmonkey This code can never work because you are overwriting the source file whilst you are reading from it. When I run that code, I get lots of warning telling me that it is trying to read bytes, but can’t so it is using the last valid frames instead. If you run it on a video that is moving throughout, you’ll see that it works for the 1st second or so, which is the data that ffmpeg has cached. At that point it fails to read more and freezes on the frame for the rest of it.

Maybe it should give a better warning or error completely somewhere in the process, but there are no bugs there that I can see.

Read more comments on GitHub >

github_iconTop Results From Across the Web

movie-py/Lobby - Gitter
Hi guys! I'm concatenating a list of video objects together then writing them with write_videofile, weirdly enough the first time I write the...
Read more >
MoviePy and python3 | Scientific logbook - Laurent Perrinet
... was using python 2, but seems to be broken when using python 3: (The video generated by animation.write_videofile("circles.mp4", fps=20).
Read more >
Moviepy write_videofile works the second time but not the first?
It seems there is no set point where it breaks, each time I write it for the first time it typically breaks at...
Read more >
moviepy - Bountysource
They cause Errno 32 Broken Pipe whenever the packaged app calls VideoClip.write_videofile. The code which calls tdqm is in Clip.iter_frames, ...
Read more >
Lightweight python motion detection - Page 9
I notice this all looks a lot like the code in the thread over at ... save circular buffer before motion event write_video(stream)...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found