Thanks to Dr. Rai for the Chinese video codec in the pay, http://blog.csdn.net/leixiaohua1020
Recently to do some video streaming things, to parse H264 bare stream and get OPENCV format of mat data to the algorithm engineers to run algorithms. Related resources have been difficult to find, often too old to make the API version of the replacement, no way to let new people or laymen [such as me] Quick validation of the code is feasible. In the reference to multiple blogs, the predecessors of the Code of the patchwork is finally written out this H264 decoder. Be a little bit of my humble ability to give back to this community.
Project Address:
Https://github.com/hirorogithub/ffmpeg_sample-H264_to_cv-Mat
Environmental dependency:
FFmpeg 3.3
opencv3.20 (in fact, 2.4 should be no problem)
Brief introduction of the file:
-H264Decoder.h H264Decoder.cpp: Decoder ontology, input H264 frame, (starting with 0001), Output Cv::mat (if you encounter a Sps,pps decoding failure, of course, the first encounter FFmpeg will record the SPS, PPS information is used for back decoding)
-H264decoder_jni.cpp h264decoder.java jni file and corresponding Java class note I pieced together the long information of the picture in the array returned in the JNI layer (2*sizeof (int)), So this array needs to be parsed accordingly. Because this side of the demand is the Java responsible for forwarding data, the actual running CV algorithm or in C + +, so there is such an operation, do not need to dispose of their own
Some pits:
FFmpeg oneself have a time.h, compile time to add the header file depends on what, very easy to make an error can not find time related basic types, solution Baidu has.
Some improvements:
I will consider making a sample of H264 bare stream and writing a simple call example for reference.
Time 2017-07-18: Have upload sample call and test data frame, remember correctly No. 0 is H264 the naked stream of the consolidated file, a file with many frames. The file after 1th is divided into 0001 H264 single frame files, frame files are packaged git