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

save video has a bug. call(cmd) #14

Closed
Wentao795 opened this issue Aug 14, 2019 · 10 comments
Closed

save video has a bug. call(cmd) #14

Wentao795 opened this issue Aug 14, 2019 · 10 comments

Comments

@Wentao795
Copy link

thank you for you work ,could you help me save the problem?
Traceback (most recent call last):
File "visualize_sequence.py", line 66, in
call(cmd)
File "/usr/lib/python2.7/subprocess.py", line 523, in call
return Popen(*popenargs, **kwargs).wait()
File "/usr/lib/python2.7/subprocess.py", line 711, in init
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1343, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory

@TimoBolkart
Copy link
Owner

The error indicates that the output directory does not exist.
Can you please print the out_path before the subprocess call and check if the output directory exists?
In case the directory does not exist, this issue might be cause by missing permissions as the directory is supposedly created few lines above

@Wentao795
Copy link
Author

hi,thank you for you reply!
this is code:
if os.path.exists(args.out_path):
print(args.out_path)

out_video_fname = os.path.join(out_path, 'video.mp4')
cmd = ['ffmpeg', '-framerate', '60', '-pattern_type', 'glob', '-i', os.path.join(img_path, '*.png')] + cmd_audio + [out_video_fname]
call(cmd)

this is output:
./animation_visualization
Traceback (most recent call last):
File "/home/wwt/github/voca-master/visualize_sequence.py", line 69, in
call(cmd)
File "/usr/lib/python2.7/subprocess.py", line 523, in call
return Popen(*popenargs, **kwargs).wait()
File "/usr/lib/python2.7/subprocess.py", line 711, in init
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1343, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
the path exisit!!!!!
please~```###

@TimoBolkart
Copy link
Owner

The error indicates that one of the files or directories in the subprocess call does not exist.
Can you please check if all other paths are valid? What about img_path, cmd_audio, ...?
Did you check your ffmpeg installation? Given a folder of images, are you able to run ffmpeg from the terminal and encode the images to a video?

@Wentao795
Copy link
Author

'''
Max-Planck-Gesellschaft zur Foerderung der Wissenschaften e.V. (MPG) is holder of all proprietary rights on this
computer program.

You can only use this computer program if you have closed a license agreement with MPG or you get the right to use
the computer program from someone who is authorized to grant you that right.

Any use of the computer program without a valid license is prohibited and liable to prosecution.

Copyright 2019 Max-Planck-Gesellschaft zur Foerderung der Wissenschaften e.V. (MPG). acting on behalf of its
Max Planck Institute for Intelligent Systems and the Max Planck Institute for Biological Cybernetics.
All rights reserved.

More information about VOCA is available at http://voca.is.tue.mpg.de.
For comments or questions, please email us at voca@tue.mpg.de
'''

import os
import glob
import argparse
from subprocess import call
from psbody.mesh import Mesh
from psbody.mesh.meshviewer import MeshViewer

parser = argparse.ArgumentParser(description='Sequence visualization')
parser.add_argument('--sequence_path', default='./animation_output', help='Path to motion sequence')
parser.add_argument('--audio_fname', default='./audio/test_sentence.wav', help='Path of speech sequence')
parser.add_argument('--out_path', default='./animation_visualization', help='Output path')

args = parser.parse_args()
sequence_path = args.sequence_path
audio_fname = args.audio_fname
out_path = args.out_path

if not os.path.exists(args.out_path):
os.makedirs(args.out_path)

img_path = os.path.join(out_path, 'img')
if not os.path.exists(img_path):
os.makedirs(img_path)

mv = MeshViewer()

sequence_fnames = sorted(glob.glob(os.path.join(sequence_path, '*.obj')))
if len(sequence_fnames) == 0:
print('No meshes found')
Render images

for frame_idx, mesh_fname in enumerate(sequence_fnames):
frame_mesh = Mesh(filename=mesh_fname)
mv.set_dynamic_meshes([frame_mesh], blocking=True)

img_fname = os.path.join(img_path, '%05d.png' % frame_idx)
mv.save_snapshot(img_fname)

Encode images to video

cmd_audio = []
if os.path.exists(audio_fname):
cmd_audio += ['-i', audio_fname]
print cmd_audio

if os.path.exists(args.out_path):
print(args.out_path)

out_video_fname = os.path.join(out_path, 'video.mp4')
print out_video_fname
cmd = ['ffmpeg', '-framerate', '60', '-pattern_type', 'glob', '-i', os.path.join(img_path, '*.png')] + cmd_audio + [out_video_fname]
call(cmd)

#this is the original code.
#the "animation_output" directory is *.obj file ,
#ffmpeg lib can import .
#could you tell me how to solve it ,i am not familiar with ffmpeg .
#please~~~~~~

@TimoBolkart
Copy link
Owner

  1. please check first, that the folder './animation_visualization/img' exists and contains rendered images.
  2. in your terminal (with activated virtual environment) just run
    ffmpeg -framerate '60' -i './animation_visualization/img/%05d.png' ./animation_visualization/video.mp4
    This should encode the images to a video (ignoring audio for now). Does this work?

@Wentao795
Copy link
Author

verg nice,it worked.!!!haha, how add audio ?

@Wentao795
Copy link
Author

i try to add audio.but have bug!!!
The encoder 'aac' is experimental but experimental codecs are not enabled, add '-strict -2' if you want to use it.

##The encoder 'aac' is experimental but experimental codecs are not enabled, add '-strict -2' if you want to use it.

@TimoBolkart
Copy link
Owner

Please try to run following in you terminal
ffmpeg -framerate '60' -i './animation_visualization/img/%05d.png' -i ./audio/test_sentence.wav ./animation_visualization/video.mp4
with the /audio/test_sentence.wav replaced by the audio file you used to run VOCA. Does this also work?

@yefeng1992
Copy link

@ TimoBolkart :
Please try to run following in you terminal
ffmpeg -framerate '60' -i './animation_visualization/img/%05d.png' -i ./audio/test_sentence.wav ./animation_visualization/video.mp4
with the /audio/test_sentence.wav replaced by the audio file you used to run VOCA. Does this also work?


the same problem

@TimoBolkart
Copy link
Owner

I played a bit with ffmpeg and was unable to reproduce this error. You could try to convert the audio to another file format before encoding the video, or try to use a different audio sequence. The problems seems related to ffmepg not to the VOCA part, hence it is difficult for me to help there

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

3 participants