Writing x264 from OpenCV 3 with FFmpeg on Linux

前端 未结 3 654
南方客
南方客 2020-12-05 14:56

I\'m having trouble writing h264 video with OpenCV 3 via FFmpeg (\"\'X\',\'2\',\'6\',\'4\'\" FOURCC). I\'ve seen all the related posts so far on SO, but nothing helps. Code:

3条回答
  •  死守一世寂寞
    2020-12-05 15:47

    The problem on OpenCV which message is:

    OpenCV: FFMPEG: tag 0x34363248/'H264' is not supported with codec id 28 and format 'mp4 / MP4 (MPEG-4 Part 14)' OpenCV: FFMPEG: fallback to use tag 0x00000021/'!???'

    It is produced by definitions of CV_FOURCC('H','2','6','4') this value do not corresponds with the value defined on isom.c

    { AV_CODEC_ID_H264 , 0x21 }

    Then defining fourcc as 0x21 cv::VideoWriter works smooth,

    cv::VideoWriter VF;
    VF.open(filename,0x21,fps,frameSize,true);
    

    as Jameson comments above,

    "I decided to use 0x21 directly into VideoWriter.open(). That generates a valid and interpretable video file."

提交回复
热议问题