[FFmpeg-user] audio channel manipulation

Jim Shupert jshupert at theppsgroup.com
Mon Jan 21 21:01:52 EET 2019


Friends,
I think I have a solution to my needs.
My purpose here is to share and ask if there is a better way to achieve 
my goal.
I would be happy to the thoughts of others.
This matter of audio mapping , channel selection is something that i 
wished I understood better.

Goal: capture from dbeta  the audio is 4 "track" . you can stand at the 
deck and turn each of the 4 up or down - they are independent.
I wish to achieve a ffv1 avi where the audio is 4 streams each having 1 
mono channel

why was I concerend about this?
If a file has 1 stream with 4 channels ( the org 4 "tracks" from tape) 
and the 1st 2 channels are "good stuff" but the  4th channel is 
something less wanted
Then when you play in vlc - you have no control -- the wanted and the 
unwanted .
if it is in 4 streams you can pick which to hear.

My capture system captures 10bit unc mov video [0:0]  ( 4ch_test.mov )
and the 4 audio "tracks" are found in 1 stream as 4 channels [0:1.0 , 
0:1.1, 0:1.2, 0:1.3 ]

below please find my current means to make the ffv1 avi ( with 4 stream 
1 chn )   and then use the ffv1 avi
to make a mp4 with 1 stream of audio holding 2 channels


I was unable to do what i wished with audio mapping ( -map / -map_channel  )


---------------------------:: make the ffv1 avi from the 10b mov  capture .
4s_b.avi

ffmpeg -i 4ch_test.mov -vcodec ffv1 -level 3 -coder 1 -pix_fmt 
yuv422p10le -aspect 4:3 -g 1 \
  -filter_complex "[0:a]pan=mono|c0=c0[a0]; [0:a]pan=mono|c0=c1[a1]; 
[0:a]pan=mono|c0=c2[a2]; [0:a]pan=mono|c0=c3[a3]" \
  -map 0:v -map "[a0]" -map "[a1]" -map "[a2]" -map "[a3]" -map 0:d -c 
copy -c:a pcm_s24le -f avi 4s_b.avi

-----------------------:: make a mp4 (4s_b.mp4 ) from the ffv1 avi ( 
4s_b.avi )

ffmpeg -i 4s_b.avi -vf "yadif" -aspect 4:3 -vcodec libx264 -b:v 5110k -g 
12 -bf 3 -b_strategy 1 -coder 1 \
  -qmin 10 -qmax 51 -sc_threshold 40 -me_range 16 -me_method hex -subq 5 
-i_qfactor 0.71 -qcomp 0.6 -qdiff 4  -pix_fmt yuv420p \
  -filter_complex "[0:1] [0:2] amerge" -acodec aac -ar 48000 -b:a 256k 
-ac 2 4s_b.mp4



::: the below are some mediainfo probes of the files
1- the capture from tape 2- the ffv1 avi I make , 3 the mp4 that i make 
from the ffv1 avi

my capture 10b unc mov  4 channels in 1 stream
-----------------------:  org capture from tape
Video
ID                                       : 1
Format                                   : YUV
Codec ID                                 : v210
Codec ID/Hint                            : AJA Video Systems Xena
Duration                                 : 12 s 880 ms
Bit rate mode                            : Constant
Bit rate                                 : 224 Mb/s
Width                                    : 720 pixels
Height                                   : 486 pixels
Display aspect ratio                     : 4:3
Frame rate mode                          : Constant
Frame rate                               : 29.970 (30000/1001) FPS
Standard                                 : NTSC
Color space                              : YUV
Chroma subsampling                       : 4:2:2
Bit depth                                : 10 bits
Scan type                                : Interlaced
Scan type, store method                  : Interleaved fields
Scan order                               : Bottom Field First
Compression mode                         : Lossless
Bits/(Pixel*Frame)                       : 21.333
Stream size                              : 343 MiB (98%)
Language                                 : English
Encoded date                             : UTC 2019-01-15 22:54:36
Tagged date                              : UTC 2019-01-15 22:54:49
Color primaries                          : BT.601 NTSC
Transfer characteristics                 : BT.709
Matrix coefficients                      : BT.601

Audio
ID                                       : 2
Format                                   : PCM
Format settings, Endianness              : Little
Format settings, Sign                    : Signed
Codec ID                                 : lpcm
Duration                                 : 12 s 880 ms
Bit rate mode                            : Constant
Bit rate                                 : 4 608 kb/s
Channel(s)                               : 4 channels
Sampling rate                            : 48.0 kHz
Bit depth                                : 24 bits
Stream size                              : 7.07 MiB (2%)
Language                                 : English


that is turned into the ffv1 avi with 4 streams of audio with 1 channel each
-------------------------------------::  ffv1 avi now with 4 streams 
each having 1 channel each
4s_b.avi
Format                                   : AVI
Format/Info                              : Audio Video Interleave
File size                                : 351 MiB
Duration                                 : 12 s 880 ms
Overall bit rate                         : 228 Mb/s
Writing application                      : Lavf57.83.100

Video
ID                                       : 0
Format                                   : YUV
Codec ID                                 : v210
Codec ID/Hint                            : AJA Video Systems Xena
Duration                                 : 12 s 880 ms
Bit rate                                 : 224 Mb/s
Width                                    : 720 pixels
Height                                   : 486 pixels
Display aspect ratio                     : 4:3
Frame rate                               : 59.940 (60000/1001) FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:2
Bit depth                                : 10 bits
Scan type                                : Progressive
Compression mode                         : Lossless
Bits/(Pixel*Frame)                       : 10.667
Stream size                              : 343 MiB (98%)

Audio #1
ID                                       : 1
Format                                   : PCM
Format settings, Endianness              : Little
Format settings, Sign                    : Signed
Codec ID                                 : 
00001000-0000-0100-8000-00AA00389B71
Duration                                 : 12 s 880 ms
Bit rate mode                            : Constant
Bit rate                                 : 1 152 kb/s
Channel(s)                               : 1 channel
Channel positions                        : Front: C
Sampling rate                            : 48.0 kHz
Bit depth                                : 24 bits
Stream size                              : 1.77 MiB (1%)
Alignment                                : Aligned on interleaves
Interleave, duration                     : 21  ms (1.27 video frame)

Audio #2
ID                                       : 2
Format                                   : PCM
Format settings, Endianness              : Little
Format settings, Sign                    : Signed
Codec ID                                 : 
00001000-0000-0100-8000-00AA00389B71
Duration                                 : 12 s 880 ms
Bit rate mode                            : Constant
Bit rate                                 : 1 152 kb/s
Channel(s)                               : 1 channel
Channel positions                        : Front: C
Sampling rate                            : 48.0 kHz
Bit depth                                : 24 bits
Stream size                              : 1.77 MiB (1%)
Alignment                                : Aligned on interleaves
Interleave, duration                     : 21  ms (1.27 video frame)

Audio #3
ID                                       : 3
Format                                   : PCM
Format settings, Endianness              : Little
Format settings, Sign                    : Signed
Codec ID                                 : 
00001000-0000-0100-8000-00AA00389B71
Duration                                 : 12 s 880 ms
Bit rate mode                            : Constant
Bit rate                                 : 1 152 kb/s
Channel(s)                               : 1 channel
Channel positions                        : Front: C
Sampling rate                            : 48.0 kHz
Bit depth                                : 24 bits
Stream size                              : 1.77 MiB (1%)
Alignment                                : Aligned on interleaves
Interleave, duration                     : 21  ms (1.27 video frame)

Audio #4
ID                                       : 4
Format                                   : PCM
Format settings, Endianness              : Little
Format settings, Sign                    : Signed
Codec ID                                 : 
00001000-0000-0100-8000-00AA00389B71
Duration                                 : 12 s 880 ms
Bit rate mode                            : Constant
Bit rate                                 : 1 152 kb/s
Channel(s)                               : 1 channel
Channel positions                        : Front: C
Sampling rate                            : 48.0 kHz
Bit depth                                : 24 bits
Stream size                              : 1.77 MiB (1%)
Alignment                                : Aligned on interleaves
Interleave, duration                     : 21  ms (1.27 video frame

..........................................................:: the mp4

and now the mp4 made from the ffv1 avi
mp4 has 1 stream with 2 channels  and these are from the 1st 2 channels 
or tape "tracks" 1 & 2

4s_b.mp4
Format                                   : MPEG-4
Format profile                           : Base Media
Codec ID                                 : isom (isom/iso2/avc1/mp41)
File size                                : 3.05 MiB
Duration                                 : 12 s 901 ms
Overall bit rate mode                    : Variable
Overall bit rate                         : 1 983 kb/s
Encoded date                             : UTC 1904-01-01 00:00:00
Tagged date                              : UTC 1904-01-01 00:00:00
Writing application                      : Lavf57.83.100

Video
ID                                       : 2
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : High at L3.1
Format settings, CABAC                   : Yes
Format settings, ReFrames                : 4 frames
Format settings, GOP                     : M=4, N=12
Codec ID                                 : avc1
Codec ID/Info                            : Advanced Video Coding
Duration                                 : 12 s 863 ms
Bit rate                                 : 1 914 kb/s
Nominal bit rate                         : 5 110 kb/s
Width                                    : 720 pixels
Height                                   : 486 pixels
Display aspect ratio                     : 4:3
Frame rate mode                          : Constant
Frame rate                               : 59.940 (60000/1001) FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:0

Audio
ID                                       : 1
Format                                   : AAC
Format/Info                              : Advanced Audio Codec
Format profile                           : LC
Codec ID                                 : 40
Duration                                 : 12 s 901 ms
Duration_LastFrame                       : -6 ms
Bit rate mode                            : Variable
Bit rate                                 : 60.8 kb/s
Maximum bit rate                         : 256 kb/s
Channel(s)                               : 2 channels
Channel positions                        : Front: L R
Sampling rate                            : 48.0 kHz
Frame rate                               : 46.875 FPS (1024 spf)
Compression mode                         : Lossy
Stream size                              : 95.7 KiB (3%)


==================================================

Links that I used to further my understanding

https://www.markkeller.me/2016-11-27-ffmpeg/
https://ffmpeg.org/ffmpeg.html#Audio-Options

https://trac.ffmpeg.org/wiki/AudioChannelManipulation
https://superuser.com/questions/1063185/how-to-select-the-left-audio-channel-with-ffmpeg-and-downmix-to-mono



More information about the ffmpeg-user mailing list