Zulko / moviepy

Video editing with Python
https://zulko.github.io/moviepy/
MIT License
12.07k stars 1.51k forks source link

ffmpeg does not allow None as fps argument #2125

Open BreuerChristian opened 4 months ago

BreuerChristian commented 4 months ago

Expected Behavior

I combine mp4 and mp3 and get that error

Actual Behavior

File "C:\X\venv\Lib\site-packages\moviepy\video\VideoClip.py", line 300, in write_videofile ffmpeg_write_video(self, filename, fps, codec, File "C:\X\venv\Lib\site-packages\moviepy\video\io\ffmpeg_writer.py", line 212, in ffmpeg_write_video with FFMPEG_VideoWriter(filename, clip.size, fps, codec = codec, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\X\venv\Lib\site-packages\moviepy\video\io\ffmpeg_writer.py", line 86, in init '-r', '%.02f' % fps,


TypeError: must be real number, not NoneType

#### Steps to Reproduce the Problem
<!-- Please include code that demonstrates this problem so that we can reproduce it. For advice on how to do this, see https://stackoverflow.com/help/mcve -->
I am not familiar with the fps fancy stuff 
but i found out that the none is not allowed for ffmpeg as fps
Thatfore i added the code in the function ffmpeg_write_video

    if fps==None:
        fps=24

After that it worked

#### Specifications

  - Python Version: 3.12.2
  - MoviePy Version: 1.0.3
  - Platform Name: Windows 64
keikoro commented 3 months ago

Please always include code samples for reproducability and complete logs for errors where applicable (code-formatted text only, no screenshots).

The wording under "Steps to Reproduce the Problem" seems to suggest this was your attempt at a fix, not the original code that resulted in your issue. Either way, this is not how you'd check for the existence of fps, see the second bullet point in this section in PEP8 ("Comparisons to singletons like None...").

keikoro commented 3 months ago

I'm assuming this is a duplicate of #2041 #1986, in which case this issue should be closed in favour of the older one.