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

something went wrong with the audio writing, Exit code 1 #10

Closed
karpitsky opened this issue Feb 3, 2014 · 9 comments
Closed

something went wrong with the audio writing, Exit code 1 #10

karpitsky opened this issue Feb 3, 2014 · 9 comments
Labels
bug Issues that report (apparent) bugs.

Comments

@karpitsky
Copy link

My video file http://d.pr/v/dAcW

Open and save:

>>> from moviepy.editor import *
>>> video_clip = VideoFileClip('7e989f661a8c4821bb542f142a91a699')
>>> video_clip.to_videofile('x.mp4')
Making file x.mp4 ...
Writing audio/video in parrallel.
Rendering video TEMP_MPY_to_videofile.mp4
Rendering audio TEMP_MPY_to_videofile_SOUND.ogg
========audio done !==========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 x.mp4
... ffmpeg command successful.

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

Open and create a subclip:

>>> clip = video_clip.subclip(0, video_clip.duration)
>>> clip.to_videofile('x.mp4')
Making file x.mp4 ...
Writing audio/video in parrallel.
Rendering video TEMP_MPY_to_videofile.mp4
Rendering audio TEMP_MPY_to_videofile_SOUND.ogg
======Error: wrong indices in video buffer. Maybe buffer too small.
Process Process-2:
Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
    self.run()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/process.py", line 114, in run
    self._target(*self._args, **self._kwargs)
  File "<string>", line 2, in to_audiofile
  File "/Users/michael/Projects/lib/python2.7/site-packages/moviepy/decorators.py", line 43, in requires_duration
    return f(clip, *a, **k)
  File "/Users/michael/Projects/lib/python2.7/site-packages/moviepy/audio/AudioClip.py", line 81, in to_audiofile
    codec, bitrate, verbose)
  File "<string>", line 2, in ffmpeg_audiowrite
  File "/Users/michael/Projects/lib/python2.7/site-packages/moviepy/decorators.py", line 43, in requires_duration
    return f(clip, *a, **k)
  File "/Users/michael/Projects/lib/python2.7/site-packages/moviepy/audio/io/ffmpeg_audiowriter.py", line 88, in ffmpeg_audiowrite
    sndarray = clip.to_soundarray(tt,nbytes)
  File "<string>", line 2, in to_soundarray
  File "/Users/michael/Projects/lib/python2.7/site-packages/moviepy/decorators.py", line 43, in requires_duration
    return f(clip, *a, **k)
  File "/Users/michael/Projects/lib/python2.7/site-packages/moviepy/audio/AudioClip.py", line 65, in to_soundarray
    snd_array = self.get_frame(tt)
  File "/Users/michael/Projects/lib/python2.7/site-packages/moviepy/Clip.py", line 75, in <lambda>
    newclip = self.set_get_frame(lambda t: fl(gf, t))
  File "/Users/michael/Projects/lib/python2.7/site-packages/moviepy/Clip.py", line 115, in <lambda>
    return self.fl(lambda gf, t: gf(t_func(t)), applyto,
  File "/Users/michael/Projects/lib/python2.7/site-packages/moviepy/audio/io/AudioFileClip.py", line 71, in gf
    result[in_time] = self.buffer[inds - self._fstart_buffer]
IndexError: index 100000 is out of bounds for axis 0 with size 100000
==========video done !WARNING: something went wrong with the audio writing, Exit code 1

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 x.mp4
... ffmpeg command successful.

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

And the new video file is crashed.

@willperkins
Copy link

I am experiencing a similar issue

In [3]: movie.to_videofile("final.mp4", codec="mpeg4")
Making file final.mp4 ...
Rendering audio TEMP_MPY_to_videofile_SOUND.ogg
===========Error: wrong indices in video buffer. Maybe buffer too small.
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-3-1fd66c2da9ef> in <module>()
----> 1 movie.to_videofile("final.mp4", codec="mpeg4")

/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, para, verbose)
    271             if make_audio:
    272                 self.audio.to_audiofile(temp_audiofile,audio_fps, audio_nbytes,
--> 273                     audio_bufsize, audio_codec, audio_bitrate, verbose)
    274             ffmpeg_writer.ffmpeg_write(self, videofile, fps, codec,
    275                                        bitrate=bitrate, verbose=verbose)

/usr/local/lib/python2.7/site-packages/moviepy/audio/AudioClip.pyc in to_audiofile(self, filename, fps, nbytes, buffersize, codec, bitrate, verbose)

/usr/local/lib/python2.7/site-packages/moviepy/decorators.pyc in requires_duration(f, clip, *a, **k)
     41         raise ValueError("Attribute 'duration' not set")
     42     else:
---> 43         return f(clip, *a, **k)
     44 
     45 @decorator.decorator

/usr/local/lib/python2.7/site-packages/moviepy/audio/AudioClip.pyc in to_audiofile(self, filename, fps, nbytes, buffersize, codec, bitrate, verbose)
     79 
     80         return ffmpeg_audiowrite(self,filename, fps, nbytes, buffersize,
---> 81                       codec, bitrate, verbose)
     82 
     83 try:

/usr/local/lib/python2.7/site-packages/moviepy/audio/io/ffmpeg_audiowriter.py in ffmpeg_audiowrite(clip, filename, fps, nbytes, buffersize, codec, bitrate, verbose)

/usr/local/lib/python2.7/site-packages/moviepy/decorators.pyc in requires_duration(f, clip, *a, **k)
     41         raise ValueError("Attribute 'duration' not set")
     42     else:
---> 43         return f(clip, *a, **k)
     44 
     45 @decorator.decorator

/usr/local/lib/python2.7/site-packages/moviepy/audio/io/ffmpeg_audiowriter.py in ffmpeg_audiowrite(clip, filename, fps, nbytes, buffersize, codec, bitrate, verbose)
     86         if ( (i% ifeedback) == 0): verbose_print("=")
     87         tt = (1.0/fps)*np.arange(pospos[i],pospos[i+1])
---> 88         sndarray = clip.to_soundarray(tt,nbytes)
     89         writer.write_frames(sndarray)
     90 

/usr/local/lib/python2.7/site-packages/moviepy/audio/AudioClip.pyc in to_soundarray(self, tt, fps, nbytes)

/usr/local/lib/python2.7/site-packages/moviepy/decorators.pyc in requires_duration(f, clip, *a, **k)
     41         raise ValueError("Attribute 'duration' not set")
     42     else:
---> 43         return f(clip, *a, **k)
     44 
     45 @decorator.decorator

/usr/local/lib/python2.7/site-packages/moviepy/audio/AudioClip.pyc in to_soundarray(self, tt, fps, nbytes)
     63             tt = np.arange(0,self.duration, 1.0/fps)
     64 
---> 65         snd_array = self.get_frame(tt)
     66         snd_array = np.maximum(-0.999, np.minimum(0.999,snd_array))
     67         inttype = {1:'int8',2:'int16',4:'int32'}[nbytes]

/usr/local/lib/python2.7/site-packages/moviepy/audio/io/AudioFileClip.pyc in gf(t)
     69 
     70                 try:
---> 71                     result[in_time] = self.buffer[inds - self._fstart_buffer]
     72                     return result
     73                 except:

IndexError: index 99963 is out of bounds for axis 0 with size 99963

@Zulko Zulko added the bug label Feb 8, 2014
@jamiewannenburg
Copy link

I am also experiencing the same issue.

audio_clip = AudioFileClip(clip_path,buffersize=200000000)
audio_clip.to_soundarray(fps=44100)

Error: wrong indices in video buffer. Maybe buffer too small.
Traceback (most recent call last):
  File "C:\Users\Vincent\Programming\Bridgestone\post.py", line 45, in <module>   np.save(path_no_extension, audio_clip.to_soundarray(fps=sr))
  File "<string>", line 2, in to_soundarray
  File "C:\Python27\lib\site-packages\moviepy-0.2.1.6.94-py2.7.egg\moviepy\decorators.py", line 47, in requires_duration
    return f(clip, *a, **k)
  File "C:\Python27\lib\site-packages\moviepy-0.2.1.6.94-py2.7.egg\moviepy\audio\AudioClip.py", line 65, in to_soundarray
    snd_array = self.get_frame(tt)
  File "C:\Python27\lib\site-packages\moviepy-0.2.1.6.94 py2.7.egg\moviepy\audio\io\AudioFileClip.py", line 71, in gf
    result[in_time] = self.buffer[inds - self._fstart_buffer]
IndexError: index (393248) out of range (0<=index<393244) in dimension 0

It makes no difference how large I make the buffersize or how small the fps. Any ideas?
(Note: This error is from my windows 7 machine, but it is the same on ubuntu.)

@Zulko
Copy link
Owner

Zulko commented Feb 10, 2014

Thanks you three for the feedback.
@karpitsky : What you are describing seems to be a bug in the "rewind" which I am investigating (but I am a little busy with other stuffs so it might take a few days). For instance, I get a bug with the following:

clip = VideoFileClip('myvideo.mp4')
clip.to_videofile("test1.mp4")
clip.to_videofile("test2.mp4")

This is because clip is read once entirely to make test1.mp4, then there is a rewind (cursor set to 0 again) when I ask to make test2.mp4 and for some reasons the rewind is buggy so the third line will fail. Until this is repared, you can solve this by making several rentry points to the file:

clip1 = VideoFileClip('myvideo.mp4')
clip2 = VideoFileClip('myvideo.mp4')
clip1.to_videofile("test1.mp4")
clip2.to_videofile("test2.mp4")

@willperkins : I would need some more details, but my guess is that your issue (and its current solution) would be the same as for karpitsky.

@jamiewannenburg : strange bug, maybe not related to the other's. I will see what I can do. How long lasts your sound ?

@jamiewannenburg
Copy link

Hi @Zulko, thanks for the reply. I think you are right.
If I make the buffersize = 150000000 I stop getting the error for most of my files; however then I get a MemoryError for the biggest ones. So guess it's time to upgrade to python64 and/or my hardware.

The largest file is around 3min HD footage.

I am trying to automate the batch syncing and editing of a gopro camera array for a bullet time effect. I want to get the audio of at least two files into numpy arrays so I can do a scipy.signal.fftconvolve with them. But I keep running into memory problems (even if I import using scipy.io.wavfile). So I am checking out numpy.memmap as a solution or using a much lower sample rate or both.

Edit1:
Actually, since I am adding a lot of files it might be related to another problem I have that is strictly a windows problem. I receive this error whenever I use a reader:

Traceback (most recent call last):
  File "C:\Users\Vincent\Programming\Bridgestone\sync_audio.py", line 7, in <module>
    clip1 = VideoFileClip("2014-01-29 16.44.00.mp4", audio=True)
  File "C:\Python27\lib\site-packages\moviepy\video\io\VideoFileClip.py", line 46, in __init__
    self.reader = FFMPEG_VideoReader(filename, pix_fmt=pix_fmt)
  File "C:\Python27\lib\site-packages\moviepy\video\io\ffmpeg_reader.py", line 17, in __init__
    self.load_infos(print_infos)
  File "C:\Python27\lib\site-packages\moviepy\video\io\ffmpeg_reader.py", line 44, in load_infos
    proc.terminate()
  File "C:\Python27\lib\subprocess.py", line 1016, in terminate
    _subprocess.TerminateProcess(self._handle, 1)
WindowsError: [Error 5] Access is denied

Google pointed me to http://bugs.python.org/issue14252 . So I thought the subprocess was already terminated when the error gets raised, and therefore there would be no harm in excepting a WindowsError every time a process is terminated. I guess not... Since I also received buffer/memory issues on my Ubuntu machine I thought the problems where unrelated. But my Ubuntu machine has only 1GB of RAM. I'll try to upgrade python and see if that helps.

Edit2:
Updated python => no more windows errors.

@Zulko
Copy link
Owner

Zulko commented Feb 15, 2014

@karpitsky @willperkins I think I have fixed this bug (only on Github, didn't push to Pypi yet). You'll tell me.

@willperkins
Copy link

thanks @Zulko . I can update and test again. As a workaround, I found that if I worked with a smaller segment of the movie, I didn't encounter the error. The original movie I was editing is about 4 minutes long.

@Zulko
Copy link
Owner

Zulko commented Jun 19, 2014

@karpitsky @willperkins @jamiewannenburg
In case you are still interested, I believe I fixed this audio issue while working on another one. It seems pretty stable now. If some of you want to try it again, I would be very grateful to receive feedback !

@willperkins
Copy link

@Zulko this fixed the issue for me. Thanks for the update!

@Zulko
Copy link
Owner

Zulko commented Jul 28, 2014

This is old, many things changed since then. I'm closing the issue. Open a new one if you still have problems.

@Zulko Zulko closed this as completed Jul 28, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issues that report (apparent) bugs.
Projects
None yet
Development

No branches or pull requests

4 participants