1

Have such script:

#!/bin/bash

# $1 -- extension, like *.MP4
# $2 -- output file name

ffmpeg -f concat -i <(find . -name '$1' -printf "file '$PWD/%p'\n" | sort) -c copy $2

Trying to concatenate MP4 file, get error:

/dev/fd/63: Invalid data found when processing input

What the problem could be? Using Linux Mint 18, based on Ubuntu 16.04.

P.S. I see the problem is $1 is not substituted in quote - '$1'. Hard coded for now. How to substitute?

11
  • 1
    %1 %2 look like Windows CMD parameters. In bash parameters are $1 and $2. Jul 28, 2016 at 19:37
  • What is the list of MP4 files you are getting? Are you sure all of them are actual MP$ files?
    – grochmal
    Jul 28, 2016 at 19:37
  • @StephenHarris, changed to $1 - same error. Jul 28, 2016 at 19:41
  • 2
    Inside single quotes variables references using $ don't get interpreted.
    – phk
    Jul 28, 2016 at 20:00
  • 1
    You can always do var=\*.MP4 and then find . -name "$var", the double quotes will prevent globing. See what echo "* - *" does
    – grochmal
    Jul 28, 2016 at 20:21

1 Answer 1

1

This works - moved extension outside quotes as -name flag allows it:

#!/bin/bash

# $1 -- extension, like MP4
# $2 -- output file name

echo Extension: $1
echo Output: $2

echo Files:
find . -name \*.$1 -printf "file '$PWD/%p'\n" | sort

ffmpeg -f concat -i <(find . -name \*.$1 -printf "file '$PWD/%p'\n" | sort) -c copy $2
1
  • 3
    I'd suggest … -name "*.$1" … in case the extension contains a space, not that it should. Also, find does not care and actually does not even know about the quoting (but your shell does!).
    – derobert
    Jul 28, 2016 at 20:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .