add audio2mesh_ar
This commit is contained in:
1 parent
ded9b27f71
commit
e0f24982d1
46 files changed
+3917
-325
No files matched your search
+5
-1
@@ -1,6 +1,6 @@
|
||||
import moviepy.editor as mpy
|
||||
import numpy as np
|
||||
|
||||
import os
|
||||
import sys
|
||||
# sys.path.insert(0, "/ssdata1/lsen/CODE/Audio2Motion")
|
||||
from common.landmark import landmark_to_images
|
||||
@@ -171,6 +171,10 @@ def save_images_with_audio(images, path_audio, path_save):
|
||||
audioclip.close()
|
||||
animation.close()
|
||||
|
||||
# add
|
||||
path_save2 = str(path_save).replace(".mp4", "2.mp4")
|
||||
cmd = f"ffmpeg -y -i {str(path_save)} -i {str(path_audio)} -map 0:v -vcodec libx264 -map 1:a -c:v copy -shortest {str(path_save2)}"
|
||||
os.system(cmd)
|
||||
|
||||
|
||||
def save_animation_with_gt2(images_pt, images_gt, path_save, fps=None, path_audio=None, start_time=None, end_time=None):
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
import numpy as np
|
||||
from scipy import interpolate
|
||||
|
||||
def resample_by_nsteps(feat, nsteps_tgt):
|
||||
"""
|
||||
feat, (nframes, ... ) (with source_fps)
|
||||
"""
|
||||
|
||||
nsteps_src = feat.shape[0]
|
||||
data_idx = np.arange(0, nsteps_src, 1)
|
||||
samp_idx = np.arange(0, nsteps_src-1, (nsteps_src - 1) / nsteps_tgt)
|
||||
# print(f"data_idx = {list(data_idx)} \nsmap_idx = {list(samp_idx)}")
|
||||
|
||||
# sample function
|
||||
func = interpolate.interp1d(data_idx, y=feat, axis=0)
|
||||
data_interpolate = func(samp_idx)
|
||||
|
||||
return data_interpolate
|
||||
|
||||
|
||||
def convert_fps(data, source_fps = 30, target_fps=25):
|
||||
"""
|
||||
data, (nframes, ... ) (with source_fps)
|
||||
"""
|
||||
|
||||
nsize = data.shape[0]
|
||||
data_idx = np.arange(0, nsize, 1)
|
||||
samp_idx = np.arange(0, nsize-1, 1.0*source_fps/target_fps)
|
||||
|
||||
func = interpolate.interp1d(data_idx, data=data, axis=0)
|
||||
data_interpolate = func(samp_idx)
|
||||
|
||||
if source_fps < target_fps:
|
||||
data_interpolate = np.concatenate([data_interpolate, data[-1:]])
|
||||
|
||||
return data_interpolate
|
||||
|
||||
|
||||
# def
|
||||
Reference in new issue
Block a user