[FFmpeg-user] Decode ac3 from multichannel USB input

Fred Rotbart rotbart at gmail.com
Tue Oct 31 17:39:46 EET 2023


Okay! After many hours I am making some progress (if anyone is interested).

This extracts the channels, recognises the ac3 and decodes it but there 
are errors thrown from time to time and the rate is not constant.

ffmpeg -f avfoundation -capture_raw_data true -i :2 -filter_complex "\
[0:a]pan=1C|c0=c0[a0];\
[0:a]pan=1C|c0=c1[a1];\
[a0][a1]amerge=inputs=2[a3]" -map '[a3]' \
-f s16le - \
| ffmpeg -loglevel debug \
-acodec ac3 -i - \
-af 'pan=5.1|c0=FL|c1=FR|c4=FC|c5=LFE|c2=SL|c3=SR' \
-ar 48000 -y output.wav

How can I clean this up and make it more stable?

Thanks
-Fred

On 28/10/2023 15:36, Fred Rotbart wrote:
> Here is one of my many other attempts. It should be clear that I am a 
> beginner with ffmpeg.
>
> No matter what I try, ffmpeg seems to merge all the 32 USB channels 
> into 6.
>
> For example:
>
> ffmpeg -ac 2 -c ac3 -loglevel debug -f avfoundation -i :2 -af 
> 'pan=5.1' output.wav
>
> Part of the output:
>
> Splitting the commandline.
> Reading option '-ac' ... matched as option 'ac' (set number of audio 
> channels) with argument '2'.
> Reading option '-c' ... matched as option 'c' (codec name) with 
> argument 'ac3'.
> Reading option '-loglevel' ... matched as option 'loglevel' (set 
> logging level) with argument 'debug'.
> Reading option '-f' ... matched as option 'f' (force format) with 
> argument 'avfoundation'.
> Reading option '-i' ... matched as input url with argument ':2'.
> Reading option '-af' ... matched as option 'af' (set audio filters) 
> with argument 'pan=5.1'.
> Reading option 'output.wav' ... matched as output url.
> Finished splitting the commandline.
> Parsing a group of options: global .
> Applying option loglevel (set logging level) with argument debug.
> Successfully parsed a group of options.
> Parsing a group of options: input url :2.
> Applying option ac (set number of audio channels) with argument 2.
> Applying option c (codec name) with argument ac3.
> Applying option f (force format) with argument avfoundation.
> Successfully parsed a group of options.
> Opening an input file: :2.
> [avfoundation @ 0x7f96400041c0] audio device 'Digiface USB (24162724)' 
> opened
> For transform of length 128, inverse, mdct_float, flags: [aligned, 
> out_of_place], found 3 matches:
>     1: mdct_inv_float_avx2 - type: mdct_float, len: [16, ∞], 
> factors[2]: [2, any], flags: [aligned, out_of_place, inv_only], prio: 544
>     2: mdct_inv_float_c - type: mdct_float, len: [2, ∞], factors[2]: 
> [2, any], flags: [unaligned, out_of_place, inv_only], prio: 96
>     3: mdct_naive_inv_float_c - type: mdct_float, len: [2, ∞], 
> factors[2]: [2, any], flags: [unaligned, out_of_place, inv_only], 
> prio: -130976
> For transform of length 64, inverse, fft_float, flags: [aligned, 
> inplace, preshuf, asm_call], found 3 matches:
>     1: fft_sr_asm_float_avx2 - type: fft_float, len: [64, 131072], 
> factor: 2, flags: [aligned, inplace, out_of_place, preshuf, asm_call], 
> prio: 480
>     2: fft_sr_asm_float_fma3 - type: fft_float, len: [64, 131072], 
> factor: 2, flags: [aligned, inplace, out_of_place, preshuf, asm_call], 
> prio: 448
>     3: fft_sr_asm_float_avx - type: fft_float, len: [64, 131072], 
> factor: 2, flags: [aligned, inplace, out_of_place, preshuf, asm_call], 
> prio: 416
> Transform tree:
>     mdct_inv_float_avx2 - type: mdct_float, len: 128, factors[2]: [2, 
> any], flags: [aligned, out_of_place, inv_only]
>         fft_sr_asm_float_avx2 - type: fft_float, len: 64, factor: 2, 
> flags: [aligned, inplace, out_of_place, preshuf, asm_call]
> For transform of length 256, inverse, mdct_float, flags: [aligned, 
> out_of_place], found 3 matches:
>     1: mdct_inv_float_avx2 - type: mdct_float, len: [16, ∞], 
> factors[2]: [2, any], flags: [aligned, out_of_place, inv_only], prio: 544
>     2: mdct_inv_float_c - type: mdct_float, len: [2, ∞], factors[2]: 
> [2, any], flags: [unaligned, out_of_place, inv_only], prio: 96
>     3: mdct_naive_inv_float_c - type: mdct_float, len: [2, ∞], 
> factors[2]: [2, any], flags: [unaligned, out_of_place, inv_only], 
> prio: -130976
> For transform of length 128, inverse, fft_float, flags: [aligned, 
> inplace, preshuf, asm_call], found 3 matches:
>     1: fft_sr_asm_float_avx2 - type: fft_float, len: [64, 131072], 
> factor: 2, flags: [aligned, inplace, out_of_place, preshuf, asm_call], 
> prio: 480
>     2: fft_sr_asm_float_fma3 - type: fft_float, len: [64, 131072], 
> factor: 2, flags: [aligned, inplace, out_of_place, preshuf, asm_call], 
> prio: 448
>     3: fft_sr_asm_float_avx - type: fft_float, len: [64, 131072], 
> factor: 2, flags: [aligned, inplace, out_of_place, preshuf, asm_call], 
> prio: 416
> Transform tree:
>     mdct_inv_float_avx2 - type: mdct_float, len: 256, factors[2]: [2, 
> any], flags: [aligned, out_of_place, inv_only]
>         fft_sr_asm_float_avx2 - type: fft_float, len: 128, factor: 2, 
> flags: [aligned, inplace, out_of_place, preshuf, asm_call]
> [avfoundation @ 0x7f96400041c0] All info found
> Input #0, avfoundation, from ':2':
>   Duration: N/A, start: 1307454.032041, bitrate: N/A
>   Stream #0:0, 1, 1/1000000: Audio: ac3, 44100 Hz, 32 channels, fltp
> Successfully opened the file.
> Parsing a group of options: output url output.wav.
> Applying option af (set audio filters) with argument pan=5.1.
> Successfully parsed a group of options.
> Opening an output file: output.wav.
> File 'output.wav' already exists. Overwrite? [y/N] y
> [file @ 0x7f9640108000] Setting default whitelist 'file,crypto,data'
> Successfully opened the file.
> For transform of length 128, inverse, mdct_float, flags: [aligned, 
> out_of_place], found 3 matches:
>     1: mdct_inv_float_avx2 - type: mdct_float, len: [16, ∞], 
> factors[2]: [2, any], flags: [aligned, out_of_place, inv_only], prio: 544
>     2: mdct_inv_float_c - type: mdct_float, len: [2, ∞], factors[2]: 
> [2, any], flags: [unaligned, out_of_place, inv_only], prio: 96
>     3: mdct_naive_inv_float_c - type: mdct_float, len: [2, ∞], 
> factors[2]: [2, any], flags: [unaligned, out_of_place, inv_only], 
> prio: -130976
> For transform of length 64, inverse, fft_float, flags: [aligned, 
> inplace, preshuf, asm_call], found 3 matches:
>     1: fft_sr_asm_float_avx2 - type: fft_float, len: [64, 131072], 
> factor: 2, flags: [aligned, inplace, out_of_place, preshuf, asm_call], 
> prio: 480
>     2: fft_sr_asm_float_fma3 - type: fft_float, len: [64, 131072], 
> factor: 2, flags: [aligned, inplace, out_of_place, preshuf, asm_call], 
> prio: 448
>     3: fft_sr_asm_float_avx - type: fft_float, len: [64, 131072], 
> factor: 2, flags: [aligned, inplace, out_of_place, preshuf, asm_call], 
> prio: 416
> Transform tree:
>     mdct_inv_float_avx2 - type: mdct_float, len: 128, factors[2]: [2, 
> any], flags: [aligned, out_of_place, inv_only]
>         fft_sr_asm_float_avx2 - type: fft_float, len: 64, factor: 2, 
> flags: [aligned, inplace, out_of_place, preshuf, asm_call]
> For transform of length 256, inverse, mdct_float, flags: [aligned, 
> out_of_place], found 3 matches:
>     1: mdct_inv_float_avx2 - type: mdct_float, len: [16, ∞], 
> factors[2]: [2, any], flags: [aligned, out_of_place, inv_only], prio: 544
>     2: mdct_inv_float_c - type: mdct_float, len: [2, ∞], factors[2]: 
> [2, any], flags: [unaligned, out_of_place, inv_only], prio: 96
>     3: mdct_naive_inv_float_c - type: mdct_float, len: [2, ∞], 
> factors[2]: [2, any], flags: [unaligned, out_of_place, inv_only], 
> prio: -130976
> For transform of length 128, inverse, fft_float, flags: [aligned, 
> inplace, preshuf, asm_call], found 3 matches:
>     1: fft_sr_asm_float_avx2 - type: fft_float, len: [64, 131072], 
> factor: 2, flags: [aligned, inplace, out_of_place, preshuf, asm_call], 
> prio: 480
>     2: fft_sr_asm_float_fma3 - type: fft_float, len: [64, 131072], 
> factor: 2, flags: [aligned, inplace, out_of_place, preshuf, asm_call], 
> prio: 448
>     3: fft_sr_asm_float_avx - type: fft_float, len: [64, 131072], 
> factor: 2, flags: [aligned, inplace, out_of_place, preshuf, asm_call], 
> prio: 416
> Transform tree:
>     mdct_inv_float_avx2 - type: mdct_float, len: 256, factors[2]: [2, 
> any], flags: [aligned, out_of_place, inv_only]
>         fft_sr_asm_float_avx2 - type: fft_float, len: 128, factor: 2, 
> flags: [aligned, inplace, out_of_place, preshuf, asm_call]
> Stream mapping:
>   Stream #0:0 -> #0:0 (ac3 (native) -> pcm_s16le (native))
> Press [q] to stop, [?] for help
> [aost#0:0/pcm_s16le @ 0x7f963f745840] cur_dts is invalid [init:0 
> i_done:0 finish:0] (this is harmless if it occurs once at the start 
> per stream)
> [AVFilterGraph @ 0x7fe03c4115c0] Setting 'args' to value '5.1'
> detected 12 logical cores
> [graph_0_in_0_0 @ 0x7fe03c4081c0] Setting 'time_base' to value '1/48000'
> [graph_0_in_0_0 @ 0x7fe03c4081c0] Setting 'sample_rate' to value '48000'
> [graph_0_in_0_0 @ 0x7fe03c4081c0] Setting 'sample_fmt' to value 'fltp'
> [graph_0_in_0_0 @ 0x7fe03c4081c0] Setting 'channels' to value '32'
> [graph_0_in_0_0 @ 0x7fe03c4081c0] tb:1/48000 samplefmt:fltp 
> samplerate:48000 chlayout:32 channels
> [format_out_0_0 @ 0x7fe03c404200] Setting 'sample_fmts' to value 's16'
> [format_out_0_0 @ 0x7fe03c404200] auto-inserting filter 
> 'auto_aresample_0' between the filter 'Parsed_pan_0' and the filter 
> 'format_out_0_0'
> [AVFilterGraph @ 0x7fe03c4115c0] query_formats: 4 queried, 6 merged, 3 
> already done, 0 delayed
> [Parsed_pan_0 @ 0x7fe03c40e180] [SWR @ 0x7fe040b00000] Using fltp 
> internally between filters
> [Parsed_pan_0 @ 0x7fe03c40e180] o0 = 0 i0 + 0 i1 + 0 i2 + 0 i3 + 0 i4 
> + 0 i5 + 0 i6 + 0 i7 + 0 i8 + 0 i9 + 0 i10 + 0 i11 + 0 i12 + 0 i13 + 0 
> i14 + 0 i15 + 0 i16 + 0 i17 + 0 i18 + 0 i19 + 0 i20 + 0 i21 + 0 i22 + 
> 0 i23 + 0 i24 + 0 i25 + 0 i26 + 0 i27 + 0 i28 + 0 i29 + 0 i30 + 0 i31
> [Parsed_pan_0 @ 0x7fe03c40e180] o1 = 0 i0 + 0 i1 + 0 i2 + 0 i3 + 0 i4 
> + 0 i5 + 0 i6 + 0 i7 + 0 i8 + 0 i9 + 0 i10 + 0 i11 + 0 i12 + 0 i13 + 0 
> i14 + 0 i15 + 0 i16 + 0 i17 + 0 i18 + 0 i19 + 0 i20 + 0 i21 + 0 i22 + 
> 0 i23 + 0 i24 + 0 i25 + 0 i26 + 0 i27 + 0 i28 + 0 i29 + 0 i30 + 0 i31
> [Parsed_pan_0 @ 0x7fe03c40e180] o2 = 0 i0 + 0 i1 + 0 i2 + 0 i3 + 0 i4 
> + 0 i5 + 0 i6 + 0 i7 + 0 i8 + 0 i9 + 0 i10 + 0 i11 + 0 i12 + 0 i13 + 0 
> i14 + 0 i15 + 0 i16 + 0 i17 + 0 i18 + 0 i19 + 0 i20 + 0 i21 + 0 i22 + 
> 0 i23 + 0 i24 + 0 i25 + 0 i26 + 0 i27 + 0 i28 + 0 i29 + 0 i30 + 0 i31
> [Parsed_pan_0 @ 0x7fe03c40e180] o3 = 0 i0 + 0 i1 + 0 i2 + 0 i3 + 0 i4 
> + 0 i5 + 0 i6 + 0 i7 + 0 i8 + 0 i9 + 0 i10 + 0 i11 + 0 i12 + 0 i13 + 0 
> i14 + 0 i15 + 0 i16 + 0 i17 + 0 i18 + 0 i19 + 0 i20 + 0 i21 + 0 i22 + 
> 0 i23 + 0 i24 + 0 i25 + 0 i26 + 0 i27 + 0 i28 + 0 i29 + 0 i30 + 0 i31
> [Parsed_pan_0 @ 0x7fe03c40e180] o4 = 0 i0 + 0 i1 + 0 i2 + 0 i3 + 0 i4 
> + 0 i5 + 0 i6 + 0 i7 + 0 i8 + 0 i9 + 0 i10 + 0 i11 + 0 i12 + 0 i13 + 0 
> i14 + 0 i15 + 0 i16 + 0 i17 + 0 i18 + 0 i19 + 0 i20 + 0 i21 + 0 i22 + 
> 0 i23 + 0 i24 + 0 i25 + 0 i26 + 0 i27 + 0 i28 + 0 i29 + 0 i30 + 0 i31
> [Parsed_pan_0 @ 0x7fe03c40e180] o5 = 0 i0 + 0 i1 + 0 i2 + 0 i3 + 0 i4 
> + 0 i5 + 0 i6 + 0 i7 + 0 i8 + 0 i9 + 0 i10 + 0 i11 + 0 i12 + 0 i13 + 0 
> i14 + 0 i15 + 0 i16 + 0 i17 + 0 i18 + 0 i19 + 0 i20 + 0 i21 + 0 i22 + 
> 0 i23 + 0 i24 + 0 i25 + 0 i26 + 0 i27 + 0 i28 + 0 i29 + 0 i30 + 0 i31
> [Parsed_pan_0 @ 0x7fe03c40e180] Pure channel mapping detected: M M M M 
> M M
> [auto_aresample_0 @ 0x7fe03c40d280] [SWR @ 0x7fe03c72d000] Using fltp 
> internally between filters
> [auto_aresample_0 @ 0x7fe03c40d280] ch:6 chl:5.1 fmt:fltp r:44100Hz -> 
> ch:6 chl:5.1 fmt:s16 r:48000Hz
> Output #0, wav, to 'output.wav':
>   Metadata:
>     ISFT            : Lavf60.3.100
>   Stream #0:0, 0, 1/48000: Audio: pcm_s16le ([1][0][0][0] / 
> 0x0001), 48000 Hz, 5.1, s16, 4233 kb/s
>     Metadata:
>       encoder         : Lavc60.3.100 pcm_s16le
> [out#0/wav @ 0x7fe03b704840] All streams finished
> [out#0/wav @ 0x7fe03b704840] Terminating muxer thread
>
> I've read all the documentation and searched all the forums but could 
> not find anything that would give me a clue.
> Please help.
>
> - Fred
>
> On 25/10/2023 14:00, Fred Rotbart wrote:
>> Hi,
>>
>> I have a RME Digiface USB as input to my Mac. This has 32 SPDIF input 
>> channels, of which the first two have an ac3 signal and the others 
>> are not used.
>> I have been trying to isolate and decode one of the ac3 channels to 
>> its six separate PCM channels but without success.
>>
>> For example, as one of the many attempts, I tried:
>>
>> ffmpeg -acodec ac3 -f avfoundation -capture_raw_data true -i :1 \
>> -map_channel 0.0.0, \
>> -af 'pan=5.1|c0=c0|c1=-|c2=FC|c3=LFE|c4=BL|c5=BR' \
>> output.wav
>>
>> Can someone help me with this?
>>
>> - Fred
>>


More information about the ffmpeg-user mailing list