예제 #1
0
파일: core.py 프로젝트: Hoohm/pyHomeVM
def updateVideoDB(video_db, ffmpeg, local, file_id, file_name, state, folder_path):
    """
    Updates video db with the new videos.
    """
    if(not state):  # Store
        temp_vid = Video(
            file_id,
            os.path.join(folder_path, file_name),
            category='normal')
        temp_vid.populate_video_details(local)
        video_db[temp_vid.file_id] = temp_vid
    else:  # Already in our video DB
        video_db[file_id].file_path = os.path.join(folder_path, file_name)
예제 #2
0
파일: core.py 프로젝트: Hoohm/pyHomeVM
def createLongVideo(folder_path, video_list, local, remote, video_db):
    """
    Function that runs mkvmerge to create a long version of list of videos.
    Needs a chapter file (see createChaptersList)
    Input: folder_info as dict
    Ouptut: None
    """
    file_in = ''
    if(len(video_list) == 1):  # Only one video
        file_in += video_db[video_list[0]].file_path
    else:
        for file_id in video_list:
            file_in += "'{}' + ".format(
                video_db[file_id].file_path.encode('utf-8'))
        file_in = file_in.rstrip(' + ')
    chapters_file_path = os.path.join(
        folder_path, CONSTANTS['chapters_file_name'])
    output_file = os.path.join(
        folder_path,  # .encode('utf-8')
        os.path.basename(folder_path) + '.mkv')  # .encode('utf-8')
    command = "{} {} --quiet --chapters '{}' -o '{}'".format(
        local['mkvmerge_executable_path'].encode('utf-8'),
        file_in,
        os.path.join(
            folder_path,
            chapters_file_path).encode('utf-8'),
        output_file.encode('utf-8'))
    stdout, err = executeCommand(command)
    if(os.path.isfile(output_file)):
        output_file_id = create_file_id(output_file)
        temp_vid = Video(
            output_file_id,
            output_file,
            category='long')
        temp_vid.populate_video_details(local)
        video_db[output_file_id] = temp_vid
    else:
        logger.info('Folder {} has some errors for merging'.format(folder_path.encode('utf-8')))
    os.remove(chapters_file_path)
예제 #3
0
파일: core.py 프로젝트: Hoohm/pyHomeVM
def correct_video(state, file_path, file_id, local, ffmpeg):
    """Function that deals with errors in videos or corrupted videos."""
    folder_path = os.path.dirname(file_path)
    if(state == 'corrupt'):  # Move the file into corrupted folder
        if(not os.path.exists(os.path.join(folder_path, 'corrupted'))):
            os.makedirs(os.path.join(folder_path, 'corrupted'))
        os.rename(
            file_path,
            os.path.join(folder_path, 'corrupted', os.path.basename(file_path)))
    elif(state == 'error'):  # Reencode
        if(not os.path.exists(os.path.join(folder_path, 'errors'))):
            os.makedirs(os.path.join(folder_path, 'errors'))
        new_file_path = os.path.join(
            folder_path, 'errors',
            os.path.basename(file_path))
        os.rename(file_path, new_file_path)
        temp_vid = Video(file_id, new_file_path, category='error')
        temp_vid.populate_video_details(local)
        temp_vid.baseConvertVideo(
            ffmpeg,
            local,
            os.path.splitext(file_path)[0] + '.mp4')