コード例 #1
0
ファイル: worker.py プロジェクト: reidransom/reid-uploader
def make_iphone(input_path, output_path=None, preset=None):
    if not preset:
        preset = FFMPEG_PRESETS.keys()[0]
    if not output_path:
        output_path = os.path.splitext(input_path)[0] + preset
    cmd = [FFMPEG, '-i', input_path] + shlex.split(FFMPEG_PRESETS[preset]) + ['-y', output_path]
    data = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
    return output_path, data
コード例 #2
0
ファイル: worker.py プロジェクト: reidransom/reid-uploader
def _process_fullcopy(key):

    # Set the content-type correctly
    bucket = helper.get_bucket()
    k = bucket.lookup(key)
    k.copy(k.bucket, k.name, preserve_acl=True, metadata={'Content-Type': helper.get_mimetype(k.name)})

    orig_video = Video(key=key, status='downloading')
    db.add(orig_video)
    db.commit()
    url = helper.get_s3url(key)
    orig_path = download_url(url)

    orig_video.update(get_video_attrs(orig_path))
    orig_video.status = 'done'

    for preset in FFMPEG_PRESETS.iterkeys():

        # Transcode/Upload based on ffmpeg preset
        iphone_path = os.path.splitext(orig_path)[0] + preset
        iphone_video = Video(key=os.path.basename(iphone_path), status='transcoding')
        db.add(iphone_video)
        db.commit()

        try:
            make_iphone(orig_path, iphone_path, preset)
            iphone_video.update(get_video_attrs(iphone_path))
        except:
            iphone_video.status = 'transcoding error'
        else:
            iphone_video.status = 'uploading'

        db.commit()

        if iphone_video.status == 'uploading':
            upload_to_s3(iphone_path)
            iphone_video.status = 'done'
            db.commit()
            os.remove(iphone_path)

    os.remove(orig_path)