Exemplo n.º 1
0
def to_hls(input, segments, playlist):

    try:
        process.check_output([
            'ffmpeg',
            '-i "%s"' % input,
            '-sn',
            '-acodec copy',
            '-vcodec copy',
            '-bsf h264_mp4toannexb',
            '-flags -global_header',
            '-map 0',
            '-f segment',
            '-segment_time 10',
            '-segment_list "%s"' % playlist,
            '-segment_format mpegts',
            '"%s"' % segments
        ])

    except process.CalledProcessError, e:
        raise TransmuxingError(e)
Exemplo n.º 2
0
def make_thumbnail(stream, filename="thumb.jpg", clobber=False, **kwargs):

    outfile = os.path.join(stream, filename)

    if not clobber and os.path.exists(outfile):
        return (Processing.WILL_NOT_CLOBBER, outfile)

    segments = fs.glob(os.path.join(stream, "*.ts"))

    if not segments:
        raise ValueError("stream '%s' does not contain any segments" % stream)

    segment = random.choice(segments)

    dimensions = kwargs.get("dimensions", "240x135")

    try:
        process.check_output(["ffmpeg", "-i", segment, "-vframes", "1", "-an", "-s", dimensions, "-ss", "1", outfile])

        return (Processing.COMPLETE, outfile)
    except process.CalledProcessError, e:
        raise ProcessingError(e.output)