예제 #1
0
def main():
    # DO STUFF
    args = set_args()
    inputPath = args.inputPath
    # for ingestfile.py this is the packageDerivDir
    outputDir = args.outputDir
    derivType = args.derivType
    ffmpegReportDir = args.ffmpegReportDir
    if ffmpegReportDir:
        pymmFunctions.set_ffreport(ffmpegReportDir, 'makeDerivs')
    ffmpegArgs = []
    inputOptions = set_input_options(derivType, inputPath, ffmpegReportDir)
    middleOptions = set_middle_options(derivType)
    outputOptions = set_output_options(derivType, inputPath, outputDir)
    ffmpegArgs = inputOptions + middleOptions + outputOptions
    ffmpegArgs.insert(0, 'ffmpeg')
    print(ffmpegArgs)
    output = subprocess.Popen(ffmpegArgs,
                              stdout=subprocess.PIPE,
                              stderr=subprocess.PIPE)
    out, err = output.communicate()
    print(out.decode('utf-8'))
    if err:
        print(err.decode('utf-8'))
    if ffmpegReportDir:
        pymmFunctions.unset_ffreport()
    # get the output path to rsync the deriv to access directories
    outputFilePath = outputOptions[-1]
    if pymmFunctions.boolean_answer(
            config['deriv delivery options'][derivType]):
        additional_delivery(outputFilePath, derivType)
    # print(outputFilePath)
    return outputFilePath
예제 #2
0
파일: makeDerivs.py 프로젝트: BAM-PFA/pymm
def main(CurrentIngest=None):
    # DO STUFF
    args = set_args()
    inputPath = args.inputPath
    # for ingestfile.py this is the packageDerivDir
    outputDir = args.outputDir
    derivType = args.derivType
    logDir = args.logDir
    rsMulti = args.rspaceMulti
    isSequence = args.isSequence
    mixdown = args.mixdown
    combine_audio_streams = args.combine_audio_streams
    # CurrentIngest = args.current_ingest

    if logDir:
        pymmFunctions.set_ffreport(logDir, 'makeDerivs')

    if not isSequence:
        inputType = pymmFunctions.is_av(inputPath)
    else:
        inputType = 'sequence'
    ffmpegArgs = []
    inputOptions, audioPath = set_input_options(derivType, inputPath, logDir,
                                                isSequence)
    middleOptions = set_middle_options(derivType, inputType, inputPath,
                                       mixdown, combine_audio_streams,
                                       audioPath)
    outputOptions = set_output_options(derivType, inputType, inputPath,
                                       outputDir)

    ffmpegArgs = inputOptions + middleOptions + outputOptions
    ffmpegArgs.insert(0, 'ffmpeg')
    # print(ffmpegArgs)
    print(' '.join(ffmpegArgs))
    output = subprocess.run(ffmpegArgs,
                            stdout=subprocess.PIPE,
                            stderr=subprocess.PIPE)
    # out,err = output.communicate()
    # print(out.decode('utf-8'))

    if output.stderr:
        print(output.stderr.decode('utf-8'))
    # if output.stdout:
    # 	print(output.stdout.decode('utf-8'))
    if logDir:
        pymmFunctions.unset_ffreport()

    # get the output path to rsync the deriv to access directories
    outputFilePath = outputOptions[-1]
    if pymmFunctions.boolean_answer(
            config['deriv delivery options'][derivType]):
        additional_delivery(outputFilePath, derivType, rsMulti)
    # print(outputFilePath)
    if inputType == "AUDIO":
        add_audio_images(CurrentIngest, outputFilePath)

    return outputFilePath
예제 #3
0
def make_derivs(processingVars):
    '''
	Make derivatives based on options declared in config...
	'''
    inputPath = processingVars['inputPath']
    packageObjectDir = processingVars['packageObjectDir']
    packageLogDir = processingVars['packageLogDir']
    packageMetadataObjects = processingVars['packageMetadataObjects']
    makeProres = processingVars['makeProres']
    ingestType = processingVars['ingestType']

    # we'll always output a resourcespace access file for video ingests,
    # so init the derivtypes list with `resourcespace`
    if ingestType in ('film scan', 'video transfer'):
        derivTypes = ['resourcespace']
    deliveredDerivPaths = {}

    if pymmFunctions.boolean_answer(
            config['deriv delivery options']['proresHQ']):
        derivTypes.append('proresHQ')
    elif makeProres == True:
        derivTypes.append('proresHQ')
    else:
        pass

    for derivType in derivTypes:
        sys.argv = [
            '', '-i' + inputPath, '-o' + packageObjectDir, '-d' + derivType,
            '-r' + packageLogDir
        ]
        deliveredDeriv = makeDerivs.main()
        deliveredDerivPaths[derivType] = deliveredDeriv

    for key, value in deliveredDerivPaths.items():
        mdDest = os.path.join(packageMetadataObjects, key)
        if not os.path.isdir(mdDest):
            os.mkdir(mdDest)
        mediainfo = makeMetadata.get_mediainfo_report(value, mdDest)
예제 #4
0
def make_derivs(CurrentIngest, rsPackage=None, isSequence=None):
    '''
	Make derivatives based on options declared in config...
	'''
    initialObject = CurrentIngest.currentTargetObject
    inputPath = initialObject.inputPath
    packageObjectDir = CurrentIngest.packageObjectDir
    packageLogDir = CurrentIngest.packageLogDir
    packageMetadataObjects = CurrentIngest.packageMetadataObjects
    makeProres = CurrentIngest.ProcessArguments.makeProres
    ingestType = CurrentIngest.ProcessArguments.ingestType
    resourcespace_deliver = CurrentIngest.ProcessArguments.resourcespace_deliver
    mono = CurrentIngest.ProcessArguments.mono
    combineAudio = CurrentIngest.ProcessArguments.combineAudio

    # make an enclosing folder for access copies if the input is a
    # group of related video files
    if rsPackage != None:
        rsPackageDelivery = make_rs_package(
            CurrentIngest.InputObject.canonicalName, resourcespace_deliver)
        CurrentIngest.accessDelivery = rsPackageDelivery
    else:
        rsPackageDelivery = None

    # we'll always output a resourcespace access file for video ingests,
    # so init the derivtypes list with `resourcespace`
    if ingestType in ('film scan', 'video transfer', 'audio xfer'):
        derivTypes = ['resourcespace']

    # deliveredDerivPaths is a dict as follows:
    # {derivtype1:/path/to/deriv/file1}
    deliveredDerivPaths = {}

    if pymmFunctions.boolean_answer(
            config['deriv delivery options']['proresHQ']):
        derivTypes.append('proresHQ')
    elif makeProres == True:
        derivTypes.append('proresHQ')
    else:
        pass

    for derivType in derivTypes:
        sysargs = [
            '', '-i' + inputPath, '-o' + packageObjectDir, '-d' + derivType,
            '-L' + packageLogDir
        ]
        if rsPackageDelivery != None:
            sysargs.append('-r' + rsPackageDelivery)
        if isSequence:
            sysargs.append('-s')
        if mono:
            # select to mixdown audio to mono
            sysargs.append('-m')
        if combineAudio:
            # select to mix all audio tracks to one stereo track
            sysargs.append('-k')
        sys.argv = sysargs

        deliveredDeriv = makeDerivs.main(CurrentIngest)
        deliveredDerivPaths[derivType] = deliveredDeriv

        event = 'migration'
        CurrentIngest.caller = CurrentIngest.ProcessArguments.ffmpegVersion
        if pymmFunctions.is_av(deliveredDeriv):
            outcome = 'create access copy at {}'.format(deliveredDeriv)
            status = 'OK'
        else:
            outcome = 'could not create access copy'
            status = 'FAIL'
        loggers.log_event(CurrentIngest, event, outcome, status)
        CurrentIngest.caller = None

    for key, value in deliveredDerivPaths.items():
        # metadata for each deriv is stored in a folder named
        # for the derivtype under the main Metadata folder
        mdDest = os.path.join(packageMetadataObjects, key)
        if not os.path.isdir(mdDest):
            os.mkdir(mdDest)

        if os.path.isfile(value):
            # if the new access file exists,
            # create it as a ComponentObject object and
            # add it to the list in InputObject
            newObject = ingestClasses.ComponentObject(
                value,
                objectCategoryDetail='access file',
                topLevelObject=False)
            newObject.metadataDirectory = mdDest
            CurrentIngest.InputObject.ComponentObjects.append(newObject)
            CurrentIngest.currentTargetObject = newObject

            loggers.insert_object(CurrentIngest,
                                  objectCategory='file',
                                  objectCategoryDetail='access file')

        else:
            pass

    # get a return value that is the path to the access copy(ies) delivered
    #   to a destination defined in config.ini
    # * for a single file it's the single deriv path
    # * for a folder of files it's the path to the enclosing deriv folder
    #
    # this path is used to make an API call to resourcespace
    if rsPackageDelivery not in ('', None):
        accessPath = rsPackageDelivery
    else:
        SIPaccessPath = deliveredDerivPaths['resourcespace']
        deliveredAccessBase = os.path.basename(SIPaccessPath)
        accessPath = os.path.join(resourcespace_deliver, deliveredAccessBase)

    CurrentIngest.ingestResults['accessPath'] = accessPath
    CurrentIngest.accessDelivery = accessPath

    return accessPath