mpeg-2 library to extract video duration

前端 未结 2 987
无人共我
无人共我 2020-12-07 06:16

I have recently ventured out into dealing with audio and video related coding and i have limited knowledge about neither one of them.

It happens that i have a projec

2条回答
  •  死守一世寂寞
    2020-12-07 06:27

    another option besides opencv or ffmpeg is maybe gstreamer:

    import gst
    from gst.pbutils import Discoverer
    
    d = Discoverer(5000000000)
    vid_info = d.discover_uri("file://") # needs to be a full path
    duration = vid_info.get_duration()
    
    # convert to seconds
    duration / gst.SECOND
    

    However, this solution crashs randomly (every 100 file or so) with the current gstreamer version (on Ubuntu 12.04). And maybe you need some gstreamer plugin for working with mpg-2; I currently don't know which ones.

    I am also working on a more or less large media project, which should be able to handle a large range of codecs and containers and every library we are using is more or less a mess (wrong values or instable). Maybe there is so some specialized mpg library out there.

    Oh and VLC is using ffmpeg; so if you are not allowed to use ffmpeg you maybe are also not allowed to use VLC too.

提交回复
热议问题