1

When user uploads video then I make its 2 sizes. Earlier, I was doing this in two steps like following

First Size:

ffmpeg -i in.mp4 -filter:v "scale=iw*min(1170/iw\,300/ih):ih*min(1170/iw\,300/ih), pad=1170:300:(1170-iw*min(1170/iw\,300/ih))/2:(300-ih*min(1170/iw\,300/ih))/2" out.mp4

Second Size:

ffmpeg -i in.mp4 -filter:v "scale=iw*min(365/iw\,172/ih):ih*min(365/iw\,172/ih), pad=365:172:(365-iw*min(365/iw\,172/ih))/2:(172-ih*min(365/iw\,172/ih))/2" out1.mp4

But now to reduce processing time, I want to combine these 2 steps in one. I have read https://trac.ffmpeg.org/wiki/Creating%20multiple%20outputs and make following command

ffmpeg -i in.mp4 -filter:v "scale=iw*min(1170/iw\,300/ih):ih*min(1170/iw\,300/ih), pad=1170:300:(1170-iw*min(1170/iw\,300/ih))/2:(300-ih*min(1170/iw\,300/ih))/2" bigVideo.mp4 \ -filter:v "scale=iw*min(365/iw\,172/ih):ih*min(365/iw\,172/ih), pad=365:172:(365-iw*min(365/iw\,172/ih))/2:(172-ih*min(365/iw\,172/ih))/2" smallVideo.mp4

But it is giving following error

[NULL @ 0xaee5440] Unable to find a suitable output format for ' -filter:v' -filter:v: Invalid argument

so can anyone suggest me how i can solve it?

Jass
  • 3,345
  • 3
  • 24
  • 41

1 Answers1

0

I tried to run both commands using the following script:

#!/bin/bash
for cmd in "$@"; do {
echo "Process \"$cmd\" started";
$cmd & pid=$!
  PID_LIST+=" $pid";
  } done
  trap "kill $PID_LIST" SIGINT
  echo "Parallel processes have started";
  wait $PID_LIST
  echo
  echo "All processes have completed";

You can save it as filename.sh and make executable. after that you need to pass two of more commands as arguments, for example I ran as:

./filename.sh "ffmpeg -i input.mp4  -s 720x480 output1.mp4" "ffmpeg -i input.mp4  -s 1170x480 output2.mp4"

Your command was bit complicated for me so I try to run simple commands using parallel script.

arshpreet
  • 679
  • 2
  • 11
  • 27