mercredi 29 juin 2016

ffmpeg c/c++ get frame count or timestamp and fps


I am using ffmpeg to decode a video file in C. I am struggling to get either the count of the current frame I am decoding or the timestamp of the frame. I have read numerous posts that show how to calculate an estimated frame no based on the fps and frame timestamp, however I am not able to get either of those. What I need: fps of video file, timestamp of current frame or frame no(not calculated) What I have: I am able to get the time of the video using pFormatCtx->duration/AV_TIME_BASE I am counting the frames currently as I process them, and getting a current frame count, this is not going to work longterm though. I can get the total frame count for the file using pFormatCtx->streams[currentStream->videoStream]->nb_frames I have read this may not work for all streams, although it has worked for every stream I have tried. I have tried using the time_base.num and time_base.den values and packet.pts, but I can't make any sense of the values that I am getting from those, so I may just need to understand better what those values are. Does anyone know of resources that show examples on how to get this values?

Aucun commentaire:

Enregistrer un commentaire