jonghwanhyeon / python-ffmpeg

A python binding for FFmpeg which provides sync and async APIs
MIT License
302 stars 53 forks source link

Getting video/audio stream info #32

Closed JohnnyRacer closed 1 year ago

JohnnyRacer commented 1 year ago

Hello, I would like the extract the data from a file's video/audio stream like with ffmpeg -i test_vid.mp4 and have the info return as a dict. Is there way I can do this to get the info like what is shown below?

ffmpeg -i test_vid.webm

Input #0, matroska,webm, from 'test_vid.webm':
  Metadata:
    ENCODER         : Lavf58.29.100
  Duration: 00:04:52.58, start: -0.007000, bitrate: 2662 kb/s
    Stream #0:0(eng): Video: vp9 (Profile 0), yuv420p(tv, bt709), 1920x1080, SAR 1:1 DAR 16:9, 23.98 fps, 23.98 tbr, 1k tbn, 1k tbc (default)
    Metadata:
      DURATION        : 00:04:52.541000000
    Stream #0:1(eng): Audio: opus, 48000 Hz, stereo, fltp (default)
    Metadata:
      DURATION        : 00:04:52.581000000
At least one output file must be specified
jonghwanhyeon commented 1 year ago

Please refer to https://python-ffmpeg.readthedocs.io/en/latest/examples/querying-metadata/