Counting audio channels in a batch file

Questions involving a Windows version of FFmpeg.
Post Reply
wallywalters
Posts: 2
Joined: Sun Jun 21, 2015 6:21 pm

Counting audio channels in a batch file

Post by wallywalters » Thu Feb 23, 2017 11:14 pm

Does ffmpeg have a way to look at an audio file and report whether it's mono or stereo ? I need count the number of channels in a track and assign that number to a variable in a Windows batch file. Thanks.

llogan
Posts: 332
Joined: Fri Mar 14, 2014 3:29 am

Re: Counting audio channels in a batch file

Post by llogan » Wed Mar 08, 2017 7:59 pm

Number of channels example:

Code: Select all

ffprobe -loglevel error -select_streams a:0 -show_entries stream=channels -of default=nw=1 5point1.m4a
Result:

Code: Select all

channels=6
Channel layout example:

Code: Select all

ffprobe -loglevel error -select_streams a:0 -show_entries stream=channels -of default=nw=1 5point1.m4a
Result:

Code: Select all

channel_layout=5.1
If you want to omit the key, such as channels=, add nk=1. Example:

Code: Select all

ffprobe -loglevel error -select_streams a:0 -show_entries stream=channels -of default=nw=1:nk=1 5point1.m4a
Result:

Code: Select all

6

Post Reply