diff --git a/src/project.cpp b/src/project.cpp index e6dfed50d..8f48bf8cb 100644 --- a/src/project.cpp +++ b/src/project.cpp @@ -300,6 +300,13 @@ void Project::LoadVideo(agi::fs::path const& path) { if (!DoLoadVideo(path)) return; if (OPT_GET("Video/Open Audio")->GetBool() && audio_file != video_file && video_provider->HasAudio()) DoLoadAudio(video_file, true); + + double dar = video_provider->GetDAR(); + if (dar > 0) + context->videoController->SetAspectRatio(dar); + else + context->videoController->SetAspectRatio(AspectRatio::Default); + context->videoController->JumpToFrame(0); } void Project::CloseVideo() { @@ -307,6 +314,9 @@ void Project::CloseVideo() { video_provider.reset(); SetPath(video_file, "?video", "", ""); video_has_subtitles = false; + context->ass->Properties.ar_mode = 0; + context->ass->Properties.ar_value = 0.0; + context->ass->Properties.video_position = 0; } void Project::DoLoadTimecodes(agi::fs::path const& path) { diff --git a/src/video_controller.cpp b/src/video_controller.cpp index 0e13a9173..2db556697 100644 --- a/src/video_controller.cpp +++ b/src/video_controller.cpp @@ -60,23 +60,8 @@ VideoController::VideoController(agi::Context *c) void VideoController::OnNewVideoProvider(AsyncVideoProvider *new_provider) { Stop(); - frame_n = 0; - provider = new_provider; - if (!provider) { - color_matrix.clear(); - context->ass->Properties.ar_mode = 0; - context->ass->Properties.ar_value = 0.0; - context->ass->Properties.video_position = 0; - return; - } - - color_matrix = provider->GetColorSpace(); - double dar = provider->GetDAR(); - if (dar > 0) - SetAspectRatio(dar); - - JumpToFrame(0); + color_matrix = provider ? provider->GetColorSpace() : ""; } void VideoController::OnSubtitlesCommit(int type, std::set const& changed) {