Goal:
Create an app via AppleScript that utilizes ffmpeg to concatenate multiple .mp4 files into a single .mp4 file.
•••••••••••
I need a little help with the workflow here.
I currently have found terminal commands that accomplish what I want to do but now I need to wrap it into an app that an end user can work with.
Working Terminal Commands
- Provide file path to .mp4 files
cd path/to/files
- Create an ffmpeg friendly formatted .txt file containing a list of .mp4 files found in this directory
for f in *.MP4; do
echo “file ‘$f’” >> list.txt
done
- Have ffmpeg read the files from the list in step 2, concatenate them into a single file (in the same directory)
ffmpeg -f concat -safe 0 -i list.txt -c copy output.mp4
•••••••••••••
So I have the general steps figured out from a basic command line perspective.
I’ve never written a shell script or used do shell script in Script Debugger so I need help with the steps
I assume the steps to create an app for an end user go as follows.
- Prompt the user to locate the folder containing the clips they want to merge.
set loc to choose folder with prompt "-- Choose the folder containing your source media --" --sets the source directory
- Prompt the user to name the merged clip
set fileName to text returned of (display dialog "Enter the Name of the Merged Clip" default answer "" with title "Name the Merged Clip") & ".mp4" --sets name of merged clip with .mp4 extension
- Execute Shell Script that does the following
A) Change Directory to path user provided in step 1 of the AppleScript app
B) Creates list.txt file as outlined in working terminal command number 2
C) Runs working terminal command number 3 while replacing output.mp4 to the variable, fileName
I am lost on how to use do Shell Script to make step 3 work
I believe I would need to provide the shell script the quoted form of the POSIX path of the variable, loc which I have done with
set pLoc to quoted form of POSIX path of loc as string -- converts loc to POSIX
Script Debugger gives me no user feedback when I run
do shell script "cd " & pLoc
Script Debugger gives me a compile error “Expected end of line, etc. but found unknown token” if I run
do shell script "cd " & pLoc ; pwd --trying to see what directory I'm in, I've also tried echo
I’ve been trying to figure this out for a while with little success.
Can someone please share how to write the do shell script command to change the directory to the variable pLoc? Also, I will then want to run the other two terminal commands. How do I string multiple commands together?
I thought you used “;” to do that, but I was getting a compile error when trying that earlier.
Thank You in advance. - Ben Brodbeck