-3

This answer would solve a lot of my problems but relies on wc -l to tally the number of audio channels from the output of ffprobe.

How do I use ffmpeg to merge all audio streams (in a video file) into one audio channel?

I'm using a Windows batch file, so I need another way of accomplishing the following in CMD:

-filter_complex "[0:v]scale=w=1920:h=1080:force_original_aspect_ratio=1,pad=1920:1080:(ow-iw)/2:(oh-ih)/2[video];[0:a]amerge=inputs=$(ffprobe -loglevel error -select_streams a -show_entries stream=codec_type -of csv=p=0 input.mov | wc -l),atempo=24000/24024[audio]"

Any help? My programming experience is minimal. This question seems like it's asking the same thing, but I can't seem to adapt its suggestions into the ffprobe call with the end result being it just returning a number.

What is the windows equivalent of Linux command wc -l?

aschipfl
  • 33,626
  • 12
  • 54
  • 99

1 Answers1

2

This is untested as I don't have your programs installed. But essentially what you need to do is capture the output of ffprobe with a FOR /F command. You will pipe the output of FFPROBE to the FIND command to get a non empty line count.

FOR /F "delims=" %%G in ('ffprobe -loglevel error -select_streams a -show_entries stream^=codec_type -of csv^=p^=0 input.mov ^| find /v /c ""') do set "count=%%G"

You can then use the variable %count% with your FFMPEG command.

Squashman
  • 13,649
  • 5
  • 27
  • 36
  • this worked a charm--thank you so much! Now I can adapt this and use ffprobe to generate all kinds of data, and then decide upon further processing based upon file properties. Amazing. You've made my day! – BrainNoWerk Oct 06 '21 at 19:30
  • The `^` is an escape character. It is needed when special characters are inside the `IN` clause of a `FOR /F` command. – Squashman Oct 06 '21 at 20:53
  • thanks! I spotted they were always preceding "=", so suspected that might be the case. – BrainNoWerk Oct 06 '21 at 21:07