Getting an error from pyffmpeg when running as a submodule

34 views Asked by At

I'm working on building an API using pyffmpeg and pytube to download YouTube videos and convert them to .wav files, synced up with some LED animations. I'm importing pyffmpeg in a submodule, which is then imported by yet another submodule. I'm getting the following error when I run the script (both from my entire package, and in the Python shell directly, and on two different devices with two different OSes):

This is the error I get from the shell on my MacBook:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/path/to/venv/lib/python3.11/site-packages/pyffmpeg/__init__.py", line 163, in convert
    raise Exception(self.error)
Exception

And this is the error I get on my Raspberry Pi when I run the full program:

  File "/path/to/venv/lib/python3.11/site-packages/pyffmpeg/__init__.py", line 154, in convert
    if 'Output #0' not in stderr:
                          ^^^^^^
UnboundLocalError: cannot access local variable 'stderr' where it is not associated with a value

I've tracked down the relevant code in the __init__.py file of pyffmpeg, but I'm not sure how to fix the problem.

        if 'Output #0' not in stderr:
            lines = stderr.splitlines()
            if len(lines) > 0:
                self.error = lines[-1]
            else:
                self.error = ""

            if self.enable_log:
                self.logger.error(self.error)
            raise Exception(self.error)
        else:
            self.error = ''
            if self.enable_log:
                self.logger.info('Conversion Done')
        return out

Anyone have any ideas?

0

There are 0 answers