moviepy: Problem with writing audio

Hey there. I’m experiencing a problem when writing audio. If I call .to_videofile with audio=False, then there is no problem. My videopy version number is 0.2.1.8.02.

The video I’m working with is here: https://www.dropbox.com/s/iepmbyieferjbay/test.MP4

The code is here:

clip = mp.VideoFileClip('../snowsports/test.MP4').subclip(220,224)
clip.to_videofile("test-short.MP4")

There error message is:

MoviePy: building video file test-short.MP4
----------------------------------------
Writing audio in test-shortTEMP_MPY_to_videofile_SOUND.ogg
Done writing Audio in test-shortTEMP_MPY_to_videofile_SOUND.ogg !

Writing video into test-shortTEMP_MPY_to_videofile.MP4
Done writing video in test-shortTEMP_MPY_to_videofile.MP4 !

Now merging video and audio:

MoviePy Running:
>>> ffmpeg -y -i test-shortTEMP_MPY_to_videofile_SOUND.ogg -i test-shortTEMP_MPY_to_videofile.MP4 -vcodec copy -acodec copy test-short.MP4
MoviePy: WARNING !
   The following command returned an error:
ffmpeg version 2.2.3 Copyright (c) 2000-2014 the FFmpeg developers
  built on Jun  3 2014 06:47:04 with Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/2.2.3 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-nonfree --enable-hardcoded-tables --enable-avresample --enable-vda --cc=clang --host-cflags= --host-ldflags= --enable-libx264 --enable-libfaac --enable-libmp3lame --enable-libxvid
  libavutil      52. 66.100 / 52. 66.100
  libavcodec     55. 52.102 / 55. 52.102
  libavformat    55. 33.100 / 55. 33.100
  libavdevice    55. 10.100 / 55. 10.100
  libavfilter     4.  2.100 /  4.  2.100
  libavresample   1.  2.  0 /  1.  2.  0
  libswscale      2.  5.102 /  2.  5.102
  libswresample   0. 18.100 /  0. 18.100
  libpostproc    52.  3.100 / 52.  3.100
test-shortTEMP_MPY_to_videofile_SOUND.ogg: No such file or directory
Conversion failed!
---------------------------------------------------------------------------
IOError                                   Traceback (most recent call last)
<ipython-input-13-b6f4d3578283> in <module>()
      1 clip = mp.VideoFileClip('../snowsports/test.MP4').subclip(220,224)
----> 2 clip.to_videofile("test-short.MP4")

/usr/local/lib/python2.7/site-packages/moviepy/video/VideoClip.pyc in to_videofile(self, filename, fps, codec, bitrate, audio, audio_fps, audio_nbytes, audio_codec, audio_bitrate, audio_bufsize, temp_audiofile, rewrite_audio, remove_temp, write_logfile, para, verbose)
    286             verbose_print("\n\nNow merging video and audio:\n")
    287             ffmpeg_merge_video_audio(videofile,temp_audiofile,
--> 288                                   filename, ffmpeg_output=True)
    289 
    290             if remove_temp:

/usr/local/lib/python2.7/site-packages/moviepy/video/io/ffmpeg_tools.pyc in ffmpeg_merge_video_audio(video, audio, output, vcodec, acodec, ffmpeg_output, verbose)
     49              "-vcodec", vcodec, "-acodec", acodec, output]
     50 
---> 51     subprocess_call(cmd, verbose = verbose)
     52 
     53 

/usr/local/lib/python2.7/site-packages/moviepy/tools.pyc in subprocess_call(cmd, verbose, errorprint)
     33                     "   The following command returned an error:\n")
     34             sys_write_flush( err.decode('utf8'))
---> 35         raise IOError
     36     else:
     37         verboseprint( "\n... command successful.\n")

IOError: 

I’ve also tried explicitly specifying the codec as ‘mpeg4’. I’m not sure if that makes any difference, but the result is the same.

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Comments: 21 (6 by maintainers)

Most upvoted comments

This worked for me to get the file to play in Quicktime/iMovie:

clip.write_videofile(out_path, 
  codec='libx264', 
  audio_codec='aac', 
  temp_audiofile='temp-audio.m4a', 
  remove_temp=True
)

On the videogrep page they say to install ffmpeg with

brew install ffmpeg --with-libvpx --with-libvorbis

But you should give up with libvorbis and try to understand why it doesn’t even work with mp3, that would be simpler. You said there is no sound: with what software are you playing it ? Could you try playing it with VLC and see if there is still no sound ?