FFmpeg 转换哔哩哔哩视频为 mp4 格式

# encoding:utf-8
import json
import os

base_dir = r"C:\Users\hj\Desktop\65548392\65548392"
output_path = r"F:\400-练习脚本\kafka"  # 输出结果


def check_str():
    """
    检查中英文
    :return:
    """
    os.chdir(base_dir)
    for item in os.listdir(base_dir):
        dir_path = os.path.join(base_dir, item)
        entry_json_path = os.path.join(dir_path, 'entry.json')
        title = read_json(entry_json_path)  # 视频标题
        file_name = f"{title}.mp4"

        os.system(f"ffmpeg -i ./{item}/80/audio.m4s -i ./{item}/80/video.m4s -codec copy {output_path}/{file_name}")


def read_json(json_path):
    """
    读取 json 文件,获取文件名
    :param json_path:
    :return:
    """
    with open(json_path, encoding='utf-8') as f:
        content = json.loads(f.read())
        return content['page_data']['part']


if __name__ == '__main__':
    check_str()
上一篇:you-get 视频下载


下一篇:[转] MP4视频测试URL地址