what is the codec for mp4 videos in python OpenCV

前端 未结 5 795
盖世英雄少女心
盖世英雄少女心 2020-12-05 07:44
fourcc = cv2.cv.CV_FOURCC(*\'XVID\')

The above line is used for avi video. In the same fashion, which codec do we use for mp4 videos in Ubuntu?

5条回答
  •  渐次进展
    2020-12-05 08:24

    The codec is H.264.

    One of these should work for you:

    fourcc = cv2.cv.CV_FOURCC(*'H264')
    #or 
    #fourcc = cv2.cv.CV_FOURCC(*'X264')
    

    However, I should warn you that you'll probably need to have ffmpeg and the x264 libraries installed so since you are in Ubuntu, try doing this command in the terminal:

    sudo apt-get install ffmpeg x264 libx264-dev
    

    Also, check out this link from OpenCV tutorials for more details as to the kinds of FourCC codes available for your platform.

    In the above link, it says X264 is the FourCC code you should use, but switch between them until you get it to work.

提交回复
热议问题