Exemplo n.º 1
0
'''
Script to download videos from the relevant amazon S3 bucket into a temporary diretory. Old version just took parameter for source bucket "folder". New version (this one) takes additional parameter giving destination. This new version is more barebones, in that it does not ask for the config file (see commented out). Figure out the right way to structure this code.  
'''
import os
import sys
import boto3
from boto3.s3.transfer import S3Transfer
import botocore
import threading
from Interface_S3 import download

if __name__ == "__main__":
    prekey = sys.argv[1]
    targetdir = sys.argv[2]
    bucket_name = 'froemkelab.videodata'
    ## List the contents of the directory in the S3 bucket:
    s3 = boto3.resource('s3')
    my_bucket = s3.Bucket(bucket_name)
    for object in my_bucket.objects.filter(Prefix=prekey):
        if object.key.split('.')[-1] == 'csv' or 'png':
            download(bucket_name, object.key, tempdir=targetdir)
    ### Get the config file too (annoying):
    ## First get the path to the directory directly above:
    #key_split = prekey.split('/')[:-1]
    #main_direct = os.path.join(*key_split)
    #configkey = main_direct+'/'+'config.py'
    #download(bucket_name,configkey,tempdir = './auxvolume/temp_videofolder/')
from boto3.s3.transfer import S3Transfer
import botocore
import threading
from Interface_S3 import download, upload
from Examine_frames import crop_videos_p

## Assume that the user gives as input the Object ID of the video to be processed as a string.
if __name__ == '__main__':
    vidpath = sys.argv[1]
    configpath = vidpath.split('.avi')[0] + 'config.py'
    ## Download the video to a temp directory:
    print(vidpath, configpath)
    print('Downloading Video')

    bucket_name = 'froemkelab.videodata'
    download(bucket_name, vidpath)

    print('Downloading Config File')

    download(bucket_name, configpath)

    ## Segment the video:
    temp_vidpath = '../vmnt/tmp_videos'
    crop_videos_p(temp_vidpath)

    ## Reupload these chunks.
    keypath_parts = vidpath.split('/')[:-1]
    keypath = os.path.join(*keypath_parts)
    # Find all of the newly produced video files in the temporary directory:
    files = os.listdir(temp_vidpath)
    ident = vidpath.split('/')[-1].split('.')[0] + 'cropped_' + 'part'
Exemplo n.º 3
0
'''
Script to download videos from the relevant amazon S3 bucket into a temporary diretory. Old version just took parameter for source bucket "folder". New version (this one) takes additional parameter giving destination. This new version is more barebones, in that it does not ask for the config file (see commented out). This version additionally takes multiple flags for file endings, as we need both the mp4 and the h5 file to do processing here.  
'''
import os
import sys
import boto3
from boto3.s3.transfer import S3Transfer
import botocore
import threading
from Interface_S3 import download

if __name__ == "__main__":
    key = sys.argv[1]
    bucket_name = sys.argv[2]
    targetdir = sys.argv[3]
    s3 = boto3.resource('s3')
    my_bucket = s3.Bucket(bucket_name)
    #for object in my_bucket.objects.filter(Prefix = key):
    #    print(object.key,'the key we would see')
    download(bucket_name, key, tempdir=targetdir)