lu-zero / bmdtools

Basic capture and play programs for Blackmagic Design Decklink
Boost Software License 1.0
198 stars 74 forks source link

Multichannel Audio Example #64

Closed triwav closed 9 years ago

triwav commented 9 years ago

Can you give an example of playing a file with more than two channels of audio with bmdplay. Setting -ac to 8 results in only one channel of audio being played out on the third channel. Setting -ac 16 acts like it's only receiving 1 audio input into bmdplay and it won't work at all. Thank you.

stevenviola commented 9 years ago

With bmdplay, you don't set the number of audio channels in the bmdplay arguments, unlike how bmdcapture works. With bmdplay, I believe it is able to pickup the number of audio channels from the container if you're using the nut container, and then it sets that for the output. For example, if you're using ffmpeg and piping video to bmdplay to output the audio, you would run the following:

ffmpeg -re -i 8_channel_audio.flac -s 1280x720 -f rawvideo -pix_fmt rgb24 -r 59.94 -i /dev/zero -shortest -c:v rawvideo -pix_fmt uyvy422 -c:a pcm_s16le -ar 48000 -ac 8 -f nut - | bmdtools/bmdplay -C 0 -m 12 -f pipe:0

This takes the 8 channel audio in the flac file and outputs it with black video over your device. If using bmdcapture to record this feed, you would need to set the -c argument to 8 in order to pick up all 8 channels, else you will only get the left and right channel audio

Let me know if that helps and if possible, share the command and source video you're trying to use with bmdplay

lu-zero commented 9 years ago

avconv has channelmap and channelsplit that you can use to take only the channels you need and optionally split them in two or more if your codec does not support multiple channels (e.g. split 8 channels in 4 2channels aac).

On the decoding side you have to use join to reconstruct the channels, bmdplay does support 2, 8 and 16 channels.

I hope it helps.

triwav commented 9 years ago

Thanks for the feedback. This is what I'm running ffmpeg -re -i Multichanel16.mov -pix_fmt uyvy422 -c:a pcm_s16le -ar 48000 -ac 8 -r 29.97 -s 1920x1080 -c:v rawvideo -f nut - | bmdplay -m 9 -f pipe:0 -C 0. Here is a link to the file: http://brianleighty.com/Multichanel16.mov

That outputs one channel of audio on channel 3. If I change -ac to 2 I get stereo audio out on channels 1 and 2. I messed with amerge some adding -filter_complex "amerge=inputs=16" and taking out -ac. This results in channels 1 & 2 having audio.

lu-zero commented 9 years ago

Please do use avconv and report back.

triwav commented 9 years ago

Just ran avconv -re -i Multichanel16.mov -pix_fmt uyvy422 -c:a pcm_s16le -ar 48000 -ac 8 -r 29.97 -s 1920x1080 -c:v rawvideo -f nut - | bmdplay -m 9 -f pipe:0 -C 0 and it's doing the same thing of outputting to one channel of audio on channel 3.

lu-zero commented 9 years ago

Paste avconv -i Multichannel16.mov please.

triwav commented 9 years ago

avconv version 9.18-6:9.18-0ubuntu0.14.04.1, Copyright (c) 2000-2014 the Libav developers built on Mar 16 2015 13:19:10 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1) Guessed Channel Layout for Input Stream #0.1 : mono Guessed Channel Layout for Input Stream #0.2 : mono Guessed Channel Layout for Input Stream #0.3 : mono Guessed Channel Layout for Input Stream #0.4 : mono Guessed Channel Layout for Input Stream #0.5 : mono Guessed Channel Layout for Input Stream #0.6 : mono Guessed Channel Layout for Input Stream #0.7 : mono Guessed Channel Layout for Input Stream #0.8 : mono Guessed Channel Layout for Input Stream #0.9 : mono Guessed Channel Layout for Input Stream #0.10 : mono Guessed Channel Layout for Input Stream #0.11 : mono Guessed Channel Layout for Input Stream #0.12 : mono Guessed Channel Layout for Input Stream #0.13 : mono Guessed Channel Layout for Input Stream #0.14 : mono Guessed Channel Layout for Input Stream #0.15 : mono Guessed Channel Layout for Input Stream #0.16 : mono Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'Multichanel16.mov': Metadata: major_brand : qt
minor_version : 537199360 compatible_brands: qt
creation_time : 2015-08-18 16:58:54 Duration: 00:02:32.68, start: 0.000000, bitrate: 22260 kb/s Stream #0.0(eng): Video: h264 (Main), yuv420p, 1920x1080, 9961 kb/s, PAR 1920:1920 DAR 16:9, 29.97 fps, 29.97 tbr, 30k tbn Metadata: creation_time : 2015-08-18 16:58:54 Stream #0.1(eng): Audio: pcm_s16le, 48000 Hz, mono, s16, 768 kb/s Metadata: creation_time : 2015-08-18 16:58:54 Stream #0.2(eng): Audio: pcm_s16le, 48000 Hz, mono, s16, 768 kb/s Metadata: creation_time : 2015-08-18 16:58:54 Stream #0.3(eng): Audio: pcm_s16le, 48000 Hz, mono, s16, 768 kb/s Metadata: creation_time : 2015-08-18 16:58:54 Stream #0.4(eng): Audio: pcm_s16le, 48000 Hz, mono, s16, 768 kb/s Metadata: creation_time : 2015-08-18 16:58:54 Stream #0.5(eng): Audio: pcm_s16le, 48000 Hz, mono, s16, 768 kb/s Metadata: creation_time : 2015-08-18 16:58:54 Stream #0.6(eng): Audio: pcm_s16le, 48000 Hz, mono, s16, 768 kb/s Metadata: creation_time : 2015-08-18 16:58:54 Stream #0.7(eng): Audio: pcm_s16le, 48000 Hz, mono, s16, 768 kb/s Metadata: creation_time : 2015-08-18 16:58:54 Stream #0.8(eng): Audio: pcm_s16le, 48000 Hz, mono, s16, 768 kb/s Metadata: creation_time : 2015-08-18 16:58:54 Stream #0.9(eng): Audio: pcm_s16le, 48000 Hz, mono, s16, 768 kb/s Metadata: creation_time : 2015-08-18 16:58:54 Stream #0.10(eng): Audio: pcm_s16le, 48000 Hz, mono, s16, 768 kb/s Metadata: creation_time : 2015-08-18 16:58:54 Stream #0.11(eng): Audio: pcm_s16le, 48000 Hz, mono, s16, 768 kb/s Metadata: creation_time : 2015-08-18 16:58:54 Stream #0.12(eng): Audio: pcm_s16le, 48000 Hz, mono, s16, 768 kb/s Metadata: creation_time : 2015-08-18 16:58:54 Stream #0.13(eng): Audio: pcm_s16le, 48000 Hz, mono, s16, 768 kb/s Metadata: creation_time : 2015-08-18 16:58:54 Stream #0.14(eng): Audio: pcm_s16le, 48000 Hz, mono, s16, 768 kb/s Metadata: creation_time : 2015-08-18 16:58:54 Stream #0.15(eng): Audio: pcm_s16le, 48000 Hz, mono, s16, 768 kb/s Metadata: creation_time : 2015-08-18 16:58:54 Stream #0.16(eng): Audio: pcm_s16le, 48000 Hz, mono, s16, 768 kb/s Metadata: creation_time : 2015-08-18 16:58:54 Stream #0.17(eng): Data: tmcd / 0x64636D74 Metadata: creation_time : 2015-08-18 17:06:14 At least one output file must be specified

lu-zero commented 9 years ago

you can do -filter_complex join=16:octagonal to have all the channels downmixed to 8, I'm pushing a patch in my personal branch to add a 16 points layout in case you need that.

triwav commented 9 years ago

Thanks @lu-zero I just tried that and am getting [join filter @ 0x1109360] Missing key or no key/value separator found after key '16:octagonal' [join @ 0xf4d500] Error parsing options string '16:octagonal'. [AVFilterGraph @ 0xda08c0] Error initializing filter 'join' with args '16:octagonal'

lu-zero commented 9 years ago

your version is old, let's use the old syntax then: join=inputs=16:channel_layout=8c

triwav commented 9 years ago

Alright, at least we got something different. That's outputting audio to channels 1 & 3

lu-zero commented 9 years ago

If your bmd output is 2 channels connected do join=inputs:16 that will downmix to 2 channels by default

triwav commented 9 years ago

I'd like to get all input channels to output to their respective output channels so channel 1 input goes to channel 1 on SDI ... channel 16 input goes to channel 16 on SDI

lu-zero commented 9 years ago

You can try this not really tested code https://github.com/lu-zero/libav/tree/16channels edit: the branch got updated and merged in the Libav master.

lu-zero commented 9 years ago

I fixed the layout here you can use libav master and using -filter_complex join=16:16c would do what you want.

triwav commented 9 years ago

Just tried that. Now it outputs to channels 1 & 3. Here's the output from that: ./avconv -re -i Multichanel16.mov -pix_fmt uyvy422 -c:a pcm_s16le9.97 -s 1920x1080 -c:v rawvideo -f nut -filter_complex join=16:16c - | bmdplay -m 9 -f pipe:0 -C 0 avconv version v12_dev0-1766-gb1abd2a, Copyright (c) 2000-2015 the Libav developers built on Aug 27 2015 08:02:02 with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04) Guessed Channel Layout for Input Stream #0.1 : mono Guessed Channel Layout for Input Stream #0.2 : mono Guessed Channel Layout for Input Stream #0.3 : mono Guessed Channel Layout for Input Stream #0.4 : mono Guessed Channel Layout for Input Stream #0.5 : mono Guessed Channel Layout for Input Stream #0.6 : mono Guessed Channel Layout for Input Stream #0.7 : mono Guessed Channel Layout for Input Stream #0.8 : mono Guessed Channel Layout for Input Stream #0.9 : mono Guessed Channel Layout for Input Stream #0.10 : mono Guessed Channel Layout for Input Stream #0.11 : mono Guessed Channel Layout for Input Stream #0.12 : mono Guessed Channel Layout for Input Stream #0.13 : mono Guessed Channel Layout for Input Stream #0.14 : mono Guessed Channel Layout for Input Stream #0.15 : mono Guessed Channel Layout for Input Stream #0.16 : mono Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/media/ifs/Anystream/08 18 15/SethMultichannelClip/Multichanel16.mov': Metadata: major_brand : qt
minor_version : 537199360 compatible_brands: qt
creation_time : 2015-08-18 16:58:54 Duration: 00:02:32.68, start: 0.000000, bitrate: 22260 kb/s Stream #0:0(eng): Video: h264 (Main) [avc1 / 0x31637661] yuv420p, tv, bt709/bt709/bt709 1920x1080, 9961 kb/s, PAR 1920:1920 DAR 16:9 29.97 fps, 30k tbn (default) Metadata: creation_time : 2015-08-18 16:58:54 handler_name : Apple Alias Data Handler encoder : H.264 Stream #0:1(eng): Audio: pcm_s16le [sowt / 0x74776F73] 48000 Hz, 1 channels, s16, 768 kb/s (default) Metadata: creation_time : 2015-08-18 16:58:54 handler_name : Apple Alias Data Handler Stream #0:2(eng): Audio: pcm_s16le [sowt / 0x74776F73] 48000 Hz, 1 channels, s16, 768 kb/s (default) Metadata: creation_time : 2015-08-18 16:58:54 handler_name : Apple Alias Data Handler Stream #0:3(eng): Audio: pcm_s16le [sowt / 0x74776F73] 48000 Hz, 1 channels, s16, 768 kb/s (default) Metadata: creation_time : 2015-08-18 16:58:54 handler_name : Apple Alias Data Handler Stream #0:4(eng): Audio: pcm_s16le [sowt / 0x74776F73] 48000 Hz, 1 channels, s16, 768 kb/s (default) Metadata: creation_time : 2015-08-18 16:58:54 handler_name : Apple Alias Data Handler Stream #0:5(eng): Audio: pcm_s16le [sowt / 0x74776F73] 48000 Hz, 1 channels, s16, 768 kb/s (default) Metadata: creation_time : 2015-08-18 16:58:54 handler_name : Apple Alias Data Handler Stream #0:6(eng): Audio: pcm_s16le [sowt / 0x74776F73] 48000 Hz, 1 channels, s16, 768 kb/s (default) Metadata: creation_time : 2015-08-18 16:58:54 handler_name : Apple Alias Data Handler Stream #0:7(eng): Audio: pcm_s16le [sowt / 0x74776F73] 48000 Hz, 1 channels, s16, 768 kb/s (default) Metadata: creation_time : 2015-08-18 16:58:54 handler_name : Apple Alias Data Handler Stream #0:8(eng): Audio: pcm_s16le [sowt / 0x74776F73] 48000 Hz, 1 channels, s16, 768 kb/s (default) Metadata: creation_time : 2015-08-18 16:58:54 handler_name : Apple Alias Data Handler Stream #0:9(eng): Audio: pcm_s16le [sowt / 0x74776F73] 48000 Hz, 1 channels, s16, 768 kb/s (default) Metadata: creation_time : 2015-08-18 16:58:54 handler_name : Apple Alias Data Handler Stream #0:10(eng): Audio: pcm_s16le [sowt / 0x74776F73] 48000 Hz, 1 channels, s16, 768 kb/s (default) Metadata: creation_time : 2015-08-18 16:58:54 handler_name : Apple Alias Data Handler Stream #0:11(eng): Audio: pcm_s16le [sowt / 0x74776F73] 48000 Hz, 1 channels, s16, 768 kb/s (default) Metadata: creation_time : 2015-08-18 16:58:54 handler_name : Apple Alias Data Handler Stream #0:12(eng): Audio: pcm_s16le [sowt / 0x74776F73] 48000 Hz, 1 channels, s16, 768 kb/s (default) Metadata: creation_time : 2015-08-18 16:58:54 handler_name : Apple Alias Data Handler Stream #0:13(eng): Audio: pcm_s16le [sowt / 0x74776F73] 48000 Hz, 1 channels, s16, 768 kb/s (default) Metadata: creation_time : 2015-08-18 16:58:54 handler_name : Apple Alias Data Handler Stream #0:14(eng): Audio: pcm_s16le [sowt / 0x74776F73] 48000 Hz, 1 channels, s16, 768 kb/s (default) Metadata: creation_time : 2015-08-18 16:58:54 handler_name : Apple Alias Data Handler Stream #0:15(eng): Audio: pcm_s16le [sowt / 0x74776F73] 48000 Hz, 1 channels, s16, 768 kb/s (default) Metadata: creation_time : 2015-08-18 16:58:54 handler_name : Apple Alias Data Handler Stream #0:16(eng): Audio: pcm_s16le [sowt / 0x74776F73] 48000 Hz, 1 channels, s16, 768 kb/s (default) Metadata: creation_time : 2015-08-18 16:58:54 handler_name : Apple Alias Data Handler Stream #0:17(eng): Data: tmcd / 0x64636D74 (default) Metadata: creation_time : 2015-08-18 17:06:14 handler_name : Apple Alias Data Handler Output #0, nut, to 'pipe:': Metadata: major_brand : qt
minor_version : 537199360 compatible_brands: qt
creation_time : 2015-08-18 16:58:54 encoder : Lavf56.21.0 Stream #0:0: Audio: pcm_s16le [PSD[16] / 0x10445350] 48000 Hz, hexadecagonal, s16, 12288 kb/s (default) Metadata: encoder : Lavc56.35.1 pcm_s16le Stream #0:1: Video: rawvideo [UYVY / 0x59565955] uyvy422, 1920x1080 [PAR 1:1 DAR 16:9], q=2-31, 200 kb/s 29.97 fps, 29.97 tbn, 29.97 tbc (default) Metadata: creation_time : 2015-08-18 16:58:54 X-Language : eng handler_name : Apple Alias Data Handler encoder : H.264 Stream mapping: Stream #0:1 (pcm_s16le) -> join:input0 (graph 0) Stream #0:2 (pcm_s16le) -> join:input1 (graph 0) Stream #0:3 (pcm_s16le) -> join:input2 (graph 0) Stream #0:4 (pcm_s16le) -> join:input3 (graph 0) Stream #0:5 (pcm_s16le) -> join:input4 (graph 0) Stream #0:6 (pcm_s16le) -> join:input5 (graph 0) Stream #0:7 (pcm_s16le) -> join:input6 (graph 0) Stream #0:8 (pcm_s16le) -> join:input7 (graph 0) Stream #0:9 (pcm_s16le) -> join:input8 (graph 0) Stream #0:10 (pcm_s16le) -> join:input9 (graph 0) Stream #0:11 (pcm_s16le) -> join:input10 (graph 0) Stream #0:12 (pcm_s16le) -> join:input11 (graph 0) Stream #0:13 (pcm_s16le) -> join:input12 (graph 0) Stream #0:14 (pcm_s16le) -> join:input13 (graph 0) Stream #0:15 (pcm_s16le) -> join:input14 (graph 0) Stream #0:16 (pcm_s16le) -> join:input15 (graph 0) join (graph 0) -> Stream #0:0 (pcm_s16le) Stream #0:0 -> #0:1 (h264 (native) -> rawvideo (native)) Press ctrl-c to stop encoding Input #0, nut, from 'pipe:0':ze= 4082kB time=0.02 bitrate=1567660.5kbits/s /s
Metadata: major_brand : qt
minor_version : 537199360 compatible_brands: qt
creation_time : 2015-08-18 16:58:54 encoder : Lavf56.21.0 Duration: N/A, start: 0.000000, bitrate: 12288 kb/s Stream #0:0: Audio: pcm_s16le (PSD[16] / 0x10445350), 48000 Hz, 16 channels, s16, 12288 kb/s (default) Stream #0:1: Video: rawvideo (UYVY / 0x59565955), uyvy422, 1920x1080, SAR 1:1 DAR 16:9, 29.97 tbr, 29.97 tbn, 29.97 tbc (default) Selected mode: HD 1080i 60 size= 241864kB time=1.94 bitrate=1023810.4kbits/s

lu-zero commented 9 years ago

I opened the test file in audacity and I can see only two tracks not quiet so I would expect you to see 2 tracks active as well. Can you capture something with all the tracks active and test it this way?

triwav commented 9 years ago

[hand on face] my mistake I assumed the file I'd received was correct. I just ran the below command and I'm seeing output on all 16 channels. ffmpeg -re -f lavfi -i "sine=frequency=1000:sample_rate=48000:duration=300" -f lavfi -i "testsrc=duration=300:size=1920x1080:rate=29.97" -pix_fmt uyvy422 -c:a pcm_s16le -ar 48000 -r 29.97 -s 1920x1080 -c:v rawvideo -filter_complex "[0:a][0:a][0:a][0:a][0:a][0:a][0:a][0:a][0:a][0:a][0:a][0:a][0:a][0:a][0:a][0:a]amerge=inputs=16[aout]" -map 1:0 -map [aout] -f nut - | bmdplay -m 9 -f pipe:0 -C 0 -O 4

lu-zero commented 9 years ago

I started documenting a little this part of the usage so it should help others, I guess you should be set now.