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.

Concatenating subclips: "AttributeError: 'CompositeAudioClip' object has no attribute 'fps'"

See original GitHub issue

Expected Behavior

Concatenates and plays composite video file.

Actual Behavior

Preview freezes on first frame with the following output:

pygame 1.9.4
Hello from the pygame community. https://www.pygame.org/contribute.html
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python3.7/threading.py", line 917, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.7/threading.py", line 865, in run
    self._target(*self._args, **self._kwargs)
  File "<decorator-gen-100>", line 2, in preview
  File "/usr/lib/python3.7/site-packages/moviepy/decorators.py", line 54, in requires_duration
    return f(clip, *a, **k)
  File "/usr/lib/python3.7/site-packages/moviepy/audio/io/preview.py", line 49, in preview
    sndarray = clip.to_soundarray(tt, nbytes=nbytes, quantize=True)
  File "<decorator-gen-72>", line 2, in to_soundarray
  File "/usr/lib/python3.7/site-packages/moviepy/decorators.py", line 54, in requires_duration
    return f(clip, *a, **k)
  File "/usr/lib/python3.7/site-packages/moviepy/audio/AudioClip.py", line 110, in to_soundarray
    fps = self.fps
AttributeError: 'CompositeAudioClip' object has no attribute 'fps'

Steps to Reproduce the Problem

#!/usr/bin/env python3

import moviepy.editor as mpy

clip=mpy.VideoFileClip("sample.mp4")
#clip=clip.without_audio()

subclip=mpy.concatenate_videoclips([clip.subclip((1,0),(2,0)),clip.subclip((3,0),(4,0)),clip.subclip((5,0),(6,0))])

subclip.preview()

Note that uncommenting the clip=clip.without_audio() removes the error.

Specifications

  • Python Version: 3.7.0
  • Moviepy Version: 0.2.3.5
  • Platform Name: Arch Linux
  • Platform Version: 4.18.12-arch1-1-ARCH

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:1
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
mislandcommented, Apr 22, 2020
final_clip = CompositeAudioClip(arr)
final_clip.fps = 44100
final_clip.write_audiofile('res.mp3')

maybe this is a workaround 😃

1reaction
astridcasadeicommented, Oct 26, 2020

I had the same problem as helasraizam when using ‘concatenate_videoclips’ and ‘preview’. His workaround didn’t work for me, but the following did:

#!/usr/bin/env python3

import moviepy.editor as mpy

clip=mpy.VideoFileClip("sample.mp4")

subclip=mpy.concatenate_videoclips([clip.subclip((1,0),(2,0)),clip.subclip((3,0),(4,0)),clip.subclip((5,0),(6,0))])
 
aud = subclip.audio.set_fps(44100)
subclip = subclip.without_audio().set_audio(aud)
subclip.preview()
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to combine 2 audio mp3s in moviepy? - Stack Overflow
I tried running the code bellow, but I get this error "AttributeError: 'CompositeAudioClip' object has no attribute 'fps'". How do I get this...
Read more >
moviepy - Bountysource
I have a problem with videos with different FPS and TBR. I open a video and try to render it: video = movieEditor.VideoFileClip('video.mp4')...
Read more >
CHANGELOG.md · Gitee 极速下载/moviepy - Gitee.com
... Fixed fps not defined in CompositeAudioClip at initialization #1462 ... with audio: AttributeError: 'NoneType' object has no attribute 'stdout' #1185 ...
Read more >
Vfx does funky things with funky errors that I cannot understand.
When you don't set audio to none, it has the error 'CompositeAudioClip' object has no attribute 'fps'. When you set it to none,...
Read more >
fix moviepy problem with pyinstaller - YouTube
AttributeError : module 'moviepy.audio.fx.all' has no attribute 'audio_fadein' ...
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