Path(os.path.join(output_path,
                              path.stem + "_%06d.jpg")).as_posix()),
    ])


def parse_args(args):
    arg_parser = argparse.ArgumentParser()
    arg_parser.add_argument(
        "--input-path",
        dest="input_path",
        help="Path to an MP4 video file",
        type=str,
        required=True,
    )
    arg_parser.add_argument(
        "--output-path",
        default='frames',
        help="Path to an MP4 video file",
        type=str,
        required=True,
    )
    return arg_parser.parse_args(args)


if __name__ == "__main__":
    args = parse_args(sys.argv[1:])
    os.makedirs(args.output_path, exist_ok=True)
    files = get_names(args.input_path)
    for file_path in files:
        extract_video_frames(file_path, args.output_path)
import os, cv2, sys
sys.path.append('..')
from pytorch_pwc.utils import get_names

all_dir = '../data/train2017'
store_dir = '../data/coco'
os.makedirs(store_dir, exist_ok=True)
'''
# 동영상 이름+idx.jpg 만들기
dir_names = [d for d in os.listdir(all_dir) if os.path.isdir(os.path.join(all_dir, d))]

for img_dir in dir_names:
    image_names = get_names(os.path.join(all_dir,img_dir))

    for i,image_name in enumerate(image_names):
        img = cv2.imread(image_name)
        name = os.path.basename(image_name)
        cv2.imwrite(os.path.join(store_dir, img_dir+'%06d.jpg'%i), img)
'''

# 이미지 이름 바꾸기
image_names = get_names(os.path.join(all_dir))
for i, img_name in enumerate(image_names):
    img = cv2.imread(img_name)
    if i % 1000 == 0:
        print(store_dir, i)
    cv2.imwrite(os.path.join(store_dir, '%08d.jpg' % i), img)
Ejemplo n.º 3
0
    )
    arg_parser.add_argument(
        "--audio-path",
        dest="audio_path",
        help=
        "Optional path to a video file that contains the audio you want to apply to the"
        " output video",
        type=str,
        required=False,
    )

    args = arg_parser.parse_args()

    assert args.framerate > 1

    image_file_paths = get_names(args.input_path)

    image_list_file_path = os.path.join(TMP_DIR, "images.txt")
    os.makedirs(TMP_DIR, exist_ok=True)
    with open(image_list_file_path, "w") as f:
        for path in image_file_paths:
            f.write("file {}\n".format(
                os.path.join(
                    os.path.abspath(os.path.dirname(
                        os.path.dirname(__file__))),
                    Path(path).as_posix())))

    subprocess.run([
        "ffmpeg",
        "-r",
        "{}".format(args.framerate),