问题描述:

I have a large set of pre-generated thumbnails and videos. What is the easiest way to figure out the specific time in the video of the associated thumbnail?

I'd imagine that I would have to use something to loop through all the frames in a video to find a match. What libraries should I use? Something like OpenCV maybe? ffmpeg?

Python is preferred but not required.

网友答案:

Yes, OpenCV can do the trick. E.g.(C++):

    Mat thumbnail=imread("./mythumb.jpg");
    VideoCapture capture("./myvideo.avi");
    Mat frame;
    double max_score=0;
    int best_matching_frame=-1;
    int framenum=0;
    while (true){
        if (!capture.read(frame)) break;
        double score=comparefunction(thumbnail,frame);
        if (score>max_score) {
          best_matching_frame=framenum;
          max_score=score;
        }
        framenum++;
    }

You'll have to find an implementation for the comparefunction(). Search stackoverflow how to compare images.

相关阅读:
Top