Merge pull request #23541 from cudawarped:fix_3474

pull/23557/head
Alexander Alekhin 2 years ago
commit d4f29a6361
  1. 12
      modules/videoio/src/cap_ffmpeg_impl.hpp
  2. 3
      modules/videoio/test/test_ffmpeg.cpp

@ -1327,6 +1327,10 @@ bool CvCapture_FFMPEG::setRaw()
return true;
}
static inline bool h26xContainer(const char* formatLongName) {
return !strcmp(formatLongName, "QuickTime / MOV") || !strcmp(formatLongName, "FLV (Flash Video)") || !strcmp(formatLongName, "Matroska / WebM");
}
bool CvCapture_FFMPEG::processRawPacket()
{
if (packet.data == NULL) // EOF
@ -1350,14 +1354,8 @@ bool CvCapture_FFMPEG::processRawPacket()
#endif
)
{
// check start code prefixed mode (as defined in the Annex B H.264 / H.265 specification)
if (packet.size >= 5
&& !(packet.data[0] == 0 && packet.data[1] == 0 && packet.data[2] == 0 && packet.data[3] == 1)
&& !(packet.data[0] == 0 && packet.data[1] == 0 && packet.data[2] == 1)
)
{
if(h26xContainer(ic->iformat->long_name))
filterName = eVideoCodec == CV_CODEC(CODEC_ID_H264) ? "h264_mp4toannexb" : "hevc_mp4toannexb";
}
}
if (filterName)
{

@ -196,7 +196,7 @@ TEST_P(videoio_container, read)
file.write(reinterpret_cast<char*>(raw_data.data), size);
ASSERT_FALSE(file.fail());
}
ASSERT_GE(totalBytes, (size_t)65536) << "Encoded stream is too small";
ASSERT_GE(totalBytes, (size_t)39775) << "Encoded stream is too small";
}
std::cout << "Checking extracted video stream: " << fileNameOut << " (size: " << totalBytes << " bytes)" << std::endl;
@ -226,6 +226,7 @@ const videoio_container_params_t videoio_container_params[] =
videoio_container_params_t(CAP_FFMPEG, "video/big_buck_bunny", "h264", "h264", "h264", "I420"),
videoio_container_params_t(CAP_FFMPEG, "video/big_buck_bunny", "h265", "h265", "hevc", "I420"),
videoio_container_params_t(CAP_FFMPEG, "video/big_buck_bunny", "mjpg.avi", "mjpg", "MJPG", "I420"),
videoio_container_params_t(CAP_FFMPEG, "video/sample_322x242_15frames.yuv420p.libx264", "mp4", "h264", "avc1", "I420")
//videoio_container_params_t(CAP_FFMPEG, "video/big_buck_bunny", "h264.mkv", "mkv.h264", "h264", "I420"),
//videoio_container_params_t(CAP_FFMPEG, "video/big_buck_bunny", "h265.mkv", "mkv.h265", "hevc", "I420"),
//videoio_container_params_t(CAP_FFMPEG, "video/big_buck_bunny", "h264.mp4", "mp4.avc1", "avc1", "I420"),

Loading…
Cancel
Save