示例#1
0
def main():
    fps = get_fps(path_vid)
    if Flags.get('playVideoFlag'):
        play_vid(path_vid)
    if Flags.get('SaveRawFrameFlag'):
        vid_to_frame(path_vid, mode=Mode)
    if Flags.get('ResizeFlag'):
        resize(path_load, path_save_resize, mode=Mode)
def main():
    fps = get_fps(path_vid)
    print("Frames per second using video.get(cv2.CAP_PROP_FPS) : {0}".format(fps))
    if Flags.get('playVideoFlag'):
        play_vid(path_vid)
    if Flags.get('SaveRawFrameFlag'):
        vid_to_frame(path_vid, mode=Mode)
    if Flags.get('ResizeFlag'):
        resize(path_load, path_save_resize, mode=Mode)
示例#3
0
def main(yaml):

    #origine = customer_id = nom de la vidéo

    #outgoing: /opt/PRODUCTION_DATA/FTP_data/incomming/customer_id/origin/UNDONE,DONE,ONGOING

    net, params = load_model()
    videos_files = glob.iglob(
        os.path.join(yaml.location_incoming,
                     "*.{}".format(yaml.video_extensions)))
    frequency = yaml.delta_time
    for video_file in videos_files:
        path, video_name = os.path.split(video_file)
        video_folder_name = video_name.split('.')[0]
        # Setup destination folders
        dest_path, video_folder_name = create_dir(yaml.location_outgoing,
                                                  video_folder_name)
        dest_path, _ = create_dir(dest_path, video_folder_name)
        final_dest_path, _ = create_dir(dest_path, "UNDONE")
        create_dir(dest_path, "ONGOING")
        create_dir(dest_path, "DONE")
        # Get frame rate of the video
        fps = get_fps(video_file)
        step_size = int(fps * frequency)
        print(frequency, step_size)
        #Make scene prediction
        scenes = predict(net, params, video_file)
        #Extracts the frames from a video using multiprocessing
        if scenes is not None:
            transitions = set(scenes[:, 0])
            video_to_frames(video_path=video_file,
                            frames_dir=final_dest_path,
                            transitions=transitions,
                            config=yaml,
                            origin=video_folder_name,
                            overwrite=True,
                            every=step_size,
                            chunk_size=1000)
示例#4
0
def main(args, callback=None):
    uid = uuid.uuid1()
    dir_name = './.TEMP-' + str(uid)
    os.makedirs(dir_name)

    audio_file = dir_name + '/audio.mp3'
    extract_audio(args.video, audio_file)

    frames_dir = dir_name + '/frames'
    os.makedirs(frames_dir)
    extract_frames(args.video, frames_dir)
    frames_count = len(glob(frames_dir + '/*'))
    audio_analyze = analyze(audio_file, frames_count)
    process(frames_dir,
            audio_analyze,
            args.size,
            neural=args.neural,
            colorize=args.colorize,
            brightify=args.brightify,
            callback=callback)
    construct_video(frames_dir, audio_file, get_fps(args.video), args.output)
    if not args.no_clean:
        rmtree(dir_name)
示例#5
0
    def __init__(self, args):

        self.args = args

        self.project_pto = path.join(args.workdir, args.pto_name)
        args.pto = self.project_pto

        if not path.isfile(args.videofile):
            print('\nFilepath doesn\'t exist: {}\n'.format(args.videofile))
            exit()
        else:
            self.fps = str(round(utils.get_fps(args.videofile)))

        self.frames_total = 0

        self.pto = HuginPTO(self.project_pto)

        ## create output video subdir tree
        data_dir_name = re.sub(r'[/\\.]+', '_', args.videofile).strip('_')
        self.data_dir = path.join(path.abspath(args.workdir), data_dir_name)

        # self.workdir = Path(path.join(self.data_dir, '0__workdir'))
        # self.workdir.mkdir(parents=True, exist_ok=True)

        ## saved command args file
        self.cmd_args = path.join(self.data_dir, 'cmd_args.txt')

        self.input_dir = Path(path.join(self.data_dir, '1__input_frames'))
        self.input_dir.mkdir(parents=True, exist_ok=True)

        self.prjn_video_name = "input_projection.mkv"

        self.prjn_basedir1 = Path(path.join(self.data_dir,
                                            '2__vidstab_detect'))
        self.prjn_basedir1.mkdir(parents=True, exist_ok=True)
        self.prjn_dir1_frames = Path(path.join(self.prjn_basedir1, 'frames'))
        self.prjn_dir1_frames.mkdir(parents=True, exist_ok=True)
        self.prjn_dir1_vidstab_orig = Path(
            path.join(self.prjn_basedir1, 'vidstab_pass_orig'))
        self.prjn_dir1_vidstab_orig.mkdir(parents=True, exist_ok=True)
        self.prjn_dir1_vidstab_prjn = Path(
            path.join(self.prjn_basedir1, 'vidstab_pass_prjn'))
        self.prjn_dir1_vidstab_prjn.mkdir(parents=True, exist_ok=True)

        self.rolling_shutter = Path(path.join(self.data_dir,
                                              '3__camera_moves'))
        self.rolling_shutter.mkdir(parents=True, exist_ok=True)

        self.projection_pto_path = path.join(self.rolling_shutter,
                                             'vidstab_projection.pto')
        self.rectilinear_pto_path = path.join(self.rolling_shutter,
                                              'rectilinear.pto')
        #self.rectilinear_pto_path = path.join(path.abspath(args.workdir), 'rectilinear.pto')

        self.hugin_projects = Path(
            path.join(self.rolling_shutter, 'hugin_ptos'))
        self.hugin_projects.mkdir(parents=True, exist_ok=True)
        self.hugin_projects_processed = Path(
            path.join(self.rolling_shutter, 'hugin_ptos_processed'))
        self.hugin_projects_processed.mkdir(parents=True, exist_ok=True)
        self.frames_input_processed = Path(
            path.join(self.rolling_shutter, 'input_frames_processed'))
        self.frames_input_processed.mkdir(parents=True, exist_ok=True)

        self.prjn_basedir2 = Path(path.join(self.data_dir,
                                            '4__vidstab_detect'))
        self.prjn_basedir2.mkdir(parents=True, exist_ok=True)
        self.prjn_dir2_frames = Path(path.join(self.prjn_basedir2, 'frames'))
        self.prjn_dir2_frames.mkdir(parents=True, exist_ok=True)
        self.prjn_dir2_vidstab_orig = Path(
            path.join(self.prjn_basedir2, 'vidstab_pass_orig'))
        self.prjn_dir2_vidstab_orig.mkdir(parents=True, exist_ok=True)
        self.prjn_dir2_vidstab_prjn = Path(
            path.join(self.prjn_basedir2, 'vidstab_pass_prjn'))
        self.prjn_dir2_vidstab_prjn.mkdir(parents=True, exist_ok=True)
        self.input_processed_video_path = path.join(self.prjn_basedir2,
                                                    'processed_input.mkv')

        self.frames_stabilized = Path(
            path.join(self.data_dir, '5__stabilized_frames'))
        self.frames_stabilized.mkdir(parents=True, exist_ok=True)

        self.out_video_name = 'out_video.mkv'
        self.out_video_prjn_name = 'out_video_prjn_vidstab.mkv'
        self.out_video_dir = self.data_dir
示例#6
0
import os
import csv
import pandas as pd
import numpy as np
import math
import utils
## The games recorded
games = ['fifa', 'csgo', 'nhl', 'nba']
## Two types of files (recorded using ffmpeg/NVIDIA) and (recorded from gazepoint analysis)
types = ['rec', 'gzpt']
ext = ['.mp4', '.avi']
games = ['nhl', 'nba']
fps = utils.get_fps()

data_path = utils.get_path()


def create_frames():
    print('Split Video Sequences into Frames \n')
    for game in games:
        print('---------------------------------------')
        print('Processing ' + game + ' video sequences')
        print('---------------------------------------')
        for type in types:
            input_video = data_path + game + '\\mp4\\' + game + '_' + type + ext[
                types.index(type)]
            output_path = data_path + game + '\\frames\\' + type + '\\'
            os.makedirs(output_path, exist_ok=True)
            cmd = 'ffmpeg.exe -i '
            cmd = cmd + input_video
            cmd = cmd + ' -vf fps='