Calculate nb_frames for MKV using duration and fps.

This commit is contained in:
Alf
2020-12-18 21:50:44 -08:00
parent 1fa33a5be3
commit 3ed230e822
3 changed files with 7 additions and 8 deletions

View File

@@ -178,15 +178,14 @@ FramesResponse get_frames(int offset) {
if (video_stream_index == -1) {
video_stream_index = i;
nb_frames = pFormatContext->streams[i]->nb_frames;
// Calculate the nb_frames for MKV/WebM if nb_frames is 0.
if (nb_frames == 0) {
nb_frames = (pFormatContext->duration / 1000000) * pFormatContext->streams[i]->avg_frame_rate.num;
}
pCodec = pLocalCodec;
pCodecParameters = pLocalCodecParameters;
}
printf("Video Codec: resolution %d x %d\n",
pLocalCodecParameters->width, pLocalCodecParameters->height);
} else if (pLocalCodecParameters->codec_type == AVMEDIA_TYPE_AUDIO) {
printf("Audio Codec: %d channels, sample rate %d\n",
pLocalCodecParameters->channels, pLocalCodecParameters->sample_rate);
}
}

2
www/package-lock.json generated
View File

@@ -1,6 +1,6 @@
{
"name": "ffprobe-wasm",
"version": "0.2.0",
"version": "0.2.1",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@@ -1,6 +1,6 @@
{
"name": "ffprobe-wasm",
"version": "0.2.0",
"version": "0.2.1",
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",