Exemplo n.º 1
0
    def test_frame_rate(self, mock_subprocess):
        MediaConverter([VideoTrack('a.mp4', codecs.H264(frame_rate=30))], 'b.mp4').convert()

        cmd = ['/somewhere/ffmpeg', '-y',
               '-analyzeduration', '2147483647', '-probesize', '2147483647', '-i', 'a.mp4',
               '-map', '0:v:0', '-c:v:0', 'h264', '-crf', '23', '-pix_fmt', 'yuv420p',
               '-profile:v', 'high', '-level', '3.1', '-r', '30',
               '-threads', '0', 'b.mp4']
        mock_subprocess.assert_called_with(cmd)
Exemplo n.º 2
0
    def test_blank_video_with_audio(self, mock_subprocess):
        MediaConverter([VideoTrack(None, codecs.H264()),
                        AudioTrack('a.mp3', codecs.AAC())], 'b.mp4').convert()

        cmd = ['/somewhere/ffmpeg', '-y',
               '-s', '640x360', '-f', 'rawvideo', '-pix_fmt', 'rgb24', '-r', '30', '-i', '/dev/zero',
               '-analyzeduration', '2147483647', '-probesize', '2147483647', '-i', 'a.mp3',
               '-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', 'aac', '-b:a', '192k', '-ac', '2', '-ar', '44100',
               '-shortest',
               '-threads', '0', 'b.mp4']
        mock_subprocess.assert_called_with(cmd)
Exemplo n.º 3
0
    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)
Exemplo n.º 4
0
    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)
Exemplo n.º 5
0
    def test_image_video_with_audio(self, mock_valid, mock_subprocess):
        mock_valid.return_value = True
        MediaConverter([VideoTrack('a.png', codecs.H264()),
                        AudioTrack('a.mp3', codecs.AAC())], 'b.mp4').convert()

        cmd = ['/somewhere/ffmpeg', '-y',
               '-i', 'a.png',
               '-analyzeduration', '2147483647', '-probesize', '2147483647', '-i', 'a.mp3',
               '-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', 'aac', '-b:a', '192k', '-ac', '2', '-ar', '44100',
               '-threads', '0', 'b.mp4']
        mock_subprocess.assert_called_with(cmd)
Exemplo n.º 6
0
    def test_subtitle_language(self, mock_subprocess):
        MediaConverter([VideoTrack('a.mp4', codecs.H264()),
                        AudioTrack('a.mp4', codecs.AAC()),
                        SubtitleTrack('a.srt', codecs.TimedText(), language='kor')], 'b.mp4').convert()

        cmd = ['/somewhere/ffmpeg', '-y',
               '-analyzeduration', '2147483647', '-probesize', '2147483647', '-i', 'a.mp4',
               '-analyzeduration', '2147483647', '-probesize', '2147483647', '-i', 'a.srt',
               '-map', '0:v:0', '-c:v:0', 'h264', '-crf', '23', '-pix_fmt', 'yuv420p',
               '-profile:v', 'high', '-level', '3.1',
               '-map', '0:a:0', '-c:a:0', 'aac', '-b:a', '192k', '-ac', '2', '-ar', '44100',
               '-map', '1:s:0', '-c:s:0', 'mov_text',
               '-metadata:s:s:0', 'language=kor',
               '-threads', '0', 'b.mp4']
        mock_subprocess.assert_called_with(cmd)
Exemplo n.º 7
0
    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)