From e32c1b48e6797aae8cf2748abfdc4083f0d50f65 Mon Sep 17 00:00:00 2001 From: Amoh Gyebi Ampofo Date: Fri, 14 Oct 2022 23:48:53 +0000 Subject: [PATCH 1/3] fix logger --- pyffmpeg/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyffmpeg/__init__.py b/pyffmpeg/__init__.py index 17f50d7..450b275 100644 --- a/pyffmpeg/__init__.py +++ b/pyffmpeg/__init__.py @@ -27,7 +27,7 @@ fh.setLevel(logging.DEBUG) ch.setLevel(logging.DEBUG) -formatter = logging.Formatter('%(asctime) - %(name)s - %(levelname)s - %(message)s') +formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') fh.setFormatter(formatter) ch.setFormatter(formatter) From 5561efa7d69d7c00d37aa85c7e9026cca7644964 Mon Sep 17 00:00:00 2001 From: Amoh Gyebi Ampofo Date: Sat, 15 Oct 2022 00:32:15 +0000 Subject: [PATCH 2/3] Update __init__.py --- pyffmpeg/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pyffmpeg/__init__.py b/pyffmpeg/__init__.py index 450b275..aae92dc 100644 --- a/pyffmpeg/__init__.py +++ b/pyffmpeg/__init__.py @@ -49,6 +49,7 @@ def __init__(self, directory="."): self.logger = logging.getLogger('pyffmpeg.FFmpeg') self.logger.info('FFmpeg Initialising') self.save_dir = directory + self.logger.info(f"Save directory: {self.save_dir}") self.overwrite = True self.loglevels = ( 'quiet', 'panic', 'fatal', 'error', 'warning', @@ -69,6 +70,7 @@ def __init__(self, directory="."): # instances are store according to function names self._ffmpeg_instances = {} self._ffmpeg_file = Paths().load_ffmpeg_bin() + self.logger.info(f"FFmpeg file: {self._ffmpeg_file}") self.error = '' def convert(self, input_file, output_file): From c8f711e74269f118c90b378b46643179f76bde0e Mon Sep 17 00:00:00 2001 From: Amoh Gyebi Ampofo Date: Sat, 15 Oct 2022 01:15:07 +0000 Subject: [PATCH 3/3] fix #524 --- pyffmpeg/__init__.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/pyffmpeg/__init__.py b/pyffmpeg/__init__.py index aae92dc..92d963e 100644 --- a/pyffmpeg/__init__.py +++ b/pyffmpeg/__init__.py @@ -79,14 +79,18 @@ def convert(self, input_file, output_file): Converts and input file to the output file """ + self.logger.info('Inside convert function') if os.path.isabs(output_file): # absolute file out = output_file else: # not an absolute file out = os.path.join(self.save_dir, output_file) + + self.logger.info(f"Output file: {out}") inf = input_file.replace("\\", "/") + self.logger.info(f"Input file: {inf}") if self.loglevel not in self.loglevels: msg = 'Warning: "{}" not an ffmpeg loglevel flag.' +\ @@ -98,6 +102,9 @@ def convert(self, input_file, output_file): options = options.format(self._ffmpeg_file, self.loglevel) options += '{} -i' options = options.format(self._over_write) + + self.logger.info(f"shell: {SHELL}") + if SHELL: options += ' "{}" "{}"'.format(inf, out) else: @@ -116,6 +123,7 @@ def convert(self, input_file, output_file): ) self._ffmpeg_instances['convert'] = outP self.error = str(outP.stderr.read(), 'utf-8') + self.logger.info(f"error message length: {len(self.error)}") return out def get_ffmpeg_bin(self): @@ -124,6 +132,7 @@ def get_ffmpeg_bin(self): Get the ffmpeg executable file. This is the fullpath to the binary distributed with pyffmpeg. There is only one at a time. """ + self.logger.info("Inside get_ffmpeg_bin") return self._ffmpeg_file @@ -131,6 +140,7 @@ def get_fps(self, input_file): """ Returns the frame per second rate of an input file """ + self.logger.info("Inside get_fps") fprobe = FFprobe(input_file) fps = fprobe.fps return fps @@ -141,6 +151,7 @@ def monitor(self, fn: str): m_thread.start() def _monitor(self, fn: str): + self.logger.info('Monitoring spirit started') sleep(1) dura = 0.0 while dura < self._in_duration: @@ -161,8 +172,10 @@ def options(self, opts): eg.: command line options of 'ffmpeg -i a.mp4 b.mp3' will be passed by user as: opts: '-i a.mp4 b.mp3' """ + self.logger.info("inside options") if isinstance(opts, list): + self.logger.info('Options is a List') options = fix_splashes(opts) # Add ffmpeg and overwrite variable @@ -177,6 +190,7 @@ def options(self, opts): options = ' '.join(['-loglevel', self.loglevel, options]) else: + self.logger.info('Options is a String') options = opts # Add ffmpeg and overwrite variable @@ -200,6 +214,8 @@ def options(self, opts): # add ffmpeg options = " ".join([self._ffmpeg_file, options]) + self.logger.info(f"Shell: {SHELL}") + if not SHELL: options = shlex.split(options, posix=False) @@ -226,8 +242,10 @@ def quit(self, function: Optional[str] = ''): Allows for any running process of ffmpeg started by pyffmpeg to be terminated """ + self.logger.info('Inside Quit') if function: + self.logger.info('There is a function for Quit: {function}') inst = self._ffmpeg_instances[function] output = inst.communicate(b'q') # Quit all instances