Esempio n. 1
0
    def file_probe(self, vid_file_path):
        """
        Give a json from ffprobe command line

        :param vid_file_path: The absolute (full) path of the video file, string.
        :return:
        """
        # Get the file probe info
        probe_info = unffmpeg.Info().file_probe(vid_file_path)

        # Get FPS from file probe info
        self.src_fps = None
        try:
            self.src_fps = eval(probe_info['streams'][0]['avg_frame_rate'])
        except ZeroDivisionError:
            # Warning, Cannot use input FPS
            self._log('Warning, Cannot use input FPS', level='warning')
        if self.src_fps == 0:
            raise ValueError('Unexpected zero FPS')

        # Get Duration from file probe info
        self.duration = None
        try:
            self.duration = float(probe_info['format']['duration'])
        except ZeroDivisionError:
            # Warning, Cannot use input Duration
            self._log('Warning, Cannot use input Duration', level='warning')

        if self.src_fps is None and self.duration is None:
            raise ValueError('Unable to match against FPS or Duration.')

        return probe_info
Esempio n. 2
0
 def test_can_read_ffmpeg_supported_codecs(self):
     # Fetch a list of supported codecs from unffmpeg
     all_codecs = unffmpeg.Info().get_all_supported_codecs()
     # Ensure audio codecs are available
     assert 'audio' in all_codecs
     # Ensure video codecs are available
     assert 'video' in all_codecs
Esempio n. 3
0
 def test_can_read_ffmpeg_supported_video_codecs(self):
     # Fetch a list of supported codecs from unffmpeg
     all_codecs = unffmpeg.Info().get_all_supported_codecs()
     # Ensure h264 is available
     assert 'h264' in all_codecs['video']
     # Ensure h265 is available
     assert 'hevc' in all_codecs['video']
     # Ensure a gibberish codec is not available
     assert 'NONSENSE CODEC' not in all_codecs['video']
Esempio n. 4
0
    def __init__(self):
        # Non config items (objects)
        self.name = "Config"
        self.settings = None

        # Set default db config
        self.apply_default_db_settings()
        # Run DB migrations
        self.run_db_migrations()
        # Init DB connection and read settings
        self.import_settings_from_db()
        # Import env variables
        self.import_settings_from_env()
        # Finally, read config from file and override all above settings.
        self.import_settings_from_file()
        # Apply settings to the unmanic logger
        self.setup_unmanic_logger()
        # Set the supported codecs (for destination)
        self.SUPPORTED_CODECS = unffmpeg.Info().get_all_supported_codecs()
        # Set the supported containers (for destination)
        self.SUPPORTED_CONTAINERS = unffmpeg.containers.get_all_containers()