Get video file duration without playing it



  • Hi,

    I have a folder with a few video files (mostly .avi, .mp4). Is there a way to get their duration without playing them? I've tried using QVideoPlayer duartion() method, but it return the correct value only when playing the file. Also, it can only get the duration of one file, while I want to get the duration for multiple values.
    Is there a Qt way of doing it? If no, any other solution you recommend?

    Thanks


  • Lifetime Qt Champion

    Hi,

    The MediaInfo project might of interest here.

    Hope it helps



  • Thanks. Ended up really using mediainfo, got it with the following method

    int getVideoDuration(std::string fileName){
         MediaInfo MI;
        MI.Open(fileName);
        int duration = std::stoi(MI.Get(Stream_General, 0, "Duration"));
        MI.Close();
        return duration;
    }
    

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.