Coder Social home page Coder Social logo

Comments (24)

codelucas avatar codelucas commented on May 20, 2024

Update, I tried this again on a different console and got some text output:

/local/lib/python2.7/site-packages/moviepy/video/io/ffmpeg_reader.py", line 94, in read_frame
 ... dtype='uint8').reshape((h,w,len(s)/(w*h)))
ValueError: total size of new array must be unchanged

from moviepy.

Zulko avatar Zulko commented on May 20, 2024

Ok, you have the same problem as the other Ubuntu users: FFMPEG is unmaintained on Ubuntu. Install the last FFMPEG version (this means go to the FFMPEG site, download the binary put it in your usr/bin folder). This should work.

from moviepy.

codelucas avatar codelucas commented on May 20, 2024

Thanks for the fast reply, will try it now and close if it works!

from moviepy.

codelucas avatar codelucas commented on May 20, 2024

I installed the ffmpeg binary from the site as you said:

Here is my current ffmpeg version:

$ ffmpeg
ffmpeg version 0.10.9-7:0.10.9-1~precise1 Copyright (c) 2000-2013 the FFmpeg developers
built on Oct  4 2013 06:37:30 with gcc 4.6.3

Unfortunately, I am getting new errors when writing to video: final_clip.to_videofile("solution.avi", fps=25, codec='mpeg4')

>>>
Making file solution.avi ...
Rendering audio TEMP_MPY_to_videofile_SOUND.ogg
        =Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/local/lib/python2.7/site-packages/moviepy/video/VideoClip.py", line 254, in to_videofile audio_bufsize, audio_codec, audio_bitrate, verbose)

File "/local/lib/python2.7/site-packages/moviepy/audio/AudioClip.py", line 86, in to_audiofile                                                                                                                      codec, bitrate, verbose)

File "<string>", line 2, in ffmpeg_audiowrite File "/local/lib/python2.7/site-packages/moviepy/decorators.py", line 43, in requires_duration
 return f(clip, *a, **k) File "/local/lib/python2.7/site-packages/moviepy/audio/io/ffmpeg_audiowriter.py", line 89, in ffmpeg_audiowrite
                                                                                    writer.write_frames(sndarray)

File "/local/lib/python2.7/site-packages/moviepy/audio/io/ffmpeg_audiowriter.py", line 58, in write_frames
                                                                                                                         frames_array.tofile(self.proc.stdin)
              ValueError: 80000 requested and 49152 written

Perhaps I am installing the wrong binary from the ffmpeg website? May I have an exact version & url?

Thank you!

from moviepy.

Zulko avatar Zulko commented on May 20, 2024

I don't know. If you were able to open a video, your FFMPEG version should be perfectly valid. Maybe it is a codec thing. Does it work if you try other codecs ? like

final_clip.to_videofile("solution.mp4") # uses codec libx264
final_clip.to_videofile("solution.ogv", fps=25, codec=libtheora')

from moviepy.

codelucas avatar codelucas commented on May 20, 2024

Hm, both fail and with the same error as above, something to do with ffmpeg_audiowriter.py.

/local/lib/python2.7/site-packages/moviepy/audio/io/ffmpeg_audiowriter.py", line 58, in write_frames frames_array.tofile(self.proc.stdin)
ValueError: 80000 requested and 49152 written
/local/lib/python2.7/site-packages/moviepy/audio/io/ffmpeg_audiowriter.py", line 58, in write_frames
frames_array.tofile(self.proc.stdin)
ValueError: 80000 requested and 49152 written

from moviepy.

Zulko avatar Zulko commented on May 20, 2024

Ok, sorry, I misread your previous message... Seems like a real bug to me. The audio support is not a part of the code that I am proud of. However I have made a lot of videos with audio and never had this problem, that's interesting. Could you give me more details on what you are trying to do ? Like, is your video very short or something ? Did you mix different videos ?

could you try this (it will use another codec for the audio):

final_clip.audio.to_audiofile("test.mp3", codec='libmp3lame')

Just to be sure: I don't think this could be the problem, but your ffmpeg version seems a little old, you have much more recent versions at the bottom of this page:

http://ffmpeg.gusari.org/static/32bit/

And last hope, try reducing the audio buffering, that may be the issue:

final_clip.to_videofile("test.mp4",  audio_bufsize=5000)

from moviepy.

codelucas avatar codelucas commented on May 20, 2024

No worries! I switched to the latest 64bit ffmpeg and now the video.avi files are being generated properly!

However, I have 2 more (smaller) issues. When I save the video in .mp4 format (I know .avi is recommended), the audio is lost. How should I go about try to get a resulting .mp4 video?

Also, if I run the txt_clip = TextClip("sample txt", fontsize=20, color='white') command, (not even compositing it yet) I get an error for:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/local/lib/python2.7/site-packages/moviepy/video/VideoClip.py", line 837, in __init__
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
 File "/usr/lib/python2.7/subprocess.py", line 679, in __init__ errread, errwrite)
 File "/usr/lib/python2.7/subprocess.py", line 1249, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory

Also, I notice a temp.txt file laying in the current directory with my set overlay text inside it. Maybe that is a clue.

Thanks for your fast responses so far man!

from moviepy.

Zulko avatar Zulko commented on May 20, 2024

For TextClip, I guess it is because you don't have ImageMagick installed on your computer. You need it to generate texts. It is very easy to install on ubuntu through the software manager, and there are less issues than with ffmpeg. You can check if you have ImageMagick installed with

convert -version

For your other point (no audio), once again it is strange. Could you copy the whole output of the .to_videofile ?

from moviepy.

codelucas avatar codelucas commented on May 20, 2024

Here is the full output of .to_videofile(..):

>>> Making file solution.mp4 ...
Rendering audio TEMP_MPY_to_videofile_SOUND.ogg
============audio done !Rendering video TEMP_MPY_to_videofile.mp4
==========video done ! Now merging video and audio...
Running:
>>> ffmpeg -y -i TEMP_MPY_to_videofile_SOUND.ogg -i TEMP_MPY_to_videofile.mp4 -vcodec copy -acodec copy solution.mp4
... ffmpeg command successful.
Your video is ready ! Fingers crossed for the Oscars !
>>> 

from moviepy.

Zulko avatar Zulko commented on May 20, 2024

This is strange, it looks like everything is run smoothly: apparently the sound file is correctly generated and incorporated into the movie. But I have heard that some media cannot read the sound of the videofile when it is .ogg ...
Could you try to_videofile('solution.mp4', remove_temp=False), this should keep a file called TEMP_MPY_to_videofile_SOUND.ogg in your directory. Is this file normal ? Can it play ?
Else you can change the audio codec (the choice of the codec was buggy, you would need to redownload moviepy from github for it to work), and run for instance to_videofile('test.mp4', audio_codec='mp3').

from moviepy.

codelucas avatar codelucas commented on May 20, 2024

Hmm, i went with your second suggestion.

I re-downloaded moviepy from Github and manually installed via setup.py. Then, attmped to use
to_videofile('test.mp4', audio_codec='mp3'). No errors occurred but the video was completely black with no sound.

from moviepy.

Zulko avatar Zulko commented on May 20, 2024

Even stranger. can you paste the output ? And when you just do to_videofile('test.mp4'), you have normal video (without sound) right ?

from moviepy.

codelucas avatar codelucas commented on May 20, 2024

For your first suggestion, when I set remove_temp=False the ogg file plays perfectly fine! Let me paste u the output now.

And yes, 'test.mp4' gives me a fine video but no sound.

from moviepy.

codelucas avatar codelucas commented on May 20, 2024

WAIT NO. ^ I was wrong. If I dont include fps=25, codec='mpeg4', then the video is black.

from moviepy.

codelucas avatar codelucas commented on May 20, 2024

Output for to_videofile('test.mp4', audio_codec='mp3')

Making file test.mp4 ...
Rendering audio TEMP_MPY_to_videofile_SOUND.mp3                                                                                                          ============audio done !Rendering video TEMP_MPY_to_videofile.mp4
==========video done !
Now merging video and audio...
Running:
>>> ffmpeg -y -i TEMP_MPY_to_videofile_SOUND.mp3 -i TEMP_MPY_to_videofile.mp4 -vcodec copy -acodec copy test.mp4
... ffmpeg command successful.

Your video is ready ! Fingers crossed for the Oscars !>>> 

from moviepy.

codelucas avatar codelucas commented on May 20, 2024

If I include codec='mpeg4' in the to_videofile('test.mp4', audio_codec='mp3') command, the video is present, but still no audio.

from moviepy.

Zulko avatar Zulko commented on May 20, 2024

Ok, I am lost, sorry. I may think of a solution later, but this really looks like an ffmpeg problem of some sort. Maybe we can see if someone else has the same problems.

from moviepy.

codelucas avatar codelucas commented on May 20, 2024

No worries! Ill install different versions of ffmpeg or try this on a different machine!

from moviepy.

Zulko avatar Zulko commented on May 20, 2024

Hey ! If you are still interested I made lots of change and there are good chances that the problem you described is solved (I would guess it was an incompatibility in the multiprocessing module, something like that). I would be very grateful if you gave it a try :)

from moviepy.

codelucas avatar codelucas commented on May 20, 2024

Awesome! THANK YOU for making all these changes. Will try tonight and report what happens.

from moviepy.

Zulko avatar Zulko commented on May 20, 2024

I can't promise anything :)

Le 21/02/2014 00:48, Lucas Ou-Yang a écrit :

Awesome! THANK YOU for making all these changes. Will try tonight and
report what happens.


Reply to this email directly or view it on GitHub
#9 (comment).

from moviepy.

codelucas avatar codelucas commented on May 20, 2024

.avi works.. but .mp4 results still contain no audio :(

I seriously think this is an ffmpeg issue where i'm probably installing the wrong thing.
Sorry haha

from moviepy.

Zulko avatar Zulko commented on May 20, 2024

Hey there. I'm closing this issue as old. The program is a lot better now I you want to give it another try :)

from moviepy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.