Fix #132216: no video (audio only) animation render produces broken file

Looks like this regressed in c1f5d8d023 (blender 3.1), basically
since then if there was no video, then no audio was ever written
either.

From what I can tell, the original change tried to fix the problem
that "file size autosplit" logic was after video, but before audio
data writing. So it moved audio writing to be before the split (good),
but also (not sure whether by accident) moved audio writing to
only happen if video is written.

Pull Request: https://projects.blender.org/blender/blender/pulls/132874
This commit is contained in:
Aras Pranckevicius
2025-01-10 12:20:32 +01:00
committed by Aras Pranckevicius
parent d27e0fcbaf
commit f355683e4b

View File

@@ -1308,17 +1308,20 @@ static bool ffmpeg_movie_append(MovieWriter *context,
if (context->video_stream) {
avframe = generate_video_frame(context, image);
success = (avframe && write_video_frame(context, avframe, reports));
}
if (context->audio_stream) {
/* Add +1 frame because we want to encode audio up until the next video frame. */
write_audio_frames(
context, (frame - start_frame + 1) / (double(rd->frs_sec) / double(rd->frs_sec_base)));
}
if (context->ffmpeg_autosplit) {
if (avio_tell(context->outfile->pb) > ffmpeg_autosplit_size) {
end_ffmpeg_impl(context, true);
context->ffmpeg_autosplit_count++;
if (context->ffmpeg_autosplit) {
if (avio_tell(context->outfile->pb) > ffmpeg_autosplit_size) {
end_ffmpeg_impl(context, true);
context->ffmpeg_autosplit_count++;
success &= start_ffmpeg_impl(context, rd, image->x, image->y, suffix, reports);
}
success &= start_ffmpeg_impl(context, rd, image->x, image->y, suffix, reports);
}
}