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

ffmpeg_writer.py #50

Closed
ghost opened this issue Jun 22, 2014 · 3 comments
Closed

ffmpeg_writer.py #50

ghost opened this issue Jun 22, 2014 · 3 comments

Comments

@ghost
Copy link

ghost commented Jun 22, 2014

Hi when I do something like:

myVideoClip.to_videoFile("myFileName.mp4", codec="libx264")

I get a broken pipe error which originates from where ffmpeg_writer.py create the ffmpeg subprocess around line 78:

        cmd = (
            [ FFMPEG_BINARY, '-y',
            "-loglevel", "panic" if logfile==DEVNULL else "info",
            "-f", 'rawvideo',
            "-vcodec","rawvideo",
            '-s', "%dx%d"%(size[0],size[1]),
            '-pix_fmt', "rgba" if withmask else "rgb24",
            '-r', "%.02f"%fps,
            '-i', '-', '-an',
            '-vcodec', 'libx264']
            + (['-b',bitrate] if (bitrate!=None) else [])

            # http://trac.ffmpeg.org/ticket/658
            + (['-pix_fmt', 'yuv420p']
                  if ((codec == 'libx264') and
                     (size[0]%2 == 0) and
                     (size[1]%2 == 0))

               else [])

            + [ '-r', "%d"%fps, filename]
            )

        self.proc = sp.Popen(cmd, stdin=sp.PIPE,
                                  stderr=logfile,
                                  stdout=DEVNULL)

If you remove the line '-vcodec', 'libx264' parameter it seems to work. I don't know why this causes an error, or how to resolve it so that a codec can be specified. Maybe stderr could provide some useful information here.

@Zulko
Copy link
Owner

Zulko commented Jun 22, 2014

It would mean that you don't have the codec libx264 which is the default codec in moviepy (because most distributions have it). You can install it from the repos on Ubuntu/Debian. You can also try another codec that you might already have :

clip.to_videofile("test.mp4", codec= 'mpeg4')

Or change the format (and the codec):

clip.to_videofile("test.ogv", codec= 'libtheora')
clip.to_videofile('test.webm', codec='libvpx')

See the doc of clip.to_videofile for more infos.

PS: it's strange that in the code you give one line looks like

'-vcodec', 'libx264']

while it should be

'-vcodec', codec]

@ghost
Copy link
Author

ghost commented Jun 22, 2014

The code was different because I tried to set a specific codec, in order to rule out other potential issues. However, I think you're right about the codec not being installed. I recently rebuilt ffmpeg and it looks like I forgot to configure the build to include libx264 support. I'm currently rebuilding ffmpeg and fingers crossed it will work this time!

Edit: Now it works!

@Zulko
Copy link
Owner

Zulko commented Jun 25, 2014

I didn't see the edit. Very cool, I am closing the issue.

@Zulko Zulko closed this as completed Jun 25, 2014
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

1 participant