def setUp(self) -> None: super().setUp() self.video_meta = video_meta_data(width=1920, height=1080) self.audio_meta = audio_meta_data() self.source = input_file('input.mp4', Stream(VIDEO, self.video_meta), Stream(AUDIO, self.audio_meta)) self.output1 = output_file('output1.mp4', VideoCodec('libx264'), AudioCodec('aac')) self.output2 = output_file('output2.mp5', VideoCodec('libx265'), AudioCodec('libfdk_aac')) self.simd = SIMD(self.source, self.output1, self.output2)
def test_vector_metadata(self): """ Checks that vector outputs metadata for a single stream in it. """ with self.subTest("input meta"): v = self.simd.video self.assertEqual(v.meta, self.video_meta) with self.subTest("filter meta"): v = v | Scale(1280, 720) expected = replace(self.video_meta, width=1280, height=720) self.assertEqual(v.meta, expected) with self.subTest("codec meta"): simd = SIMD(self.source, self.output1) x = v > simd self.assertEqual(x.meta, expected)
from fffw.graph import * # detect information about input file mi = MediaInfo.parse('source.mp4') video_meta, audio_meta = from_media_info(mi) # initialize input file with stream and metadata source = input_file('source.mp4', Stream(VIDEO, video_meta), Stream(AUDIO, audio_meta)) outputs = [] for size in 360, 540, 720, 1080: out = output_file(f'{size}.mp4', VideoCodec('libx264'), AudioCodec('aac')) outputs.append(out) simd = SIMD(source, *outputs) mi = MediaInfo.parse('logo.png') logo_meta, = from_media_info(mi) # add a logo logo = simd < input_file('logo.png', Stream(VIDEO, logo_meta)) trim = [ { 'kind': VIDEO, 'start': 25, 'end': 50 }, { 'kind': VIDEO,