mirror of
https://github.com/opencv/opencv.git
synced 2025-06-12 12:22:51 +08:00
VideoCapture: apply bitstream filter to all h264/5 raw streams
This commit is contained in:
parent
e3e1f704a4
commit
871f931e95
@ -1327,6 +1327,10 @@ bool CvCapture_FFMPEG::setRaw()
|
|||||||
return true;
|
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()
|
bool CvCapture_FFMPEG::processRawPacket()
|
||||||
{
|
{
|
||||||
if (packet.data == NULL) // EOF
|
if (packet.data == NULL) // EOF
|
||||||
@ -1350,14 +1354,8 @@ bool CvCapture_FFMPEG::processRawPacket()
|
|||||||
#endif
|
#endif
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// check start code prefixed mode (as defined in the Annex B H.264 / H.265 specification)
|
if(h26xContainer(ic->iformat->long_name))
|
||||||
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)
|
|
||||||
)
|
|
||||||
{
|
|
||||||
filterName = eVideoCodec == CV_CODEC(CODEC_ID_H264) ? "h264_mp4toannexb" : "hevc_mp4toannexb";
|
filterName = eVideoCodec == CV_CODEC(CODEC_ID_H264) ? "h264_mp4toannexb" : "hevc_mp4toannexb";
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (filterName)
|
if (filterName)
|
||||||
{
|
{
|
||||||
|
@ -196,7 +196,7 @@ TEST_P(videoio_container, read)
|
|||||||
file.write(reinterpret_cast<char*>(raw_data.data), size);
|
file.write(reinterpret_cast<char*>(raw_data.data), size);
|
||||||
ASSERT_FALSE(file.fail());
|
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;
|
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", "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", "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/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", "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", "h265.mkv", "mkv.h265", "hevc", "I420"),
|
||||||
//videoio_container_params_t(CAP_FFMPEG, "video/big_buck_bunny", "h264.mp4", "mp4.avc1", "avc1", "I420"),
|
//videoio_container_params_t(CAP_FFMPEG, "video/big_buck_bunny", "h264.mp4", "mp4.avc1", "avc1", "I420"),
|
||||||
|
Loading…
Reference in New Issue
Block a user