deuteronomy-works / pyffmpeg

FFmpeg wrapper for python
Apache License 2.0
61 stars 11 forks source link

FFprobe not working at all #667

Open fluffy-critter opened 10 months ago

fluffy-critter commented 10 months ago

It looks like the FFprobe mechanism is currently broken.

>>> FFprobe('tests/album/test track.wav')
2023-10-28 00:15:01,565 - pyffmpeg.pseudo_ffprobe.FFprobe - INFO - FFprobe initialised
2023-10-28 00:15:01,567 - pyffmpeg.misc.Paths - INFO - bin folder: /Users/fluffy/.pyffmpeg/bin
2023-10-28 00:15:01,567 - pyffmpeg.misc.Paths - INFO - Inside load_ffmpeg_bin
2023-10-28 00:15:01,567 - pyffmpeg.pseudo_ffprobe.FFprobe - INFO - ffmpeg bin: /Users/fluffy/.pyffmpeg/bin/ffmpeg
2023-10-28 00:15:01,567 - pyffmpeg.pseudo_ffprobe.FFprobe - INFO - Inside probe
2023-10-28 00:15:01,567 - pyffmpeg.pseudo_ffprobe.FFprobe - INFO - Probing file: "tests/album/test track.wav"
2023-10-28 00:15:01,567 - pyffmpeg.pseudo_ffprobe.FFprobe - INFO - Issuing commads ['/Users/fluffy/.pyffmpeg/bin/ffmpeg', '-y', '-i', 'tests/album/test track.wav', '-f', 'null', '/dev/null']
2023-10-28 00:15:02,076 - pyffmpeg.pseudo_ffprobe.FFprobe - INFO - Inside _extract_all
2023-10-28 00:15:02,076 - pyffmpeg.pseudo_ffprobe.FFprobe - ERROR - Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

Use -h to get full help or, even better, run 'man ffmpeg'

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/fluffy/Library/Caches/pypoetry/virtualenvs/bandcrash-nnauGvj1-py3.11/lib/python3.11/site-packages/pyffmpeg/pseudo_ffprobe.py", line 63, in __init__
    self.probe()
  File "/Users/fluffy/Library/Caches/pypoetry/virtualenvs/bandcrash-nnauGvj1-py3.11/lib/python3.11/site-packages/pyffmpeg/pseudo_ffprobe.py", line 289, in probe
    self._extract_all(stdout)
  File "/Users/fluffy/Library/Caches/pypoetry/virtualenvs/bandcrash-nnauGvj1-py3.11/lib/python3.11/site-packages/pyffmpeg/pseudo_ffprobe.py", line 112, in _extract_all
    raise Exception(self.error)
Exception: Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

Use -h to get full help or, even better, run 'man ffmpeg'

>>> 

The installed version of ffmpeg:

$ ~/.pyffmpeg/bin/ffmpeg --help
ffmpeg version N-108453-gb0c7352cd4-tessus Copyright (c) 2000-2022 the FFmpeg developers
  built with Apple clang version 11.0.0 (clang-1100.0.33.17)
  configuration: --cc=/usr/bin/clang --prefix=/opt/ffmpeg --extra-version=tessus --enable-avisynth --enable-fontconfig --enable-gpl --enable-libaom --enable-libass --enable-libbluray --enable-libdav1d --enable-libfreetype --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libmysofa --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvmaf --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-version3 --pkg-config-flags=--static --disable-ffplay
alinsavix commented 7 months ago

What's really strange about this (and I'm experiencing the same) is that if I take the command it says is being executed (in the debug output, and run it directly myself, it works fine!

fluffy-critter commented 7 months ago

Hm, might be something to do with TTY output on the ffmpeg binary? ffmpeg does some really weird stuff with terminal detection.

dust333 commented 6 months ago

in class FFProbe in method probe replace

commands = [
            self._ffmpeg, '-y', '-i',
            self.file_name, '-f',
            'null', os.devnull]

with commands = f"{self._ffmpeg} -y -i {self.file_name} -f null {os.devnull}"

as temporary solution

amoh-godwin commented 5 months ago

I have made a new release. I suspect that could be it. If it doesn't work I will try and fix it.

solovieff commented 1 month ago

@dust333 solution still seems to be the only way at the moment.

solovieff commented 1 month ago
class FFprobeFixed(FFprobe):
    def probe(self):
        self.logger.info('Inside probe')
        self.logger.info(f'Probing file: "{self.file_name}"')

        # randomize the filename to avoid overwrite prompt

        commands = f"{self._ffmpeg} -y -i {self.file_name} -f null {os.devnull}"

        self.logger.info(f"Issuing commads {str(commands)}")

        # start subprocess
        subP = subprocess.Popen(
            commands,
            stdin=subprocess.PIPE,
            stdout=subprocess.PIPE,
            stderr=subprocess.STDOUT,
            text=True,
            shell=SHELL)

        # break the operation
        sleep(0.5)
        stdout, _ = subP.communicate(input='q')

        self._extract_all(stdout)

        # Expose publicly know var
        self._expose()