This is really a difficult task, and it is very depressing. It takes about two minutes to solve the problem. Well, I don't know if it is too dish or whether it is too difficult for streaming media, I don't want to do this in the future. If you have encountered a bunch of problems, first record the problems you have encountered. Let's take a step:
1. error LNK2019, there is still a problem. I can find it and I have no clue for a long time. After comparing the files without errors, it seems that an extern "C" is missing. I just need to add this file. Okay, I am here, and the C/C ++ mixed compilation will kill people. But this error must be because your project does not contain the header file, or the function is not defined or has not been imported into the database, finally, try extern.
2. to add your own video capturing class, you must add the library file, common file, sdk_dll file, and av2000SDK. dll cannot be included in the current directory. You must add it to the project.
3. if error C2664: "LoadLibraryW" occurs: you cannot convert parameter 1 from "const char [14]" to "LPCWSTR", that is, the project has opened multiple characters, in project properties/configuration properties/General/project default value/Character Set, modify to not use Unicode.
4. after ffmpeg is compiled, the jpeg file is decoded, And the yuv420 file is generated after ffmpeg-I 1.jpg 1.yuv is converted. However, the flat screen is always opened with vlc. I can't solve the problem and no one can teach me how to solve it, I thought that transcoding was incorrect, and my heart was dead, so it was hard to solve it. After I asked my brother, I said that yuv420 has a fixed storage method and needs to be opened with a specific tool, hope for it. I immediately got a picture and finally took the right step. Well, it's too long. After it turns into 420, we need to decode the jpeg in the memory, then, code it to 264 and use live555 to forward it. No problem occurs in any step, so we will record it today. We will continue to struggle tomorrow and update it in real time. NND.
Today, I am very happy. I have solved all the problems I encountered in the past two days. I have come up with a person looking for information and I admire myself) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/2040543120-0.gif "/>.
Well, it is really difficult to record the process and problems encountered during streaming for nearly half a month. I actually found the relevant group and asked, or else, i'm sure I can't do it anymore. I insist on it. I 'd like to encourage you here.
Now, after decoding the jpg video stream with ffmpeg, it will start to encode it into 264. Here, the 264 encoding needs to compile the libx264 library file, which does not seem to have encountered any difficulties during the compilation process, however, it seems that yuv420 is needed. I heard people say that ffmpeg is decoded to 422, and then I spent another day looking for yuv422 to 420, sws_scale with ffmpeg is used for transcoding, but when my program runs here, it crashes. I am referring to the online example. I can't find a problem, and no one can give me a question or give me some guidance, I want to give up. The last friend in the group asked me if the data source was wrong. You are going to check the description of the data source on the Internet. Later I will see that YUV will use three channels, in this example, I used only one channel, RGB24 and YUV, and then changed it to the following:
/*ctx->pic_src.data[0] = (uint8_t *)pFrame->data[0]; ctx->pic_src.data[1] = (uint8_t *)pFrame->data[1]; ctx->pic_src.data[2] = (uint8_t *)pFrame->data[2]; ctx->pic_src.data[3] = 0; ctx->pic_src.linesize[0] = pFrame->linesize[0]; ctx->pic_src.linesize[1] = pFrame->linesize[1]; ctx->pic_src.linesize[2] = pFrame->linesize[2]; ctx->pic_src.linesize[3] = 0; int rs = sws_scale(ctx->sws, ctx->pic_src.data, ctx->pic_src.linesize,0, ctx->rows, ctx->pic_target.data, ctx->pic_target.linesize);
OK, okay, very excited. Haha, solved one.
Now I can encode the image to 264 with peace of mind, and this problem has always caused me to call the 264 compression function x1__encoder_encode to crash, because it crashes again later, with the lessons learned above, I know that it is definitely a data transfer error. It is certainly that the data is not 420, and then I will return and change the data.
This is all done, but the live555 picture is still black, and then it crashes again after a run. I'm going crazy, no way, I still need to find a mistake, there should be a problem with the 264 encoding format, because the general process is yuv420-> 264, and then live555 sends 264. I can write YUV420 as a file, so the problem lies in encoding 264. I wrote 264 to the file and read it. That's right. I went there. I didn't have to change this time. I should not. As usual, I collapsed and lost my heart, then I looked at the code with no goal and suddenly saw a place where data was released. I just got the data of yuv420 and then called av_free (pFrame ), let's just release it. It seems a little wrong. Then I will comment it out and say, "Oh, my God, the image is coming out, crying, and the psychological taste, I don't want to mention much. The results of the past half a month have finally come out, and finally I can deliver the goods. However, memory leakage occurs, and the speed of 1 Mbit/s starts to increase, but this is nothing, as long as the director can see the results, the following problems can be solved. Haha.
I wrote so much. In summary, too many problems are actually caused by lack of understanding, because there is not so much time to show me. If I don't know much about it, we need to carefully program the program, and then first list the general structure of the whole, and solve any problems we encounter. In this age, basically, you can find answers to any questions online. my overall framework is listed as follows. For details, refer:
Get a frame of data from the IP camera-> Use ffmpeg decoding-> Use ffmpeg conversion format-> Use libx264 to encode the data into a 264 format-> live555 to send the data.
In this way, a real-time camera monitoring is complete, and the rest is the optimization work.
OK, the article is written here. The article is not easy to write and can be written casually. It is mainly because you have to communicate with each other. It's not too early, and there are 650 people coming off work.) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/2040543120-0.gif "/>
This article is from the "West sun" blog, please be sure to keep this source http://thgenius.blog.51cto.com/1042803/1284532