From 15d920573dcf7e70e6db780d4a3cd65c8713d957 Mon Sep 17 00:00:00 2001 From: Erich Seifert Date: Sat, 24 Oct 2026 21:12:30 +0200 Subject: [PATCH] Set the avformat consumer running before starting its thread The encoding thread loops while the running property is set, but the property was only set after creating the thread. If the thread got to its loop first, it skipped encoding and marked the consumer stopped, and the start function then set running again, so the consumer looked like it was running forever. A thread failing early had the same effect. Set the property before creating the thread. --- src/modules/avformat/consumer_avformat.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/modules/avformat/consumer_avformat.c b/src/modules/avformat/consumer_avformat.c index 030b0b798..5122769c2 100644 --- a/src/modules/avformat/consumer_avformat.c +++ b/src/modules/avformat/consumer_avformat.c @@ -576,11 +576,11 @@ static int consumer_start(mlt_consumer consumer) // Assign the thread to properties mlt_properties_set_data(properties, "thread", thread, sizeof(pthread_t), free, NULL); + // Set the running state before the thread checks it + mlt_properties_set_int(properties, "running", 1); + // Create the thread pthread_create(thread, NULL, consumer_thread, consumer); - - // Set the running state - mlt_properties_set_int(properties, "running", 1); } return error; }