Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VideoClip has no attribute fps error when trying to concatenate #407

Closed
BrianLee608 opened this issue Feb 15, 2017 · 3 comments
Closed

VideoClip has no attribute fps error when trying to concatenate #407

BrianLee608 opened this issue Feb 15, 2017 · 3 comments

Comments

@BrianLee608
Copy link
Contributor

Hello, new to moviepy! I ran into an issue when trying to concatenate some mp4 files.

My code:

dir = '.'
files = glob.glob(os.path.join(dir, '*.mp4'))

clips = [VideoFileClip(f) for f in files]
final_clip = concatenate_videoclips(clips)
final_clip.write_videofile("my_concatenation.mp4")

Error:

Traceback (most recent call last):
File "autocomp.py", line 38, in
final_clip.write_videofile("my_concatenation.mp4")
File "", line 2, in write_videofile
File "/Users/brianlee/Envs/autocompenv/lib/python3.5/site-packages/moviepy/decorators.py", line 54, in requires_duration
return f(clip, *a, **k)
File "", line 2, in write_videofile
File "/Users/brianlee/Envs/autocompenv/lib/python3.5/site-packages/moviepy/decorators.py", line 133, in use_clip_fps_by_default
for (arg, name) in zip(a, names)]
File "/Users/brianlee/Envs/autocompenv/lib/python3.5/site-packages/moviepy/decorators.py", line 133, in
for (arg, name) in zip(a, names)]
File "/Users/brianlee/Envs/autocompenv/lib/python3.5/site-packages/moviepy/decorators.py", line 122, in fun
" the clip's fps with clip.fps=24"%f.name)
AttributeError: No 'fps' (frames per second) attribute specified for function write_videofile and the clip has no 'fps' attribute. Either provide e.g. fps=24 in the arguments of the function, or define the clip's fps with clip.fps=24

It looks like each clip in [clips] has an fps attribute (I can print them with)...
But when I tried to access the final_clip's fps attribute, it does not have one.

I have to write
final_clip.fps = 30
before calling
final_clip.write_videofile("my_concatenation.mp4")
in order to make it work. Is this a bug?

@Zulko
Copy link
Owner

Zulko commented Feb 15, 2017

concatenate will only attribute a fps to the final clip if all clips in the concatenation have the same fps, otherwise it's considered an ambiguous case and the user has to provide the fps. That's implemented in this line.

I see two possible actions: either document this behavior in concatenate's docstring, or make the default fps the largest fps in the list (I can't remember why I didnt do that at the time).

@tburrows13
Copy link
Collaborator

@Zulko I support your second option:

make the default fps the largest fps in the list

@ghost
Copy link

ghost commented Feb 28, 2017

a solution to this issue has been merged into the repo, so closing.

@ghost ghost closed this as completed Feb 28, 2017
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants