def test_h265_with_ac3(self, mock_subprocess): MediaConverter([VideoTrack('a.mkv', codecs.H265(constant_rate_factor=18, preset='slow')), AudioTrack('a.mkv', codecs.AC3('448k', 6, 48000))], 'b.mp4').convert() cmd = ['/somewhere/ffmpeg', '-y', '-analyzeduration', '2147483647', '-probesize', '2147483647', '-i', 'a.mkv', '-map', '0:v:0', '-c:v:0', 'libx265', '-preset', 'slow', '-x265-params', 'crf=18', '-map', '0:a:0', '-c:a:0', 'ac3', '-b:a', '448k', '-ac', '6', '-ar', '48000', '-threads', '0', 'b.mp4'] mock_subprocess.assert_called_with(cmd)
def test_multiple_video_filters(self, mock_subprocess): vos = VideoOutstream('a.mp4').deinterlace().scale(width=1920) MediaConverter([VideoTrack(vos, codecs.H264()), AudioTrack('a.mp4', codecs.AC3('448k', 6, 48000))], 'b.mp4').convert() cmd = ['/somewhere/ffmpeg', '-y', '-analyzeduration', '2147483647', '-probesize', '2147483647', '-i', 'a.mp4', '-filter_complex', '[0:v:0]yadif[vout0];[vout0]scale=1920:-2[vout1]', '-map', '[vout1]', '-c:v:0', 'h264', '-crf', '23', '-pix_fmt', 'yuv420p', '-profile:v', 'high', '-level', '3.1', '-map', '0:a:0', '-c:a:0', 'ac3', '-b:a', '448k', '-ac', '6', '-ar', '48000', '-threads', '0', 'b.mp4'] mock_subprocess.assert_called_with(cmd)
def test_delay_audio_for_5sec(self, mock_subprocess): delayed_instream = AudioInstream('a.mkv', start_at=5) MediaConverter([VideoTrack('a.mkv', codecs.H264()), AudioTrack(delayed_instream, codecs.AC3('448k', 6, 48000))], 'b.mp4').convert() cmd = ['/somewhere/ffmpeg', '-y', '-analyzeduration', '2147483647', '-probesize', '2147483647', '-i', 'a.mkv', '-analyzeduration', '2147483647', '-probesize', '2147483647', '-ss', '5', '-i', 'a.mkv', '-map', '0:v:0', '-c:v:0', 'h264', '-crf', '23', '-pix_fmt', 'yuv420p', '-profile:v', 'high', '-level', '3.1', '-map', '1:a:0', '-c:a:0', 'ac3', '-b:a', '448k', '-ac', '6', '-ar', '48000', '-threads', '0', 'b.mp4'] mock_subprocess.assert_called_with(cmd)
def test_overlay_filter_with_xy_option(self, mock_valid, mock_subprocess): mock_valid.side_effect = lambda x: x == 'a.png' vos = VideoOutstream('a.mp4').overlay('a.png', 30, 70) MediaConverter([VideoTrack(vos, codecs.H264()), AudioTrack('a.mp4', codecs.AC3('448k', 6, 48000))], 'b.mp4').convert() cmd = ['/somewhere/ffmpeg', '-y', '-analyzeduration', '2147483647', '-probesize', '2147483647', '-i', 'a.mp4', '-i', 'a.png', '-filter_complex', '[0:v:0][1:v:0]overlay=30:70[vout0]', '-map', '[vout0]', '-c:v:0', 'h264', '-crf', '23', '-pix_fmt', 'yuv420p', '-profile:v', 'high', '-level', '3.1', '-map', '0:a:0', '-c:a:0', 'ac3', '-b:a', '448k', '-ac', '6', '-ar', '48000', '-threads', '0', 'b.mp4'] mock_subprocess.assert_called_with(cmd)