Example #1
0
def transcode(*args):
    '''
    transcode the video to mp4 format
    '''
    # print args, kwargs
    context = args[0]
    for bitrate in context["bitrateList"]:
        parameters = compute_quantification_parameters(bitrate)
        if not os.path.exists(get_transcoded_folder(context)):
            os.makedirs(get_transcoded_folder(context))
        args = get_welsenc_path(context) + " -org " + get_yuv_file(
            context
        ) + " -bf " + get_transcoded_file(context, bitrate) + " -sw " + str(
            context["track_width"]) + " -sh " + str(
                context["track_height"]
            ) + " -tarb " + str(bitrate) + " -minqp " + str(
                parameters["min_qp"]) + " -maxqp " + str(
                    parameters["max_qp"]
                ) + " -ltarb " + get_layer_path(context) + " " + str(
                    bitrate) + " -lqp " + get_layer_path(context) + " " + str(
                        parameters["in_qp"]
                    ) + " -dw " + get_layer_path(context) + " " + str(
                        context["target_width"]) + " -dh " + get_layer_path(
                            context) + " " + str(context["target_height"])
        run_background(args)
        print args

    return context
def chunk_hls(*args, **kwargs):
    '''
    create hls chunks and the version specific playlist
    '''
    # print args, kwargs
    context = args[0]

    if not os.path.exists(get_hls_transcoded_folder(context)):
        os.makedirs(get_hls_transcoded_folder(context))

    ffargs = "ffmpeg -i " + get_transcoded_file(
        context) + " -map 0 -flags +global_header -vcodec copy -vbsf h264_mp4toannexb -acodec copy -f segment -segment_format mpegts -segment_time " + str(
        context["segtime"]) + " -segment_wrap 0 -segment_list " + get_hls_transcoded_playlist(
        context) + " " + get_hls_transcoded_folder(context) + "/chunks_name%03d.ts"
    print ffargs
    run_background(ffargs)
    return context
def transcode(*args, **kwargs):
    '''
    transcode the video to mp4 format
    '''
    # print args, kwargs
    context = args[0]
    context["bitrate"] = kwargs['bitrate']
    context["segtime"] = kwargs['segtime']
    dimsp = str(context["target_width"]) + ":" + str(context["target_height"])
    if not os.path.exists(get_transcoded_folder(context)):
        os.makedirs(get_transcoded_folder(context))
    run_background(
        "ffmpeg -i " + context[
            "original_file"] + " -c:v libx264 -profile:v main -level 3.1 -b:v " + str(context["bitrate"]) + "k -vf scale=" + dimsp + " -c:a aac -strict -2 -force_key_frames expr:gte\(t,n_forced*" + str(
        context["segtime"]) + "\) " + get_transcoded_file(
            context))
    return context
def transcode(*args, **kwargs):
    '''
    transcode the video to mp4 format
    '''
    # print args, kwargs
    context = args[0]
    context["bitrate"] = kwargs['bitrate']
    context["segtime"] = kwargs['segtime']
    dimsp = str(context["target_width"]) + ":" + str(context["target_height"])
    if not os.path.exists(get_transcoded_folder(context)):
        os.makedirs(get_transcoded_folder(context))
    run_background(
        "ffmpeg -i " + context["original_file"] +
        " -c:v libx264 -profile:v main -level 3.1 -b:v " +
        str(context["bitrate"]) + "k -vf scale=" + dimsp +
        " -c:a aac -strict -2 -force_key_frames expr:gte\(t,n_forced*" +
        str(context["segtime"]) + "\) " + get_transcoded_file(context))
    return context
def chunk_hls(*args, **kwargs):
    '''
    create hls chunks and the version specific playlist
    '''
    # print args, kwargs
    context = args[0]

    if not os.path.exists(get_hls_transcoded_folder(context)):
        os.makedirs(get_hls_transcoded_folder(context))

    ffargs = "ffmpeg -i " + get_transcoded_file(
        context
    ) + " -map 0 -flags +global_header -vcodec copy -vbsf h264_mp4toannexb -acodec copy -f segment -segment_format mpegts -segment_time " + str(
        context["segtime"]
    ) + " -segment_wrap 0 -segment_list " + get_hls_transcoded_playlist(
        context) + " " + get_hls_transcoded_folder(
            context) + "/chunks_name%03d.ts"
    print ffargs
    run_background(ffargs)
    return context
Example #6
0
def transcode(*args, **kwargs):
    '''
    transcode the video to mp4 format
    '''
    # print args, kwargs
    context = args[0]
    context["bitrate"] = kwargs['bitrate']
    context["segtime"] = kwargs['segtime']
    dimsp = str(context["target_width"]) + ":" + str(context["target_height"])
    if not os.path.exists(get_transcoded_folder(context)):
        try:
            os.makedirs(get_transcoded_folder(context))
        except OSError as e:
            pass

    command_line = "ffmpeg -i " + context[
        "original_file"] + " -c:v libx264 -profile:v main -level 3.1 -b:v " + str(
            context["bitrate"]
        ) + "k -vf scale=" + dimsp + " -c:a aac -strict -2 -force_key_frames expr:gte\(t,n_forced*" + str(
            context["segtime"]) + "\) " + get_transcoded_file(context)
    print("transcoding commandline %s" % command_line)
    subprocess.call(command_line, shell=True)
    return context
Example #7
0
def transcode(*args, **kwargs):
    '''
    transcode the video to mp4 format
    '''
    # print args, kwargs
    context = args[0]
    context["bitrate"] = kwargs['bitrate']
    context["segtime"] = kwargs['segtime']
    dimsp = str(context["target_width"]) + ":" + str(context["target_height"])
    if not os.path.exists(get_transcoded_folder(context)):
        try:
            os.makedirs(get_transcoded_folder(context))
        except OSError as e:
            pass

    command_line = "ffmpeg -i " + context[
        "original_file"] + " -c:v libx264 -profile:v main -level 3.1 -b:v " + str(context[
        "bitrate"]) + "k -vf scale=" + dimsp + " -c:a aac -strict -2 -force_key_frames expr:gte\(t,n_forced*" + str(
        context["segtime"]) + "\) " + get_transcoded_file(
        context)
    print("transcoding commandline %s" % command_line)
    subprocess.call(command_line,
                    shell=True)
    return context