home-assistant-libs / ha-ffmpeg

A python library that handling with ffmpeg for home-assistant
BSD 3-Clause "New" or "Revised" License
16 stars 13 forks source link

Exception in HASS 0.56.1 #20

Closed bachya closed 5 years ago

bachya commented 6 years ago

In the latest release of HASS, I'm getting this unhandled exception:

2017-10-22 15:00:17 ERROR (MainThread) [haffmpeg.core] FFmpeg fails program arguments must be a bytes or text string, not bool
Traceback (most recent call last):
  File "/config/deps/lib/python3.6/site-packages/haffmpeg/core.py", line 114, in open
    stderr=stderr
  File "/usr/lib/python3.6/asyncio/subprocess.py", line 225, in create_subprocess_exec
    stderr=stderr, **kwds)
  File "/usr/lib/python3.6/asyncio/base_events.py", line 1181, in subprocess_exec
    % type(arg).__name__)
TypeError: program arguments must be a bytes or text string, not bool

I'm using Arlo Cameras and a Yi Camera. Let me know if you have any questions.

pvizeli commented 6 years ago

I think your command argument will parse as bool and not as string. That was also your problem before...

bachya commented 6 years ago

This is a boolean?

ffmpeg_arguments: '-vf scale=800:450'
pvizeli commented 6 years ago

Maybe a trouble inside component? I can only say that I become a boolean instead a string to ffmpeg-ha library

pvizeli commented 6 years ago

Maybe I can help me to find the problem?

bachya commented 6 years ago

Happy to help in any way I can! As I mentioned in my previous bug, I'm dealing with raw MP4s, so if sending you one of those would help, I can certainly do that.

arsaboo commented 6 years ago

I am also seeing these errors:

FFmpeg fails program arguments must be a bytes or text string, not bool
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.6/site-packages/haffmpeg/core.py", line 114, in open
    stderr=stderr
  File "/usr/lib/python3.6/asyncio/subprocess.py", line 225, in create_subprocess_exec
    stderr=stderr, **kwds)
  File "/usr/lib/python3.6/asyncio/base_events.py", line 1182, in subprocess_exec
    % type(arg).__name__)
TypeError: program arguments must be a bytes or text string, not bool

My entire config is here. I am using Hikvision and Bloomsky cameras. I don't have any arguments specified for ffmpeg. Let me know if I can provide any more details.

etsinko commented 6 years ago

I'm having the same problem with Ring Doorbell camera:

2017-11-19 10:34:06 ERROR (MainThread) [haffmpeg.core] FFmpeg fails program arguments must be a bytes or text string, not bool
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.5/site-packages/haffmpeg/core.py", line 114, in open
    stderr=stderr
  File "/usr/lib/python3.5/asyncio/subprocess.py", line 212, in create_subprocess_exec
    stderr=stderr, **kwds)
  File "/usr/lib/python3.5/asyncio/base_events.py", line 1070, in subprocess_exec
    % type(arg).__name__)
TypeError: program arguments must be a bytes or text string, not bool
2017-11-19 10:34:06 WARNING (MainThread) [haffmpeg.tools] Error starting FFmpeg.
etsinko commented 6 years ago

Ok, I've figured out what was going on in my case. Here it is: ring camera component for HA was passing False as input_source to open() function:

    def open(self, cmd, input_source, output="-", extra_cmd=None,
             stdout_pipe=True, stderr_pipe=False):
        """Start a ffmpeg instance and pipe output."""
        stdout = asyncio.subprocess.PIPE if stdout_pipe\
            else asyncio.subprocess.DEVNULL
        stderr = asyncio.subprocess.PIPE if stderr_pipe\
            else asyncio.subprocess.DEVNULL

        if self.is_running:
            _LOGGER.warning("FFmpeg is allready running!")
            return

        # set command line
        self._generate_ffmpeg_cmd(cmd, input_source, output, extra_cmd)
....

Hence self._generate_ffmpeg_cmd() generated a parameter list with False in it. Here is my list for example:

['ffmpeg', '-i', False, '-an', '-frames:v', '1', '-c:v', 'mjpeg', '-f', 'image2pipe', '-']

And this caused the problem in asyncio.create_subprocess_exec as seen in the stacktrace earlier.

@pvizeli do you think it will be better to check for valid parameters and maybe throw more meaningful exception? I'm pretty sure others here have similar issues: the modules they use pass invalid parameter for input_source