Hi,
I have a file which I can't down-mix to stereo due to
AV_CHANNEL_ORDER_NATIVE requirement in sane_layout.
```
$ ffmpeg -i COMMUNITY_HERO_2.mov -vn -af
'aformat=sample_rates=48000:channel_layouts=stereo' -y /tmp/out.wav
ffmpeg version N-118381-g4ba9ae7742 Copyright (c) 2000-2025 the FFmpeg
developers
built with gcc 7 (SUSE Linux)
configuration: --prefix=/Developer/x86_64 --prefix=/Developer/x86_64
--enable-runtime-cpudetect --enable-libzimg --enable-libx264
--enable-libass --enable-libmodplug --enable-libxml2 --enable-libvmaf
--enable-shared --enable-pthreads --enable-gpl --enable-version3
--enable-gnutls --enable-libfreetype --enable-pic --disable-static
--enable-shared --enable-rpath --enable-ffnvcodec --enable-debug
--disable-stripping --disable-optimizations --disable-mmx
libavutil 59. 56.100 / 59. 56.100
libavcodec 61. 31.101 / 61. 31.101
libavformat 61. 9.106 / 61. 9.106
libavdevice 61. 4.100 / 61. 4.100
libavfilter 10. 9.100 / 10. 9.100
libswscale 8. 13.100 / 8. 13.100
libswresample 5. 4.100 / 5. 4.100
libpostproc 58. 4.100 / 58. 4.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'COMMUNITY_HERO_2.mov':
Metadata:
major_brand : qt
minor_version : 512
compatible_brands: qt
encoder : Lavf58.29.100
Duration: 00:02:02.86, start: 0.000000, bitrate: 97805 kb/s
Stream #0:0[0x1]: Video: prores (LT) (apcs / 0x73637061), yuv422p10le(top
first), 1920x1080, 88583 kb/s, SAR 1:1 DAR 16:9, 29.97 fps, 29.97 tbr, 30k
tbn (default)
Metadata:
handler_name : VideoHandler
vendor_id : FFMP
encoder : Lavc58.54.100 prores
timecode : 14:25:46;28
Stream #0:1[0x2]: Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, 8
channels (FL+FR+FC+LFE+SL+SR+BL+BR), s32 (24 bit), 9216 kb/s (default)
Metadata:
handler_name : SoundHandler
vendor_id : [0][0][0][0]
Stream #0:2[0x3](eng): Data: none (tmcd / 0x64636D74)
Metadata:
handler_name : TimeCodeHandler
timecode : 14:25:46;28
Stream mapping:
Stream #0:1 -> #0:0 (pcm_s24le (native) -> pcm_s16le (native))
Press [q] to stop, [?] for help
[auto_aresample_0 @ 0x7ff5bc004900] [SWR @ 0x7ff5bc0049f0] Input channel
layout '8 channels (FL+FR+FC+LFE+SL+SR+BL+BR)' is not supported
[auto_aresample_0 @ 0x7ff5bc004900] Failed to configure output pad on
auto_aresample_0
[af#0:0 @ 0x21841830] Error reinitializing filters!
[af#0:0 @ 0x21841830] Task finished with error code: -22 (Invalid argument)
[af#0:0 @ 0x21841830] Terminating thread with return code -22 (Invalid
argument)
[aost#0:0/pcm_s16le @ 0x218412b0] [enc:pcm_s16le @ 0x21841770] Could not
open encoder before EOF
[aost#0:0/pcm_s16le @ 0x218412b0] Task finished with error code: -22
(Invalid argument)
[aost#0:0/pcm_s16le @ 0x218412b0] Terminating thread with return code -22
(Invalid argument)
[out#0/wav @ 0x21840b80] Nothing was written into output file, because at
least one of its streams received no packets.
size= 0KiB time=N/A bitrate=N/A speed=N/A
Conversion failed!
```
If I remove 2 lines from sane_layout then I am able to process this file
successfully.
However IDK the implications of this change.
In any case, I'm attaching the patch here, and hopefully someone more
knowledgeable can come up with a more appropriate fix.
From 8dfd5ac84171d591665f069ec935bdf7b8b69936 Mon Sep 17 00:00:00 2001
From: Pavel Koshevoy <[email protected]>
Date: Wed, 29 Jan 2025 20:24:42 -0700
Subject: [PATCH] libswr/rematrix: Do no require AV_CHANNEL_ORDER_NATIVE from
sane_layout
---
libswresample/rematrix.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/libswresample/rematrix.c b/libswresample/rematrix.c
index b9bf4dcac0..f8d77db21f 100644
--- a/libswresample/rematrix.c
+++ b/libswresample/rematrix.c
@@ -104,8 +104,6 @@ static int clean_layout(AVChannelLayout *out, const AVChannelLayout *in, void *s
}
static int sane_layout(AVChannelLayout *ch_layout) {
- if (ch_layout->order != AV_CHANNEL_ORDER_NATIVE)
- return 0;
if(!av_channel_layout_subset(ch_layout, AV_CH_LAYOUT_SURROUND)) // at least 1 front speaker
return 0;
if(!even(av_channel_layout_subset(ch_layout, (AV_CH_FRONT_LEFT | AV_CH_FRONT_RIGHT)))) // no asymetric front
--
2.43.0
_______________________________________________
ffmpeg-devel mailing list
[email protected]
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
[email protected] with subject "unsubscribe".