With reference to this my previous question. I debugged the code in two scenarios
When i running while (av_read_frame(ifmt_ctx, av_pkt) >= 0)
loop without containing much code as shown below
while (av_read_frame(ifmt_ctx, av_pkt) >= 0)
{
j++;
if (j >= 600)
{
cout << "Elapsed Time : " << timer->ElapsedTime()<<"\n";
}
av_packet_unref(av_pkt);
}
600 frames at 30fps got finished in 20 seconds as expected [30*20=600].
But when I am adding encoding and decoding codes in this while loop, it starts lagging and finally for 600 frames at 30fps it takes more than 44 seconds to finish.So in another way we can tell that if i finish recording at 20th second it will not get all 600 frames (at 30fps) that is why the recorded video is playing too fast.
If my understanding is correct if I set for 30 fps the while loop should run 30 times in a second but it not. Above 18fps I have this problem. When I tried with FFMPEG.exe it doing the job correctly.So I think it is not due to my processing speed of my cpu.
Any solution for this problem.?