示例#1
0
    async def cut_video(self, cut_from, duration, video_file_path, output_path,
                        use_copy):
        if self.config['ffmpeg_path'] is not None and self.config[
                'ffmpeg_path'] != '':
            ffmpeg = FFmpeg(self.config['ffmpeg_path'])
        else:
            ffmpeg = FFmpeg()

        ffmpeg = ffmpeg.option('ss', cut_from).input(
            os.path.abspath(video_file_path))

        if use_copy:
            ffmpeg = ffmpeg.output(output_path, c='copy', t=duration)
        else:
            ffmpeg = ffmpeg.output(output_path, t=duration)

        @ffmpeg.on('start')
        def on_start(arguments):
            print('ffmpeg arguments: ', arguments)

        @ffmpeg.on('stderr')
        def on_stderr(line):
            print('ffmpeg out:', line)

        @ffmpeg.on('completed')
        def on_completed():
            print('Completed')

        @ffmpeg.on('terminated')
        def on_terminated():
            print('Terminated')

        @ffmpeg.on('error')
        def on_error(code):
            print('Error:', code)

        await ffmpeg.execute()
示例#2
0
from ffmpeg import FFmpeg
import asyncio
import sys

ffscale = FFmpeg()


@ffscale.on('completed')
def on_complete():
    print("completed")


# @ffscale.on('progress')
# def on_ffprobe_progress(progress):
#     print(progress.resolution)

new_file = sys.argv[1] + "_scale"
filter_scale = "scale=" + sys.argv[2]

ffscale.input(sys.argv[1])
ffscale.output(new_file, {'filter_complex': filter_scale}, f='mp4')
loop = asyncio.get_event_loop()
loop.run_until_complete(ffscale.execute())
loop.close()
示例#3
0
from ffmpeg import FFmpeg
import asyncio
import sys

resolution = ""
ffmpeg = FFmpeg()


@ffmpeg.on('progress')
def on_ffmpeg_progress(progress):
    if 'VMAF' in progress._fields:
        print(progress.VMAF)


ffmpeg.input(sys.argv[1])
ffmpeg.input(sys.argv[2])
ffmpeg.output("-", {'filter_complex': 'libvmaf'}, f="null")
loop = asyncio.get_event_loop()
loop.run_until_complete(ffmpeg.execute())
loop.close()
from ffmpeg import FFmpeg as ffmpeg

input_stream = ffmpeg.input('input.mp4', f='mp4')
output_stream = ffmpeg.output(input_stream, 'output.m3u8', format='hls', start_number=0, hls_time=5, hls_list_size=0)
ffmpeg.run(output_stream)
示例#5
0
from ffmpeg import FFmpeg
import asyncio
import sys

resolution = ""
ffmpeg = FFmpeg(executable='ffmpeg')


@ffmpeg.on('progress')
def on_ffmpeg_progress(progress):
    if 'PSNR' in progress._fields:
        print(progress.PSNR)


ffmpeg.input(sys.argv[1])
ffmpeg.input(sys.argv[2])
ffmpeg.output("-", {'filter_complex': 'psnr'}, f="null")
loop = asyncio.get_event_loop()
loop.run_until_complete(ffmpeg.execute())
loop.close()
示例#6
0
from ffmpeg import FFmpeg
import asyncio
import sys

resolution = ""
ffmpeg = FFmpeg(executable='ffmpeg')


@ffmpeg.on('progress')
def on_ffmpeg_progress(progress):
    if 'SSIM' in progress._fields:
        print(progress.SSIM)


ffmpeg.input(sys.argv[1])
ffmpeg.input(sys.argv[2])
ffmpeg.output("-", {'filter_complex': 'ssim'}, f="null")
loop = asyncio.get_event_loop()
loop.run_until_complete(ffmpeg.execute())
loop.close()