From 59db44ad6512e5954694b0e713f46505d9ec4d3b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 12 Oct 2023 23:59:25 +1100 Subject: [PATCH] Fix animation player failing to play back JPEG 2000 image sequences --- source/blender/windowmanager/intern/wm_playanim.cc | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/source/blender/windowmanager/intern/wm_playanim.cc b/source/blender/windowmanager/intern/wm_playanim.cc index dcd9434c2ef..5023930a9a5 100644 --- a/source/blender/windowmanager/intern/wm_playanim.cc +++ b/source/blender/windowmanager/intern/wm_playanim.cc @@ -947,15 +947,27 @@ static void build_pict_list(GhostData *ghost_data, * it's important the frame number increases each time. Otherwise playing `*.png` * in a directory will expand into many arguments, each calling this function adding * a frame that's set to zero. */ - const int frame_offset = picsbase.last ? ((PlayAnimPict *)picsbase.last)->frame + 1 : 0; + const PlayAnimPict *picture_last = (PlayAnimPict *)picsbase.last; + const int frame_offset = picture_last ? (picture_last->frame + 1) : 0; + bool do_image_load = false; if (IMB_isanim(filepath_first)) { build_pict_list_from_anim(ghost_data, display_ctx, filepath_first, frame_offset); + if (picsbase.last == picture_last) { + /* FFMPEG detected JPEG200 as a video which would load with zero duration. + * Resolve this by using images as a fallback when a video file has no frames to display. */ + do_image_load = true; + } } else { + do_image_load = true; + } + + if (do_image_load) { build_pict_list_from_image_sequence( ghost_data, display_ctx, filepath_first, frame_offset, totframes, fstep, loading_p); } + *loading_p = false; }