Exemplo n.º 1
0
def merge_subtitle_to_video_view(request, video_id, mode, sub_lang_type):
    """
    将指定语言类型的字幕合并到video_id的视频中
    :param request:
    :param video_id:
    :param sub_lang_type:
    :return:
    """
    add_subtitle_to_video_process(video_id, mode, sub_lang_type)

    return render_to_response('result.html', {'text': '合并的字幕到视频完成!'})
Exemplo n.º 2
0
def download_upload_video(video_id):
    """
    下载video_id为 video_id 的youtube视频和中英字幕,合并字幕到视频,设置优酷目录,然后上传到优酷
    :param video_id:
    :return:
    """
    video = Video.objects.get(pk=video_id)

    if not video.file:
        video_filepath = download_single_youtube_video_main(video_id)
    else:
        video_filepath = False

    if not video.subtitle_en:
        subtitle_fielpath_list = download_subtitle(video_id)
    else:
        subtitle_fielpath_list = []

    # merge_sub_edit_style(video_id)
    # 将video_id对应的Video对象的中文vtt字幕转换为ass格式
    # 并将中文ass字幕的地址保存到subtitle_merge字段
    # 然后修改ass字幕的文字式样
    change_vtt_to_ass_and_edit_style(video_id)

    # 将字幕用软压的方式添加到视频上
    # 优酷推荐的格式未:MKV容器格式,内嵌字幕的字体最好是用黑体,SSA/SRT都支持的比较好,SUB支持的不怎么好。
    # 文本编码一般正常情况下都能识别,如果不能识别就改成ANSI
    # https://www.hi-pda.com/forum/viewthread.php?tid=1962179
    add_subtitle_to_video_process(video_id, mode='soft', sub_lang_type='merge')

    # 如果该video没有对应的Youku对象,就新建一个,title就用video的英文title
    if not hasattr(video, 'youku'):
        Youku.objects.create(title=video.title, video=video)

    set_youku_category_local(video.youku.id)

    if not video.youku.youku_video_id:
        youku_video_id = youku_upload(video.youku.id)

        if youku_video_id:
            # 在playlist_config表中,根据video_id视频所属的youtube
            # playlist对应的youku playlist
            # 设置该视频在优酷上的playlist
            set_youku_playlist_online_from_playlist_config(video_id)
    else:
        youku_video_id = False

    return (video_filepath, subtitle_fielpath_list, youku_video_id)
Exemplo n.º 3
0
def download_upload_video(video_id):
    """
    下载video_id为 video_id 的youtube视频和中英字幕,合并字幕到视频,设置优酷目录,然后上传到优酷
    :param video_id:
    :return:
    """
    video = Video.objects.get(pk=video_id)

    if not video.file:
        video_filepath = download_single_youtube_video_main(video_id)
    else:
        video_filepath = False

    if not video.subtitle_en:
        subtitle_fielpath_list = download_subtitle(video_id)
    else:
        subtitle_fielpath_list = []

    # merge_sub_edit_style(video_id)

    # 将字幕添加到视频上
    # todo 因为Linode上压制字幕到视频很慢,用时很长,所以先注释掉 2016-3-31
    add_subtitle_to_video_process(video_id, sub_lang_type='zh-Hans')

    # 如果该video没有对应的Youku对象,就新建一个,title就用video的英文title
    if not hasattr(video, 'youku'):
        Youku.objects.create(title=video.title, video=video)

    set_youku_category_local(video.youku.id)

    if not video.youku.video_id:
        youku_video_id = youku_upload(video.youku.id)
    else:
        youku_video_id = False

    return (video_filepath, subtitle_fielpath_list, youku_video_id)
Exemplo n.º 4
0
def merge_subtitle_to_video_view(request, video_id, mode, sub_lang_type):
    """
    将指定语言类型的字幕合并到video_id的视频中
    :param request:
    :param video_id:
    :param sub_lang_type:
    :return:
    """
    result = add_subtitle_to_video_process(video_id, mode, sub_lang_type)

    if result:
        text = '合并的字幕到视频完成!'
    else:
        text = '合并的字幕到视频失败!'

    return render_to_response('result.html', {'text': text})