Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cutting off end of videos #11

Merged
merged 2 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ffmpeg_video_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ void FFmpegVideoStreamPlayback::update_internal(double p_delta) {
// if at the end of the stream but our playback enters a valid time region again, a seek operation is required to get the decoder back on track.
if (playback_position < decoder->get_last_decoded_frame_time()) {
seek_into_sync();
} else {
playing = false;
}
} else if (decoder->get_decoder_state() == VideoDecoder::DecoderState::END_OF_STREAM) {
playing = false;
}

Ref<DecodedFrame> peek_frame = available_frames.size() > 0 ? available_frames[0] : nullptr;
Expand Down
6 changes: 1 addition & 5 deletions video_decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@
int hw_device_create_result = av_hwdevice_ctx_create(&video_codec_context->hw_device_ctx, info.device_type, nullptr, nullptr, 0);
ERR_CONTINUE_MSG(hw_device_create_result < 0, vformat("Couldn't create hardware video decoder context %s for codec %s: %s", av_hwdevice_get_type_name(info.device_type), info.codec->get_codec_ptr()->name, ffmpeg_get_error_message(hw_device_create_result)));

print_line(vformat("Succesfully opened hardware video decoder context %s for codec %s", av_hwdevice_get_type_name(info.device_type), info.codec->get_codec_ptr()->name));

Check failure on line 174 in video_decoder.cpp

View workflow job for this annotation

GitHub Actions / 📊 Static checks / Code style, file formatting, and docs

Succesfully ==> Successfully
} else {
video_codec_context->thread_count = 0;
}
Expand All @@ -179,7 +179,7 @@
int open_codec_result = avcodec_open2(video_codec_context, info.codec->get_codec_ptr(), nullptr);
ERR_CONTINUE_MSG(open_codec_result < 0, vformat("Error trying to open %s codec: %s", info.codec->get_codec_ptr()->name, ffmpeg_get_error_message(open_codec_result)));

print_line("Succesfully initialized decoder:", info.codec->get_codec_ptr()->name);

Check failure on line 182 in video_decoder.cpp

View workflow job for this annotation

GitHub Actions / 📊 Static checks / Code style, file formatting, and docs

Succesfully ==> Successfully
break;
}
if (!audio_stream) {
Expand All @@ -199,7 +199,7 @@
ERR_FAIL_COND_MSG(param_copy_result < 0, vformat("Couldn't copy codec parameters from %s: %s", codec->name, ffmpeg_get_error_message(param_copy_result)));
int open_codec_result = avcodec_open2(audio_codec_context, codec, nullptr);
ERR_FAIL_COND_MSG(open_codec_result < 0, vformat("Error trying to open %s codec: %s", codec->name, ffmpeg_get_error_message(open_codec_result)));
print_line("Succesfully initialized audio decoder:", codec->name);

Check failure on line 202 in video_decoder.cpp

View workflow job for this annotation

GitHub Actions / 📊 Static checks / Code style, file formatting, and docs

Succesfully ==> Successfully
has_audio = true;
}
}
Expand Down Expand Up @@ -459,11 +459,7 @@
}
}
unwrapped_frame.resize(width * height * 4);
if (!image.is_valid()) {
image = Image::create_from_data(width, height, false, Image::FORMAT_RGBA8, unwrapped_frame);
} else {
image->set_data(width, height, false, Image::FORMAT_RGBA8, unwrapped_frame);
}
image = Image::create_from_data(width, height, false, Image::FORMAT_RGBA8, unwrapped_frame);
}
#ifdef FFMPEG_MT_GPU_UPLOAD
Ref<ImageTexture> tex;
Expand Down
Loading