Esempio n. 1
0
 def setUp(self) -> None:
     self.v1 = inputs.Stream(StreamType.VIDEO)
     self.v2 = inputs.Stream(StreamType.VIDEO)
     self.a1 = inputs.Stream(StreamType.AUDIO)
     self.a2 = inputs.Stream(StreamType.AUDIO)
     self.a3 = inputs.Stream(StreamType.AUDIO)
     self.i1 = inputs.Input(streams=(self.v1, self.a1))
     self.i2 = inputs.Input(streams=(self.a2, self.v2, self.a3))
Esempio n. 2
0
    def setUp(self) -> None:
        super().setUp()
        self.video_metadata = video_meta_data(width=1920,
                                              height=1080,
                                              dar=1.777777778,
                                              par=1.0,
                                              duration=300.0,
                                              frame_rate=10.0,
                                              frame_count=3000)
        self.source_audio_duration = 200.0
        self.source_sampling_rate = 48000
        self.source_samples_count = (self.source_audio_duration *
                                     self.source_sampling_rate)
        self.source_audio_bitrate = 128000
        self.audio_metadata = audio_meta_data(
            duration=self.source_audio_duration,
            sampling_rate=self.source_sampling_rate,
            samples_count=self.source_samples_count,
            bit_rate=self.source_audio_bitrate,
        )
        self.target_audio_bitrate = 64000

        self.source = inputs.Input(
            input_file='input.mp4',
            streams=(inputs.Stream(VIDEO, meta=self.video_metadata),
                     inputs.Stream(AUDIO, meta=self.audio_metadata)))
        self.output = outputs.output_file(
            'output.mp4', codecs.VideoCodec('libx264'),
            FdkAAC(bitrate=self.target_audio_bitrate))
        self.input_list = inputs.InputList((self.source, ))
        self.output_list = outputs.OutputList((self.output, ))
        self.fc = FilterComplex(self.input_list, self.output_list)
Esempio n. 3
0
    def test_append_source(self):
        """
        Source file streams receive indices when appended to input list.
        """
        il = inputs.InputList()
        v3 = inputs.Stream(StreamType.VIDEO)

        il.append(inputs.Input(streams=(v3, )))

        self.assertEqual(v3.name, '0:v')
Esempio n. 4
0
 def test_default_input(self):
     """
     By default each input has a video and an audio stream without meta.
     """
     source = inputs.Input()
     self.assertEqual(len(source.streams), 2)
     v = source.streams[0]
     self.assertEqual(v.kind, StreamType.VIDEO)
     self.assertIsNone(v._meta)
     a = source.streams[1]
     self.assertEqual(a.kind, StreamType.AUDIO)
     self.assertIsNone(a._meta)
Esempio n. 5
0
    def setUp(self) -> None:
        self.video_metadata = meta.video_meta_data(
            width=1920,
            height=1080,
            dar=1.777777778,
            par=1.0,
            duration=300.0,
        )
        self.audio_metadata = meta.audio_meta_data()

        self.source = inputs.Input(
            input_file='input.mp4',
            streams=(inputs.Stream(VIDEO, meta=self.video_metadata),
                     inputs.Stream(AUDIO, meta=self.audio_metadata)))
        self.output = outputs.Output(
            output_file='output.mp4',
            codecs=[H264Cuda(), codecs.AudioCodec('aac')])
Esempio n. 6
0
    def test_validate_input_hardware(self):
        """
        Hardware-decoded input could not be passed to CPU codec and so on.
        """
        vs = inputs.Stream(StreamType.VIDEO,
                           meta=video_meta_data(width=640, height=360))
        src = inputs.Input(streams=(vs, ), hardware='cuda', device='foo')

        @dataclass
        class X264(VideoCodec):
            codec = 'libx264'
            hardware = None  # cpu only

        with self.assertRaises(ValueError):
            src.video > X264()

        with self.assertRaises(ValueError):
            src.video | filters.Scale(640, 360)

        src.video | ScaleNPP(640, 360) > H264Cuda()
Esempio n. 7
0
    def setUp(self) -> None:
        super().setUp()
        self.video_metadata = video_meta_data(width=1920,
                                              height=1080,
                                              dar=1.777777778,
                                              par=1.0,
                                              duration=300.0,
                                              frame_rate=10.0,
                                              frame_count=3000)
        self.audio_metadata = audio_meta_data(duration=200.0,
                                              sampling_rate=48000,
                                              samples_count=200 * 48000)

        self.source = inputs.Input(
            input_file='input.mp4',
            streams=(inputs.Stream(VIDEO, meta=self.video_metadata),
                     inputs.Stream(AUDIO, meta=self.audio_metadata)))
        self.output = outputs.output_file('output.mp4',
                                          codecs.VideoCodec('libx264'),
                                          codecs.AudioCodec('libfdk_aac'))
        self.input_list = inputs.InputList((self.source, ))
        self.output_list = outputs.OutputList((self.output, ))
        self.fc = FilterComplex(self.input_list, self.output_list)