PR #25709 opened by MattCrossleyTR
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25709
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25709.patch

Currently the `is_live` flag is only set to true if the manifest type is 
dynamic. This PR changes this to set the flag on every manifest parse.

An ongoing MPEG-DASH livestream will have a manifest with `type="dynamic"`, 
which tells the reader that they should keep checking back for updates. Once 
the livestream ends the type will change to "static" indicating no more 
updates. You can see this by running the following command and inspecting 
`live.mpd` as it goes on:
```
ffmpeg -re -f lavfi -i testsrc -t 30 \
  -c:v libx264 -preset veryfast -b:v 800k \
  -c:a aac -b:a 128k \
  -f dash -seg_duration 4 \
  -window_size 5 -extra_window_size 2 \
  -use_template 1 -use_timeline 1 \
  -remove_at_exit 0 \
  live.mpd
```

That change in the type should tell FFMPEG that the stream has ended, but if 
you run this command whilst
the stream is ongoing you'll see it never exits:
```
ffmpeg -i live.mpd -y out.mp4
```

This is due to a bug in how "liveness" is decided. It checks the manifest type 
value on every parse,
but only assigns a value to `is_live` if the type is dynamic. It never unsets 
that flag.

This PR changes that by always setting that flag on every manifest parse. 
Re-running the commands shows FFMPEG exiting properly when the stream finishes.

The FATE test suite passes locally when I run it. Testing this required two 
FFMPEG processes running concurrently so no regression test has been added, as 
I couldn't figure out how to get FATE working with that.


>From de39e8ddf8e11bc1f37ef8f2699ac03407cc7f06 Mon Sep 17 00:00:00 2001
From: Matthew Crossley <[email protected]>
Date: Tue, 3 Nov 2026 12:10:52 +0000
Subject: [PATCH] avformat/dashdec: fix is_live flag not being unset after
 stream ends

An ongoing MPEG-DASH livestream will have a manifest with `type="dynamic"`, 
which tells the reader that they
should keep checking back for updates. Once the livestream ends the type will 
change to "static" indicating no more
updates. You can see this by running the following command and inspecting 
`live.mpd` as it goes on:
```
ffmpeg -re -f lavfi -i testsrc -t 30 \
  -c:v libx264 -preset veryfast -b:v 800k \
  -c:a aac -b:a 128k \
  -f dash -seg_duration 4 \
  -window_size 5 -extra_window_size 2 \
  -use_template 1 -use_timeline 1 \
  -remove_at_exit 0 \
  live.mpd
```

That change in the type should tell FFMPEG that the stream has ended, but if 
you run this command whilst
the stream is ongoing you'll see it never exits:
```
ffmpeg -i live.mpd -y out.mp4
```

This is due to a bug in how "liveness" is decided. It checks the manifest type 
value on every parse,
but only assigns a value to `is_live` if the type is dynamic. It never unsets 
that flag.

This commit changes that by always setting that flag on every manifest parse. 
Re-running the commands shows
FFMPEG exiting properly when the stream finishes.
---
 libavformat/dashdec.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
index 00f91fc205a..3d36344e140 100644
--- a/libavformat/dashdec.c
+++ b/libavformat/dashdec.c
@@ -1355,8 +1355,7 @@ static int parse_manifest(AVFormatContext *s, const char 
*url, AVIOContext *in)
             ret = AVERROR_INVALIDDATA;
             goto cleanup;
         }
-        if (!av_strcasecmp(val, "dynamic"))
-            c->is_live = 1;
+        c->is_live = !av_strcasecmp(val, "dynamic");
         xmlFree(val);
 
         attr = node->properties;
-- 
2.54.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to