[FFmpeg-user] error handling for map_channel

littlebat dashing.meng at gmail.com
Thu Oct 17 04:03:11 CEST 2013


On Wed, 16 Oct 2013 14:25:49 -0700
Elliott Balsley <elliottbalsley at gmail.com> wrote:

> I've been using ffmpeg to batch process lots of files by putting it
> in a find -execdir command.  The source clips I'm encoding have
> varying numbers of audio tracks, and I always want to encode only the
> first two.  Below is my command, which is working beautifully...
> 
> find $source_dir -maxdepth 1 -iname "*.mov" -execdir ffmpeg -i "{}"
> -pix_fmt yuv420p -vf scale=hd720 -acodec libfdk_aac -b:a 128k
> -map_channel 0.1.0 -map_channel 0.1.1 -vcodec libx264 -preset
> veryfast -crf 18 -level 31 H.264/"{}" \;
> 
> But when it comes to a clip that has fewer than two audio tracks, it
> fails with this error: mapchan: stream #0.1 is not an audio stream.
> 
> In this case, I want the encode to have the same number of channels
> as the source (either 0 or 1).  Is there some way to make ffmpeg
> handle this? _______________________________________________

You can write a script, detect audio channel information using ffmpeg
(ffprobe) first, then deal with the audio mapping according the
information.


More information about the ffmpeg-user mailing list