CG Wire视频自动转码码率过大

作为流程控制协同工具,CG Wire可上传视频并在线标注审核。通过kitsu上传到zou的视频会自动转码,转码利用ffmpeg进行,默认HD模式源代码将码率写死为28M。只需手动修改码率值即可。python文件位置(按照cgwire的默认安装位置):

/opt/zou/zouenv/lib/python3.8/site-packages/zou/utils/movie.py

在如下代码中修改HD模式和LD模式对应的码率:

def normalize_movie(movie_path, fps, width, height):
    """
    Normalize movie using resolution, width and height given in parameter.
    Generates a high def movie and a low def movie.
    """
    folder_path = os.path.dirname(movie_path)
    file_source_name = os.path.basename(movie_path)
    file_target_name = "%s.mp4" % file_source_name[:-8]
    file_target_path = os.path.join(folder_path, file_target_name)
    low_file_target_name = "%s_low.mp4" % file_source_name[:-8]
    low_file_target_path = os.path.join(folder_path, low_file_target_name)

    (w, h) = get_movie_size(movie_path)
    resize_factor = w / h

    if width is None:
        width = math.floor(resize_factor * height)

    if width % 2 == 1:
        width = width + 1

    if height % 2 == 1:
        height = height + 1

    err = None
    if not has_soundtrack(movie_path):
        error_code, _, err = add_empty_soundtrack(movie_path)
        if error_code != 0:
            return file_target_path, low_file_target_path, err
        else:
            err = None

    # High def version
    normalize_encoding(
        movie_path,
        "Compute high def version",
        file_target_path,
        fps,
        "28M",    # 这里默认写的是28M码率,按照B站推荐码率,1080P为6M,4k为20M,8k为40M
        width,
        height,
    )

    # Low def version
    low_width = 1280
    low_height = math.floor((height / width) * low_width)
    if low_height % 2 == 1:
        low_height = low_height + 1
    normalize_encoding(
        movie_path,
        "Compute low def version",
        low_file_target_path,
        fps,
        "1M",
        low_width,
        low_height,
    )

    return file_target_path, low_file_target_path, err

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值