Download third-party/HOI4D-Instructions/utils/decode.py from hk239/v2d: direct link, hf CLI and curl.
- Browser
- Download file 1.24 kB
-
https://huggingface.co/datasets/hk239/v2d/resolve/main/third-party/HOI4D-Instructions/utils/decode.py
- Command line
-
hf download hf://datasets/hk239/v2d/third-party/HOI4D-Instructions/utils/decode.py
-
curl -L -o decode.py https://huggingface.co/datasets/hk239/v2d/resolve/main/third-party/HOI4D-Instructions/utils/decode.py
1.24 kB
| import os | |
| import subprocess | |
| import sys | |
| def decode_video(root): | |
| with open('./release.txt', 'r') as f: | |
| rgb_list = [os.path.join(root, i.strip(),'align_rgb') for i in f.readlines()] | |
| for rgb in rgb_list: | |
| depth = rgb.replace('align_rgb','align_depth') | |
| rgb_video = os.path.join(rgb, "image.mp4") | |
| depth_video = os.path.join(depth, "depth_video.avi") | |
| cmd = """ ffmpeg -i {} -f image2 -start_number 0 -vf fps=fps=15 -qscale:v 2 {}/%05d.{} -loglevel quiet """.format(rgb_video, rgb, "jpg") | |
| print(cmd) | |
| p = subprocess.Popen(cmd, shell=True, | |
| stdout=subprocess.PIPE, stderr=subprocess.PIPE) | |
| out, err = p.communicate() | |
| if err: | |
| log.info(err.decode()) | |
| cmd = """ ffmpeg -i {} -f image2 -start_number 0 -vf fps=fps=15 -qscale:v 2 {}/%05d.{} -loglevel quiet """.format(depth_video, depth, "png") | |
| print(cmd) | |
| p = subprocess.Popen(cmd, shell=True, | |
| stdout=subprocess.PIPE, stderr=subprocess.PIPE) | |
| out, err = p.communicate() | |
| if err: | |
| log.info(err.decode()) | |
| if __name__ == '__main__': | |
| decode_video('/path/to/HOI4D/') | |