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

don't read *.mp4 file #75

Closed
vah13 opened this issue Oct 5, 2014 · 11 comments
Closed

don't read *.mp4 file #75

vah13 opened this issue Oct 5, 2014 · 11 comments

Comments

@vah13
Copy link

vah13 commented Oct 5, 2014

Hi.
I have some problems.
I have debian server where installed moviepy and ffmpeg . I want to create gif from *.mp4 video but look what write.

-------------gif creator script---------------
from moviepy.editor import *

anna_olaf = (VideoFileClip("c5baba648903aefc48771937de56918f.mp4")
.subclip(1,1)
.speedx(0.5) # Play at half speed
.resize(.4))

snapshot = (anna_olaf
.crop(x2= anna_olaf.w/2) # remove right half
.to_ImageClip(0.2) # snapshot of the clip at t=0.2s
.set_duration(anna_olaf.duration))

composition = CompositeVideoClip([anna_olaf, snapshot])
composition.write_gif('anna_olaf.gif', fp

s=15)

video http://109.120.161.43/uploads/c5baba648903aefc48771937de56918f.mp4

return message

root@vps-1049546:~# python /var/www/uploads/gif.py
Traceback (most recent call last):
File "/var/www/uploads/gif.py", line 3, in
clip = (VideoFileClip("c5baba648903aefc48771937de56918f.mp4")
File "/usr/local/lib/python2.7/dist-packages/moviepy-0.2.1.8.12-py2.7.egg/moviepy/video/io/VideoFileClip.py", line 55, in init
self.reader = FFMPEG_VideoReader(filename, pix_fmt=pix_fmt)
File "/usr/local/lib/python2.7/dist-packages/moviepy-0.2.1.8.12-py2.7.egg/moviepy/video/io/ffmpeg_reader.py", line 22, in init
infos = ffmpeg_parse_infos(filename, print_infos, check_duration)
File "/usr/local/lib/python2.7/dist-packages/moviepy-0.2.1.8.12-py2.7.egg/moviepy/video/io/ffmpeg_reader.py", line 225, in ffmpeg_parse_infos
"path.")%filename)
IOError: MoviePy error: the file c5baba648903aefc48771937de56918f.mp4 could not be found !
Please check that you entered the correct path.
Exception AttributeError: "VideoFileClip instance has no attribute 'reader'" in <bound method VideoFileClip.del of <moviepy.video.io.VideoFileClip.VideoFileClip instance at 0x7f2dc57e1320>> ignored

please help, what I doing not true?

@vah13
Copy link
Author

vah13 commented Oct 5, 2014

I upgraded ffmpeg and work all, but don't can write gif on file

<moviepy.video.io.VideoFileClip.VideoFileClip instance at 0x2fc1b00>
<moviepy.video.compositing.CompositeVideoClip.CompositeVideoClip instance at 0x2fc1cf8>
Traceback (most recent call last):
File "gif.py", line 15, in
composition.write_gif('anna_olaf.gif',fps=24)
File "", line 2, in write_gif
File "/usr/local/lib/python2.7/dist-packages/moviepy-0.2.1.8.12-py2.7.egg/moviepy/decorators.py", line 49, in requires_duration
return f(clip, _a, *_k)
File "/usr/local/lib/python2.7/dist-packages/moviepy-0.2.1.8.12-py2.7.egg/moviepy/video/VideoClip.py", line 435, in write_gif
dispose= dispose, colors=colors)
File "", line 2, in write_gif
File "/usr/local/lib/python2.7/dist-packages/moviepy-0.2.1.8.12-py2.7.egg/moviepy/decorators.py", line 49, in requires_duration
return f(clip, _a, *_k)
File "/usr/local/lib/python2.7/dist-packages/moviepy-0.2.1.8.12-py2.7.egg/moviepy/video/io/gif_writers.py", line 186, in write_gif
stdout=sp.PIPE)
File "/usr/lib/python2.7/subprocess.py", line 679, in init
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1259, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory

on ./ directory created anna_olaf.gif file

python code

from moviepy.editor import *

anna_olaf = (VideoFileClip("c5baba648903aefc48771937de56918f.mp4")
.subclip((0,01.65),(0,01.70))
.resize(0.3))
print anna_olaf
snapshot = (anna_olaf
.crop(x2= anna_olaf.w/2) # remove right half
.to_ImageClip(0.2) # snapshot of the clip at t=0.2s
.set_duration(anna_olaf.duration))

composition = CompositeVideoClip([anna_olaf, snapshot])
print composition
composition.write_gif('anna_olaf.gif',fps=24)

@vah13
Copy link
Author

vah13 commented Oct 5, 2014

I want to write to file 1.56, 1.67, 1,80,1.89 frame. how I can create this. please help

@Zulko
Copy link
Owner

Zulko commented Oct 5, 2014

Have you installed ImageMagick ?

@vah13
Copy link
Author

vah13 commented Oct 6, 2014

I installed and all OK, thank you very much, sorry for stupid question :)

@Zulko
Copy link
Owner

Zulko commented Oct 6, 2014

Problem solved :)

@Zulko Zulko closed this as completed Oct 6, 2014
@Zulko
Copy link
Owner

Zulko commented Oct 9, 2014

By the way, what do you mean by this -> "I want to write to file 1.56, 1.67, 1,80,1.89 frame."
Can you give more details ?

@vah13
Copy link
Author

vah13 commented Oct 9, 2014

Yes of course. For example I have video 3 sec. I want to get Image frame from video in 1sec 56 ms, 1 sec. 67 ms ...

@Zulko
Copy link
Owner

Zulko commented Oct 9, 2014

What I didn't understand is what you want to do with these. I mean, if you just want the arrays that correspond to the images (these will be numpy arrays), you write

im1 = myclip.get_frame(1.56)
im2 = myclip.get_frame(1.67)
# etc...

If you want to save these frames as image files you will write

myclip.save_frame("my_image1.png", t=1.56) # you can also ask .jpeg, .tiff, etc.
myclip.save_frame("my_image2.png", t=1.67)
# etc.

Did that answer your question ?

@vah13
Copy link
Author

vah13 commented Oct 12, 2014

yes thanks)

@Zulko
Copy link
Owner

Zulko commented Oct 12, 2014

Cool !

@hgillh
Copy link

hgillh commented May 11, 2016

Hi @Zulko ,
I am facing same issue on my Ubuntu 14.04 system. I have installed imagemagick. But still getting same error.
Following is my code

from moviepy import editor
video = editor.VideoFileClip("/var/www/sites/site1/videos/video.mp4")
result = editor.CompositeVideoClip([video]).resize( (720 , 547) )
result.write_videofile("/var/www/sites/site1/videos/new_test.mp4", fps=24)

Error details are as following

Traceback (most recent call last):
File "test_video.py", line 8, in
video = editor.VideoFileClip("test_video.mp4")#.subclip(0,10)
File "/usr/local/lib/python2.7/dist-packages/moviepy-0.2.2.11-py2.7.egg/moviepy/video/io/VideoFileClip.py", line 55, in init
reader = FFMPEG_VideoReader(filename, pix_fmt=pix_fmt)
File "/usr/local/lib/python2.7/dist-packages/moviepy-0.2.2.11-py2.7.egg/moviepy/video/io/ffmpeg_reader.py", line 32, in init
infos = ffmpeg_parse_infos(filename, print_infos, check_duration)
File "/usr/local/lib/python2.7/dist-packages/moviepy-0.2.2.11-py2.7.egg/moviepy/video/io/ffmpeg_reader.py", line 253, in ffmpeg_parse_infos
"path.")%filename)
IOError: MoviePy error: the file test_video.mp4 could not be found !
Please check that you entered the correct path.
Exception AttributeError: "VideoFileClip instance has no attribute 'reader'" in <bound method VideoFileClip.del of <moviepy.video.io.VideoFileClip.VideoFileClip instance at 0x7fd4947bb560>> ignored

Please help me to get it working.

Thanks

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