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.

Error when writing video file out

See original GitHub issue

Expected Behavior

Using write_videofile("data/output.mp4", fps='30') should produce a video file at data/output.mp4

Actual Behavior

Moviepy throws an error TypeError: must be real number, not str from the file ffmpeg_writer.py and exits the program.

Steps to Reproduce the Problem

Below I have included the section of code that is responsible for actually generating and saving the video file to the disk

clipData = []
for path in clipPaths:
     newClip = VideoFileClip(path)
    normalClip = audio_normalize(VideoFileClip(path))
    clipData.append(newClip)
finalVideo = concatenate_videoclips(clipData, method='compose')
finalVideo.write_videofile("data/output.mp4", fps='30')
  • clipPaths is a list of paths to the clips that I am using to make the video.

I have also included the full stack trace that I get when I run the code

Moviepy - Building video data/output.mp4.
MoviePy - Writing audio in outputTEMP_MPY_wvf_snd.mp3
MoviePy - Done.                                                                                                                                                                               
Moviepy - Writing video data/output.mp4

Traceback (most recent call last):
  File "src/videoEditor.py", line 60, in <module>
    globals()[sys.argv[1]]()
  File "src/videoEditor.py", line 51, in GenerateVideo
    finalVideo.write_videofile("data/output.mp4", fps='30')
  File "<decorator-gen-55>", line 2, in write_videofile
  File "/home/mwollam/.local/lib/python3.8/site-packages/moviepy/decorators.py", line 54, in requires_duration
    return f(clip, *a, **k)
  File "<decorator-gen-54>", line 2, in write_videofile
  File "/home/mwollam/.local/lib/python3.8/site-packages/moviepy/decorators.py", line 135, in use_clip_fps_by_default
    return f(clip, *new_a, **new_kw)
  File "<decorator-gen-53>", line 2, in write_videofile
  File "/home/mwollam/.local/lib/python3.8/site-packages/moviepy/decorators.py", line 22, in convert_masks_to_RGB
    return f(clip, *a, **k)
  File "/home/mwollam/.local/lib/python3.8/site-packages/moviepy/video/VideoClip.py", line 300, in write_videofile
    ffmpeg_write_video(self, filename, fps, codec,
  File "/home/mwollam/.local/lib/python3.8/site-packages/moviepy/video/io/ffmpeg_writer.py", line 213, in ffmpeg_write_video
    with FFMPEG_VideoWriter(filename, clip.size, fps, codec = codec,
  File "/home/mwollam/.local/lib/python3.8/site-packages/moviepy/video/io/ffmpeg_writer.py", line 88, in __init__
    '-r', '%.02f' % fps,
TypeError: must be real number, not str

Specifications

  • Python Version: Python 3.8.2
  • Moviepy Version: moviepy 1.0.3
  • Platform Name: Ubuntu 20.04.1 LTS

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11

github_iconTop GitHub Comments

4reactions
smidmcommented, Nov 18, 2021

This happens when moviepy and decorator modules are not compatible (e.g. after the decorator module was upgraded to the last version).

This should solve the issue:

pip uninstall moviepy decorator
pip install moviepy
2reactions
SattyAGcommented, Jul 7, 2021

Hi, In my code, I am facing the error TypeError: must be real number, not NoneType and it’s after the first two lines in output section:

Moviepy - Building video data/output.mp4.
MoviePy - Writing audio in outputTEMP_MPY_wvf_snd.mp3

I have set fps as fps=clip.fps where clip contains the original video file.

It worked after upgrading moviepy.

Thank you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error in writing video file using moviepy and ffmpeg
I have a list of start and end time. video = VideoFileClip("videoFile.mp4") clips = [] for cut in cuts: clip = video.
Read more >
20 most common video errors & how to fix them
This article guide you how to fix all 20 problems or errors while playing videos like playback errors, audio video sync, issues, choppy, ......
Read more >
Fix export issues in Premiere Pro - Adobe Support
Fix common export issues in 7 simple steps · Choose File > Project Settings > General. The Project Settings window opens. · In...
Read more >
error in making video file - MATLAB Answers - MathWorks
step(videoFWriter, videoFrame); % write video to myFile.avi. end. release(videoFReader); % close the input file. release(videoFWriter); % close the output ...
Read more >
Error at 17% exporting mp4 file - Help/How To - Shotcut Forum
[consumer avformat] error writing video frame: -28. I do not know why this occurred. Maybe you ran out of disk space?
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