Exemplo n.º 1
0
def transcode(aRequest):
    global RepDir, ExpDir, transcodingcount
    #cmd,options,datasource
    if (aRequest.DataSource.find("_") > -1):
        videochoice = aRequest.DataSource.split("_")[0]
        segmentnum = aRequest.DataSource.split("_")[1]
        segmentName = "video" + str(int(segmentnum)) + ".ts"
        DataTag = aRequest.DataTag
    else:
        print("Special message received ")
        return
    inputfile = RepDir + videochoice + "/" + segmentName
    #outputfile=ExpDir+videochoice+"/"+segmentName
    foldername = videochoice + "_" + DataTag
    if not os.path.exists(os.path.join(
            ExpDir,
            foldername,
    )):
        try:
            access_rights = 0o777
            os.makedirs(os.path.join(ExpDir, foldername), access_rights)
            os.popen('cp ' + os.path.join(RepDir, videochoice, 'video.m3u8') +
                     ' ' + os.path.join(ExpDir, foldername,
                                        'video.m3u8'))  #copy manifest file
        except:
            print("Error found:", sys.exc_info()[0])
            pass
    print(inputfile + " Deadline=" + str(aRequest.GlobalDeadline) + " ")
    tests = []
    #print("test="+str(tests))
    for eachop in aRequest.OPlist:
        #print("cmd="+str(eachop.Cmd))
        for eachparam in eachop.Parameter:
            #print("parameterchoice="+str(eachparam.subparameter))
            #print("cmd="+ "ffmpeg -y -i "+inputfile+" "+cmdTranslate(eachop.Cmd)+" "+paramTranslate(eachop.Cmd,int(eachparam.subparameter))+" "+outputfile)
            tests.append(
                benchmark.BTest(
                    segmentName + " " + eachop.Cmd +
                    paramTranslate(eachop.Cmd, eachparam.subparameter),
                    lambda: args.generic_video_convert_args(
                        os.path.join(RepDir, videochoice, segmentName),
                        os.path.join(ExpDir, foldername, segmentName),
                        cmd_=cmdTranslate(eachop.Cmd),
                        option_=paramTranslate(eachop.Cmd, eachparam.
                                               subparameter)),
                    input_file_=os.path.join(RepDir, videochoice, segmentName),
                    output_file_=os.path.join(ExpDir, videochoice,
                                              segmentName),
                ))

    ###now start to execute
    results = list()
    #print("results="+str(results))
    ###disable to test
    for test in tests:
        results.append(test.process())
    print("end" + str(transcodingcount))
    transcodingcount = transcodingcount + 1
    return results
Exemplo n.º 2
0
def transcode(aRequest):
    global RepDir, ExpDir, transcodingcount
    #cmd,options,datasource
    if (aRequest.DataSource.find("_") > -1):
        videochoice = aRequest.DataSource.split("_")[0]
        segmentnum = aRequest.DataSource.split("_")[1]
        segmentName = "standardoutput" + str(int(segmentnum) + 1) + ".ts"
    else:
        print("Special message received ")
        return
    inputfile = RepDir + videochoice + "/" + segmentName
    outputfile = ExpDir + videochoice + "/" + segmentName
    print(inputfile + " Deadline=" + str(aRequest.GlobalDeadline) + " ")
    tests = []
    #print("test="+str(tests))
    for eachop in aRequest.OPlist:
        #print("cmd="+str(eachop.Cmd))
        for eachparam in eachop.Parameter:
            #print("parameterchoice="+str(eachparam.subparameter))
            #print("cmd="+ "ffmpeg -y -i "+inputfile+" "+cmdTranslate(eachop.Cmd)+" "+paramTranslate(eachop.Cmd,int(eachparam.subparameter))+" "+outputfile)
            tests.append(
                benchmark.BTest(
                    segmentName + " " + eachop.Cmd +
                    paramTranslate(eachop.Cmd, int(eachparam.subparameter)),
                    lambda: args.generic_video_convert_args(
                        os.path.join(RepDir, videochoice, segmentName),
                        os.path.join(ExpDir, videochoice + " " + segmentName),
                        cmd_=cmdTranslate(eachop.Cmd),
                        option_=paramTranslate(eachop.Cmd,
                                               int(eachparam.subparameter))),
                    input_file_=os.path.join(RepDir, videochoice, segmentName),
                    output_file_=os.path.join(ExpDir,
                                              videochoice + " " + segmentName),
                ))

    ###now start to execute
    results = list()
    #print("results="+str(results))
    ###disable to test
    #    for test in tests:
    #        results.append(test.process())
    print("end" + str(transcodingcount))
    transcodingcount = transcodingcount + 1
    return results
Exemplo n.º 3
0
    tests = [
        #BW test
        #    benchmark.BTest(
        #            'convert_grayscale',
        #            lambda: args.grayscale_conversion_args(
        #                os.path.join(RepDir,"1","standardoutput1.ts"),
        #                os.path.join(ExpDir,"standardoutput1.ts")),
        #            input_file_=os.path.join(RepDir,"1","standardoutput1.ts"),
        #            output_file_=os.path.join(ExpDir,"standardoutput1.ts")
        #        )
        #try resolution
        benchmark.BTest(
            'Framerate',
            lambda: args.basic_video_convert_args(
                os.path.join(RepDir, VideoNum, SegmentName),
                os.path.join(ExpDir, SegmentName),
                fps_=5,
            ),
            input_file_=os.path.join(RepDir, VideoNum, SegmentName),
            output_file_=os.path.join(ExpDir, SegmentName),
        )
    ]

    #print(tests[0]._args_func)
    # Process each test and capture the results
    results = list()
    for test in tests:
        results.append(test.process())
    print('execution time=' +
          str(results[0][1]))  #### this is the execution time
    print('\n[----Benchmark results----]')
    list(map(_format_output, results))
Exemplo n.º 4
0
    print('-' * 100)


def _format_output(str_: str) -> None:
    """Formats printed output"""
    print(str_)
    print_sep()


###############################################################################
if __name__ == "__main__":
    # Test suite setup
    tests = [
        benchmark.BTest(
            OUTPUT_NAME_GRAYSCALE,
            lambda: args.grayscale_conversion_args(
                sample_files.SAMPLE_VIDEO_PPRESS, OUTPUT_FILES[OUTPUT_MP4]),
            input_file_=sample_files.SAMPLE_VIDEO_PPRESS,
            output_file_=OUTPUT_FILES[OUTPUT_MP4]),
        benchmark.BTest(OUTPUT_NAME_SCALE_VID,
                        lambda: args.scale_video_args(
                            sample_files.SAMPLE_VIDEO_PPRESS, OUTPUT_FILES[
                                OUTPUT_MP4], '1280:720'),
                        input_file_=sample_files.SAMPLE_VIDEO_PPRESS,
                        output_file_=OUTPUT_FILES[OUTPUT_MP4]),
        benchmark.BTest(OUTPUT_NAME_ENCODE_ADJUST,
                        lambda: args.encode_and_adjust_args(
                            sample_files.SAMPLE_VIDEO_PPRESS,
                            OUTPUT_FILES[OUTPUT_MKV],
                            bitrate_=1,
                            fps_=30,
                            scale_=720),