Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Pavel Koshevoy <pkoshevoy@gmail.com>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: [FFmpeg-devel] libswresample/rematrix.c sane_layout
Date: Wed, 29 Jan 2025 20:29:22 -0700
Message-ID: <CAJgjuozSoEwfTaiDbZGUwgoL1NgRNYi4XX4bQiA9p3F5znA5JA@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 3349 bytes --]

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.

[-- Attachment #2: 0001-libswr-rematrix-Do-no-require-AV_CHANNEL_ORDER_NATIV.patch --]
[-- Type: text/x-patch, Size: 951 bytes --]

From 8dfd5ac84171d591665f069ec935bdf7b8b69936 Mon Sep 17 00:00:00 2001
From: Pavel Koshevoy <pkoshevoy@gmail.com>
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


[-- Attachment #3: Type: text/plain, Size: 251 bytes --]

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

             reply	other threads:[~2025-01-30  3:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-30  3:29 Pavel Koshevoy [this message]
2025-02-02  0:01 ` Pavel Koshevoy
2025-02-02 16:04 ` James Almer
2025-02-02 22:01   ` Pavel Koshevoy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAJgjuozSoEwfTaiDbZGUwgoL1NgRNYi4XX4bQiA9p3F5znA5JA@mail.gmail.com \
    --to=pkoshevoy@gmail.com \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git