Esempio n. 1
0
    def smi_to_srt(sub_path):
        def _detect(file_path):
            detector = UniversalDetector()
            fp = open(file_path, 'rb')
            for line in fp:
                line = line.replace(b'\r', b'')
                detector.feed(line)
                if detector.done:
                    break

            fp.close()
            detector.close()

            return detector.result['encoding']

        srt_path = fileutil.generate_temporary_file_path('.srt')
        tmp_sub_path = fileutil.generate_temporary_file_path('.smi')

        char_type = _detect(sub_path)
        context = open(sub_path, 'r', encoding=char_type, errors='ignore').read()
        open(tmp_sub_path, 'w', encoding='utf8').write(context)
        sub_path = tmp_sub_path

        cmd = ['/usr/local/bin/ffmpeg', '-y',
               '-i', sub_path,
               srt_path]

        processutil.call(cmd)
        return srt_path
Esempio n. 2
0
def mux(mediafile, *args):
    mkv_path = fileutil.generate_temporary_file_path('.mkv')
    cmd = ['/usr/local/bin/mkvmerge', '-o', mkv_path, mediafile]
    cmd.extend(args)
    processutil.call(cmd)

    return mkv_path
Esempio n. 3
0
def concat(mediafile, *args):
    mkv_path = fileutil.generate_temporary_file_path('.mkv')
    cmd = ['/usr/local/bin/mkvmerge', '-o', mkv_path, '--no-chapters', '--no-subtitles', mediafile]
    for arg in args:
        cmd.extend(['--no-chapters', '--no-subtitles', '+%s' % arg])
    processutil.call(cmd)

    return mkv_path
Esempio n. 4
0
    def command(self):
        if self._command is None:
            self._init_command()
            self._add_analyze_options()
            self._add_infiles_options()
            self._add_stream_options()
            self._add_duration_option()
            self._add_framerate_options()
            self._command.extend(['-threads', '0', fileutil.generate_temporary_file_path(self._container.extension)])

        return self._command
Esempio n. 5
0
    def change_container(src, container):
        dst = fileutil.generate_temporary_file_path(container.extension)
        processutil.call(['/usr/local/bin/ffmpeg', '-y', '-i', src, '-map', '0', '-c', 'copy', dst])

        return dst