Example #1
0
    def test_convert_video_success(self):
        v = VideoFFMpeg(verbose=False)
        status = v.convert_video('test.mp4', 'test.flv')
        if os.path.exists('test.flv'):
            os.unlink('test.flv')

        self.assertTrue(status)
Example #2
0
 def test_add_audio_already_exists(self):
     v = VideoFFMpeg(verbose=False)
     # test.mp4 already has an audio stream
     # check if AudioAlreadyExists error is being
     # raised when trying to add audio stream to a
     # video file which already has one
     try:
         v.add_audio_to_video('test.mp4', 'testwithaudio.mp4', 'test.aac')
     except AudioAlreadyExistsError:
         e = sys.exc_info()[1]
         self.assertEqual(e.message, 'Audio stream exists')
     else:
         self.fail('Exception was not thrown')
Example #3
0
 def test_ffmpeg_already_exists_error(self):
     # test if FFMpegAlreadyExistsError exception
     # is thrown when file we want to produce with
     # ffmpeg already exists
     message = "File 'test.avi' already exists. Overwrite ? [y/N]"
     v = VideoFFMpeg(verbose=False)
     try:
         v.convert_video('test.mp4', 'test.avi')
     except FFMpegAlreadyExistsError:
         e = sys.exc_info()[1]
         self.assertEqual(e.message, message)
     else:
         self.fail('Exception was not thrown')
Example #4
0
    def test_add_audio_to_video(self):
        # test if method can add an audio stream
        # to a video file which does not have one
        f = FFMpeg(verbose=False)
        v = VideoFFMpeg(verbose=False)
        v.add_audio_to_video('noaudio.mp4', 'gotaudio.mp4', 'test.aac')
        # get the second stream
        stream = f.probe('gotaudio.mp4').streams[1]

        self.assertEqual(stream.codec.codec_type, 'audio')

        # unlink the output video file
        if os.path.exists('gotaudio.mp4'):
            os.unlink('gotaudio.mp4')