add BG processing BG_actor4
This commit is contained in:
1 parent
7550ffe30f
commit
6e0e400449
12 files changed
+844
-241
No files matched your search
@@ -7,16 +7,18 @@ from moviepy.editor import VideoFileClip, AudioFileClip
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
path_raw = Path("/ssdata1/cf/data/raw/20220422")
|
||||
# path_raw = Path("/ssdata1/cf/data/raw/20220422")
|
||||
path_raw = Path("/mfs/lsen/DATA/Actor4/meiyan/")
|
||||
|
||||
path_root = Path("/mfs/lsen/DATA/Actor4")
|
||||
|
||||
vpath_videos = sorted(path_raw.glob("*.MP4"), reverse=True)
|
||||
vpath_videos = sorted(path_raw.glob("*.mp4"), reverse=True)
|
||||
print(f"Have {len(vpath_videos)} dir files")
|
||||
|
||||
# IDs = ["clip_full"]
|
||||
durations = 0
|
||||
# for each video
|
||||
for i, ipath_item in enumerate(vpath_videos):
|
||||
for i, ipath_item in enumerate(vpath_videos[1:]):
|
||||
iname = ipath_item.stem
|
||||
print(f"processing {i}/{len(vpath_videos)} -> {ipath_item} ... ")
|
||||
|
||||
@@ -24,7 +26,7 @@ if __name__ == '__main__':
|
||||
# if iname not in IDs: continue
|
||||
|
||||
# data path
|
||||
ipath_data = path_root.joinpath("processing", ipath_item.stem)
|
||||
ipath_data = path_root.joinpath("meiyan", ipath_item.stem)
|
||||
|
||||
ipath_frame = ipath_data.joinpath("frames")
|
||||
ipath_video = ipath_data.joinpath("video")
|
||||
@@ -78,30 +80,31 @@ if __name__ == '__main__':
|
||||
# nframes = len(list(video.iter_frames()))
|
||||
# print(f"after cut video duration = {video.duration}, fps = {video.fps}, (start, end)=({video.start},{video.end}), nframes={int(video.duration * video.fps)}")
|
||||
|
||||
# if fps != 50
|
||||
if video.fps != 50:
|
||||
print("FPS NOT = 50!! ")
|
||||
# # if fps != 50
|
||||
# if video.fps != 50:
|
||||
# print("FPS NOT = 50!! ")
|
||||
|
||||
# save sub video fps=50
|
||||
ipath_video_sub = ipath_video.joinpath("video_trim.mp4")
|
||||
if ipath_video_sub.exists():
|
||||
print("\nERROR: ipath_video_sub.exists()")
|
||||
continue
|
||||
else:
|
||||
video.write_videofile(str(ipath_video_sub), fps=50, audio=True)
|
||||
print(f"save video > {ipath_video_sub}")
|
||||
# # save sub video fps=50
|
||||
# ipath_video_sub = ipath_video.joinpath("video_trim.mp4")
|
||||
# if ipath_video_sub.exists():
|
||||
# print("\nERROR: ipath_video_sub.exists()")
|
||||
# continue
|
||||
# else:
|
||||
# video.write_videofile(str(ipath_video_sub), fps=50, audio=True)
|
||||
# print(f"save video > {ipath_video_sub}")
|
||||
|
||||
# reload video
|
||||
video.close()
|
||||
video = VideoFileClip(str(ipath_video_sub))
|
||||
print(f"video reload duration = {video.duration}, fps = {video.fps}, (start, end)=({video.start},{video.end}), nframes={int(video.duration * video.fps)}")
|
||||
nframes = len(list(video.iter_frames()))
|
||||
# # reload video
|
||||
# video.close()
|
||||
# video = VideoFileClip(str(ipath_video_sub))
|
||||
# print(f"video reload duration = {video.duration}, fps = {video.fps}, (start, end)=({video.start},{video.end}), nframes={int(video.duration * video.fps)}")
|
||||
# nframes = len(list(video.iter_frames()))
|
||||
|
||||
|
||||
# get audio
|
||||
audio_sub = video.audio
|
||||
if audio_sub is None:
|
||||
print("\nERROR: audio info is None")
|
||||
continue
|
||||
|
||||
print(f"audio_sub duration = {audio_sub.duration}, fps = {audio_sub.fps}, (start, end)=({audio_sub.start},{audio_sub.end}), nframes={int(audio_sub.duration * audio_sub.fps)}")
|
||||
|
||||
|
||||
@@ -17,14 +17,14 @@ from decalib.utils.config import cfg as deca_cfg
|
||||
def main(args):
|
||||
|
||||
# device = args.device
|
||||
device = "cuda:7"
|
||||
device = "cuda:4"
|
||||
|
||||
# run DECA
|
||||
deca_cfg.model.use_tex = args.useTex
|
||||
deca = DECA(config = deca_cfg, device=device)
|
||||
|
||||
# path_data = Path("/yrfs/lsen/DATA/TestData/processing")
|
||||
path_data = Path("/mfs/lsen/DATA/Actor4/processing")
|
||||
path_data = Path("/mfs/lsen/DATA/Actor4/smile")
|
||||
|
||||
v_dir_videos = sorted(path_data.glob("*"), reverse=True)
|
||||
print(f"Have {len(v_dir_videos)} dir files")
|
||||
@@ -33,7 +33,7 @@ def main(args):
|
||||
# IDs = ["clip_full"]
|
||||
|
||||
# for each video
|
||||
for i, ipath_data in enumerate(v_dir_videos[1:]):
|
||||
for i, ipath_data in enumerate(v_dir_videos[:4]):
|
||||
ivideo_name = ipath_data.stem
|
||||
print(f"\n processing {i}/{len(v_dir_videos)} ...", ivideo_name)
|
||||
# if ivideo_name not in IDs: continue
|
||||
|
||||
Reference in new issue
Block a user