splitmuxsrc: Use natural ordering to find files

Today when using the `splitmuxsrc` on a collection of files named as:

```
item0.mkv
item1.mkv
item2.mkv
[...]
item10.mkv
item11.mkv
[...]
```

You will get a continuous stream made in the order of:

```
item0.mkv -> item1.mkv -> item10.mkv -> item11.mkv -> [...]
```

You can fix this by having smarter names of the items:

```
item000.mkv
item001.mkv
item002.mkv
[...]
item010.mkv
item011.mkv
[...]
```

Will get you:
```
item000.mkv -> item001.mkv -> item003.mkv -> item004.mkv -> [...]
```

But, we could also "fix" the former case by using natural ordering when
comparing the files in gstsplitutils.c.

Fixes #2523

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4491>
This commit is contained in:
Jonas K Danielsson 2024-01-17 15:59:15 +01:00 committed by GStreamer Marge Bot
parent 0cd3a98c78
commit b0becfa46b
2 changed files with 18 additions and 1 deletions

View file

@ -54381,6 +54381,23 @@ the result.</doc>
</parameter>
</parameters>
</function>
<function name="util_filename_compare" c:identifier="gst_util_filename_compare" version="1.24">
<doc xml:space="preserve" filename="../subprojects/gstreamer/gst/gstutils.c">Compares the given filenames using natural ordering.</doc>
<source-position filename="../subprojects/gstreamer/gst/gstutils.h"/>
<return-value transfer-ownership="none">
<type name="gint" c:type="gint"/>
</return-value>
<parameters>
<parameter name="a" transfer-ownership="none">
<doc xml:space="preserve" filename="../subprojects/gstreamer/gst/gstutils.c">a filename to compare with @b</doc>
<type name="utf8" c:type="const gchar*"/>
</parameter>
<parameter name="b" transfer-ownership="none">
<doc xml:space="preserve" filename="../subprojects/gstreamer/gst/gstutils.c">a filename to compare with @a</doc>
<type name="utf8" c:type="const gchar*"/>
</parameter>
</parameters>
</function>
<function name="util_fraction_add" c:identifier="gst_util_fraction_add">
<doc xml:space="preserve" filename="../subprojects/gstreamer/gst/gstutils.c">Adds the fractions @a_n/@a_d and @b_n/@b_d and stores
the result in @res_n and @res_d.</doc>

View file

@ -30,7 +30,7 @@
static int
gst_split_util_array_sortfunc (gchar ** a, gchar ** b)
{
return strcmp (*a, *b);
return gst_util_filename_compare (*a, *b);
}
gchar **