forked from forks/ffprobe-wasm
add FPS information (#12)
This commit is contained in:
@@ -68,6 +68,7 @@ typedef struct FramesResponse {
|
|||||||
int gop_size;
|
int gop_size;
|
||||||
int duration;
|
int duration;
|
||||||
double time_base;
|
double time_base;
|
||||||
|
double avg_frame_rate;
|
||||||
} FramesResponse;
|
} FramesResponse;
|
||||||
|
|
||||||
FileInfoResponse get_file_info(std::string filename) {
|
FileInfoResponse get_file_info(std::string filename) {
|
||||||
@@ -195,11 +196,13 @@ FramesResponse get_frames(std::string filename, int timestamp) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
AVRational stream_time_base = pFormatContext->streams[video_stream_index]->time_base;
|
AVRational stream_time_base = pFormatContext->streams[video_stream_index]->time_base;
|
||||||
|
AVRational avg_frame_rate = pFormatContext->streams[video_stream_index]->avg_frame_rate;
|
||||||
// printf("stream_time_base: %d / %d = %.5f\n", stream_time_base.num, stream_time_base.den, av_q2d(stream_time_base));
|
// printf("stream_time_base: %d / %d = %.5f\n", stream_time_base.num, stream_time_base.den, av_q2d(stream_time_base));
|
||||||
|
|
||||||
FramesResponse r;
|
FramesResponse r;
|
||||||
r.nb_frames = nb_frames;
|
r.nb_frames = nb_frames;
|
||||||
r.time_base = av_q2d(stream_time_base);
|
r.time_base = av_q2d(stream_time_base);
|
||||||
|
r.avg_frame_rate = av_q2d(avg_frame_rate);
|
||||||
r.duration = pFormatContext->streams[video_stream_index]->duration;
|
r.duration = pFormatContext->streams[video_stream_index]->duration;
|
||||||
|
|
||||||
// If the duration value isn't in the stream, get from the FormatContext.
|
// If the duration value isn't in the stream, get from the FormatContext.
|
||||||
@@ -316,6 +319,7 @@ EMSCRIPTEN_BINDINGS(structs) {
|
|||||||
.field("gop_size", &FramesResponse::gop_size)
|
.field("gop_size", &FramesResponse::gop_size)
|
||||||
.field("duration", &FramesResponse::duration)
|
.field("duration", &FramesResponse::duration)
|
||||||
.field("time_base", &FramesResponse::time_base)
|
.field("time_base", &FramesResponse::time_base)
|
||||||
|
.field("avg_frame_rate", &FramesResponse::avg_frame_rate)
|
||||||
;
|
;
|
||||||
function("get_frames", &get_frames);
|
function("get_frames", &get_frames);
|
||||||
}
|
}
|
||||||
@@ -54,6 +54,7 @@ export default {
|
|||||||
{ name: 'Duration', value: this.data.duration },
|
{ name: 'Duration', value: this.data.duration },
|
||||||
{ name: 'Timebase', value: this.data.time_base },
|
{ name: 'Timebase', value: this.data.time_base },
|
||||||
{ name: 'Total Frames', value: this.data.nb_frames },
|
{ name: 'Total Frames', value: this.data.nb_frames },
|
||||||
|
{ name: 'FPS', value: this.data.avg_frame_rate },
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user