deuteronomy-works / pyffmpeg

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

FFprobe tags KeyError #658

Open tunaflsh opened 1 year ago

tunaflsh commented 1 year ago

When trying to get metadata from a this specific video, KeyError occures:

2023-05-17 04:57:10,758 - pyffmpeg.pseudo_ffprobe.FFprobe - INFO - FFprobe initialised
2023-05-17 04:57:10,759 - pyffmpeg.misc.Paths - INFO - bin folder: C:\Users\bum\.pyffmpeg\bin
2023-05-17 04:57:10,759 - pyffmpeg.misc.Paths - INFO - Inside load_ffmpeg_bin
2023-05-17 04:57:10,759 - pyffmpeg.pseudo_ffprobe.FFprobe - INFO - ffmpeg bin: C:\Users\bum\.pyffmpeg\bin\ffmpeg.exe
2023-05-17 04:57:10,759 - pyffmpeg.pseudo_ffprobe.FFprobe - INFO - Inside probe
2023-05-17 04:57:10,760 - pyffmpeg.pseudo_ffprobe.FFprobe - INFO - Probing file: "video.mp4"
2023-05-17 04:57:10,760 - pyffmpeg.pseudo_ffprobe.FFprobe - INFO - Issuing commads ['C:\\Users\\bum\\.pyffmpeg\\bin\\ffmpeg.exe', '-y', '-i', 'video.mp4', '-f', 'null', 'nul']
2023-05-17 04:57:10,835 - pyffmpeg.pseudo_ffprobe.FFprobe - INFO - Inside _extract_all
2023-05-17 04:57:10,835 - pyffmpeg.pseudo_ffprobe.FFprobe - INFO - Inside _parse_input_meta
2023-05-17 04:57:10,835 - pyffmpeg.pseudo_ffprobe.FFprobe - INFO - Inside _strip_input_meta
2023-05-17 04:57:10,835 - pyffmpeg.pseudo_ffprobe.FFprobe - INFO - Inside _parse_meta
2023-05-17 04:57:10,835 - pyffmpeg.pseudo_ffprobe.FFprobe - INFO - Inside _strip_meta
2023-05-17 04:57:10,836 - pyffmpeg.pseudo_ffprobe.FFprobe - INFO - Inside _parse_header
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
Cell In[2], line 1
----> 1 FFprobe('video.mp4')

File C:\Program Files\Python311\Lib\site-packages\pyffmpeg\pseudo_ffprobe.py:63, in FFprobe.__init__(self, file_name)
     60 self.error = ''
     62 # START
---> 63 self.probe()

File C:\Program Files\Python311\Lib\site-packages\pyffmpeg\pseudo_ffprobe.py:289, in FFprobe.probe(self)
    286 sleep(0.02)
    287 stdout, _ = subP.communicate(input='q')
--> 289 self._extract_all(stdout)
    291 # Expose publicly know var
    292 self._expose()

File C:\Program Files\Python311\Lib\site-packages\pyffmpeg\pseudo_ffprobe.py:129, in FFprobe._extract_all(self, stdout)
    127     else:
    128         if streams[x]:
--> 129             self.metadata[0].append(self._parse_meta(streams[x]))
    131 # parse other metadata
    132 self._parse_other_meta()

File C:\Program Files\Python311\Lib\site-packages\pyffmpeg\pseudo_ffprobe.py:180, in FFprobe._parse_meta(self, stream)
    178 # this might be a continuation
    179 if key == '':
--> 180     tags[prev_key] += "\\r\\n" + data[1].strip()
    181 else:
    182     tags[key] = value

KeyError: ''

To Reproduce:

  1. Have yt-dlp installed then run the following.
    yt-dlp --merge-output-format mp4 --embed-subs --embed-thumbnail --embed-metadata -o video.mp4 \
    https://www.youtube.com/shorts/mBROMPJHsFc
  2. Execute the following commands in a script, Python interpreter or IPython.
    from pyffmpeg import FFprobe
    FFprobe('video.mp4')