[FFmpeg-user] Batch Join multimono to multichannel Auido (wav /

Oliver Fromme oliver at fromme.com
Thu Jul 10 21:37:04 CEST 2014

Luigi Rensinghoff wrote:
 > I dont understand the highlighted parts ....  will do some more reading

This is my last answer to the list regarding this.
If you have further questions, please mail to my private address.

 > ------------------    
 >   set --
 > ^^^^^^^^^^^^

Please read the manual page of your shell, i.e. type "man sh"
(or "man bash" if your bourne shell is the bash variant).
It should have a section titled "built-in commands" or similar
that explains the "set" command.

Basically, "set --" clears the positional parameters, i.e. the
parameters assigned to $1, $2, $3 and so on.

 > >         set -- -i "$pre-$c.aif"

That was actually a mistake.  Well, I wasn't able to actually
test the script because I don't have the input files that you
have.  :-)

The correct line should be:

        set -- "$@" -i "$pre-$c.aif"

The term "$@" (must be in double quotes!) is expanded to the
current list of positional parameters, just as if they were
quoted separately.  In other words, "$@" is exactly the same
as "$1" "$2" "$3" ... for any number of positional parameters,
including zero (in this case it expands to nothing at all).

People sometimes confuse $@ and $*.  The latter expands the
parameters to a single string, i.e. "$*" is "$1 $2 $3 ...".

So, the above set command appends -i "$pre-$c.aif" to the
current list of positional parameters.

 > ------------------   ------------------   ------------------   
 >       if [ $? -ne 0 ]; then
 >               echo "****  
 > ------------------   ------------------   ------------------   

"[ ... ]" is the test command, usually built into the shell.
The -ne operator compares two values numerically ("ne" means
not equal).  "$?" expands to the exit code of the most recent
command, which is ffmpeg in this case.  By convention, the
exit code 0 indicates success, and a different value means
that something didn't go right.

So, the above command checks if ffmpeg's exit code was not
equal to zero, and in this case it prints an informative
message and exits from the script, itself returning the exit
code 1 to indicate failure.

Best regards

``We are all but compressed light'' (Albert Einstein)

Donations: http://www.amazon.de/wishlist/A0LHFK68RV8S

More information about the ffmpeg-user mailing list