[Libav-user] Wrong frame rate for asf files
Ron Woods
rwoods at vaytek.com
Mon Jan 18 22:22:56 CET 2016
To obtain the fps for a video stream, I've been using the following code:
if (pFormatCtx->streams[videoStream]->avg_frame_rate.num == 0)
*frameRate = (float)av_q2d(pFormatCtx->streams[videoStream]->r_frame_rate);
else
*frameRate = (float)av_q2d(pFormatCtx->streams[videoStream]->avg_frame_rate);
And then while reading the video, to determine the PTS for a frame, the following code:
if (decoder_reorder_pts == -1) {
*pts = av_frame_get_best_effort_timestamp(pFrame);
} else if (decoder_reorder_pts) {
*pts = pFrame->pkt_pts;
} else {
*pts = pFrame->pkt_dts;
}
if (*pts == AV_NOPTS_VALUE) {
*pts = 0;
}
*pts *= av_q2d(pFormatCtx->streams[videoStream]->time_base);
And this has worked fine with every video format that I analyze, except for asf files as recorded by Axis cameras, which have the wrong values for the frame rate, spec.,
pFormatCtx->streams[videoStream]->r_frame_rate = 100
pFormatCtx->streams[videoStream]->avg_frame_rate = 0
pFormatCtx->streams[videoStream]->time_base = 1 / 1000
whereas the file is actually recorded at 30 fps.
ffprobe also reports invalid values:
r_frame_rate=100/1
avg_frame_rate=0/0
time_base=1/1000
The "Windows Media ASF View 9 Series" tool reports the correct information as follows (in Extended Stream Properties):
Avg. Time / Frame 00:00.0333333
Avg. Frames / Second 30.00
VLC Media Player, Windows Media Player and ffplay play these asf files just fine; and yet, using the above code results in incorrect value for the time base used to determine the PTS of each frame. How can I get the correct values from the asf files using ffmpeg funtions?
Ron
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20160118/9e475983/attachment.html>
More information about the Libav-user
mailing list