DinoMan / speech-driven-animation

947 stars 289 forks source link

va.save_video runs into error + requirements conflict #19

Closed pashadude closed 5 years ago

pashadude commented 5 years ago

Good day I run into same error both at floyd-hub and local machine

Traceback (most recent call last):
  File "test.py", line 12, in <module>
    va.save_video(vid, aud, "extracted.mp4")
  File "/Users/pl/AnacondaProjects/FaceExp/speech-driven-animation/sda/sda.py", line 173, in save_video
    writer.writeFrame(frame)
  File "/usr/local/anaconda3/envs/faces/lib/python3.6/site-packages/skvideo/io/abstract.py", line 519, in writeFrame
    raise IOError(msg)
OSError: [Errno 32] Broken pipe

FFMPEG COMMAND:
/usr/local/bin/ffmpeg -y -r 25/1 -f rawvideo -pix_fmt rgb24 -s 96x128 -i - -r 25/1 /var/folders/zq/w73cr80n5xd5lkgs5mm18q2r0000gn/T/tmprphdnm_h/tmp.avi

might not it be caused my requirements conflict between menpo and scikit which disturbs work of ffmpeg-python?

scikit-umfpack 0.3.2 has requirement scipy>=1.0.0rc1, but you'll have scipy 0.19.1 which is incompatible.
menpo 0.8.1 has requirement scipy<1.0,>=0.16, but you'll have scipy 1.3.0 which is incompatible.
DinoMan commented 5 years ago

The library provides a saving functionality but you don't have to use it. If you want you can save the video,which is returned as a numpy array using menpo.

pashadude commented 5 years ago

Thanks @DinoMan , however if anyone might need an alternative way to save the vid due to menpo problems one can use this function (add to the class VideoAnimator())

import imageio
from moviepy.editor import *
from moviepy.audio.AudioClip import AudioArrayClip

...

    def save_video_alternative(self, video, audio, path):
        if not os.path.isabs(path):
            path = os.getcwd() + "/" + path

        with tempdir() as dirpath:
            videowriter = imageio.get_writer(dirpath + '/tmp.avi', fps=self.video_rate)
            for i in range(video.shape[0]):
                frame = np.rollaxis(video[i, :, :, :], 0, 3)
                videowriter.append_data(frame)
            videowriter.close()

            aclip = AudioArrayClip(audio, self.audio_rate)

            clip = VideoFileClip(dirpath + '/tmp.avi')
            clip.set_audio(aclip)
            clip.write_videofile(path, temp_audiofile=dirpath+'/temp-audio.m4a', remove_temp=True, codec="libx264", audio_codec="aac")