nbixler
nbixler

Reputation: 522

How to fix "some_number bytes wanted, 0 bytes read error on moviepy vfx"

I'm using moviepy to write code that lets me apply a variety of vfx edits to an uploaded video file (crop to specific aspect ratios, overlay static images, and lighten or darken the video). The code does what I want it to do, but after the first few seconds, the returned video freezes (though the audio continues).

I've looked around the internet for similar issues and haven't found much. https://groups.google.com/forum/#!topic/imageio/kx0R0JQ6RVA suggested that imageio sometimes has to estimate the number of frames and https://github.com/Zulko/moviepy/issues/86 suggested that ffmpeg cannot read some frames (and that it's more prone with webcam based video - which my files are).

My current error: (I'm receiving it multiple times so I used xxx, yyy, and zzz to designate various numbers) WARNING:py.warnings: .../moviepy-1.0.0-py3.7.egg/moviepy/video/io/ffmpeg_reader.py:130: UserWarning: Warning: in file /codebase/my_video_file.mp4, xxx bytes wanted but 0 bytes read, at frame yyy/total, at time zzz/total sec. Using the last valid frame instead.

I am successfully cropping/lightening/darkening/overlaying my videos, but after a few seconds the video stops (presumably each frame after the first few seconds worth are simply copies of the previous one) while the audio continues, so I know the video file is continuing to play.

EDIT (8/14): I processed a video without any changes (so no gamma_corr and no CompositeVideoClip) and still had the same result - so it isn't a frame size error.

Upvotes: 2

Views: 3999

Answers (1)

nbixler
nbixler

Reputation: 522

(Caveat) I don't know that this error is always fixed by the solution at which I arrived.

Turns out I was saving the edited video to the same path as the input video, overwriting the original video (which I was fine with). By adding a temporary location, then renaming, I was able to use the same path while avoiding the issue. I now receive the full video with video effects in place.

vl_sans_mp4 = video_location[0:-4] temp_location = vl_sans_mp4 + "temp" + ".mp4" original_video.write_videofile(temp_location, fps=30, bitrate="90k", audio_bitrate="128k") os.rename(video_location, vl_sans_mp4 + "input" + '.mp4') os.rename(temp_location, video_location)

Upvotes: 5

Related Questions