valkjsaaa / ffmpeg-smart-trim

Smart trim with FFMPEG
GNU General Public License v3.0
13 stars 2 forks source link

KeyError: 'pts_time' #4

Open jdchristensen opened 1 year ago

jdchristensen commented 1 year ago

I tried this program for the first time and got:

$ python3 -m ffmpeg_smart_trim.trim test.mp4 --start_time 12.345 --end_time 300.0 --output out.mp4
Parsing video file...
Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/usr/local/lib/python3.10/dist-packages/ffmpeg_smart_trim/trim.py", line 127, in <module>
    video = TrimVideo(args.video, time_range=(input_start_time, input_end_time))
  File "/usr/local/lib/python3.10/dist-packages/ffmpeg_smart_trim/trim.py", line 14, in __init__
    self.key_frame_timestamps = [Decimal(frame['pts_time']) for frame in probe['frames']]
  File "/usr/local/lib/python3.10/dist-packages/ffmpeg_smart_trim/trim.py", line 14, in <listcomp>
    self.key_frame_timestamps = [Decimal(frame['pts_time']) for frame in probe['frames']]
KeyError: 'pts_time'

The test video is 90 minutes long, from a Zoom recording.

sugizo commented 3 months ago

execute

pip install -U ffmpeg-smart-trim
!wget -c http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerBlazes.mp4
!python -m ffmpeg_smart_trim.trim ForBiggerBlazes.mp4 --start_time 0.345 --end_time 9.890 --output out.mp4

result

Parsing video file...
Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/usr/local/lib/python3.10/dist-packages/ffmpeg_smart_trim/trim.py", line 127, in <module>
    video = TrimVideo(args.video, time_range=(input_start_time, input_end_time))
  File "/usr/local/lib/python3.10/dist-packages/ffmpeg_smart_trim/trim.py", line 14, in __init__
    self.key_frame_timestamps = [Decimal(frame['pts_time']) for frame in probe['frames']]
  File "/usr/local/lib/python3.10/dist-packages/ffmpeg_smart_trim/trim.py", line 14, in <listcomp>
    self.key_frame_timestamps = [Decimal(frame['pts_time']) for frame in probe['frames']]
KeyError: 'pts_time'

p.s. same video can be trim using ffmpeg from shell and another python module, e.g. ffmpeg-python

best regards