0

I want to have the one output for a lot MP4 files ,this code output everey file in output separately:

for i in *.MP4; do
  ffmpeg -i "$i" "${i/%MP4/ass}"
done

Thank you

  • Please edit and provide the full details of your situation. Together with askubuntu.com/q/1210090/507051 I assume you have a directory with a number of .MP4 files and want to extract one single .ass subtitle file from them, is that correct? – dessert Feb 14 at 6:41
2

Possible duplicate to: https://stackoverflow.com/questions/7333232/how-to-concatenate-two-mp4-files-using-ffmpeg/11175851

In resume, what you want to do is:

$ cat mylist.txt
file '/path/to/file1'
file '/path/to/file2'
file '/path/to/file3'

$ ffmpeg -f concat -safe 0 -i mylist.txt -c copy output.mp4

PS:

To create the file listing all your .mp4 inputs, you can use this command inside the directory containing all your files:

(edit: Thank's to dessert for the better command line into the comments)

printf "file '%s'\n" *.MP4 > mylist.txt

TL;DR:

One bash line solution (thank's to dessert):

ffmpeg -f concat -safe 0 -i <(printf "file '%s'\n" *.MP4) -c copy output.mp4

If you want to only retrieve all the subtitle, change the extension on the output file:

ffmpeg -f concat -safe 0 -i <(printf "file '%s'\n" *.MP4) -c copy output.ass
  • Totally agree, I've updated my answer with your command line which is way cleaner. – avallete Feb 14 at 6:56
  • 1
    Great!​ :) Now you may combine that with process substitution and save the file creation step: ffmpeg -f concat -safe 0 -i <(printf "file '%s'\n" *.MP4) -c copy output.mp4 – and as OP (I suppose, see comment on Q) doesn’t really want a .mp4, but rather just the subtitle .ass file, just use this extension for the output file and the oneliner is ready. – dessert Feb 14 at 7:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.