I need a script that merges multiple files (.aif and .mp4) in the same folder with the same name to a new folder called [original_name]_new.mp4
Code:
#!/usr/bin/env bash -e
function combine(){
ffmpeg -i "$1" -i "$2" -map 0:0 -map 1:0 -acodec libfdk_aac -b:a 192k -vcodec copy -shortest "$3"
}
for video in ‘“*.mp4’; do
name="{video%.*}
audio=${name}.aif
output=${name}_new.mp4
combine $audio $video $output
done
And the output that I get:
Last login: Sun Oct 18 20:31:10 on ttys000
Tjalles-Mac-Pro:~ tjallo$ /Users/tjallo/Desktop/Christof/try1\ copy.command ; exit;
/Users/tjallo/Desktop/Christof/try1 copy.command: line 8: unexpected EOF while looking for matching `"'
logout
[Process completed]
(Complete re-edit on 18-10-2015)
Edit for @derobert: Now I have this as my code:
set -x
#!/usr/bin/env bash
set -e
function combine(){
ffmpeg -i "$1" -i "$2" -map 0:0 -map 1:0 -acodec libfdk_aac -b:a 192k -vcodec copy -shortest "$3"
}
for video in *.mp4; do
name=“${video%.*}”
audio=“${name}.aif”
output=“${name}_new.mp4”
combine "$audio" "$video" "$output"
done
And this as the Output:
Last login: Sun Oct 18 21:13:27 on ttys001
Tjalles-Mac-Pro:~ tjallo$ /Users/tjallo/Desktop/Christof/try1\ copy.command ; exit;
++ set -e
++ for video in '*.mp4'
++ name='“*”'
++ audio='““*”.aif”'
++ output='““*”_new.mp4”'
++ combine '““*”.aif”' '*.mp4' '““*”_new.mp4”'
++ ffmpeg -i '““*”.aif”' -i '*.mp4' -map 0:0 -map 1:0 -acodec libfdk_aac -b:a 192k -vcodec copy -shortest '““*”_new.mp4”'
ffmpeg version 2.8 Copyright (c) 2000-2015 the FFmpeg developers
built with Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)
configuration: --prefix=/usr/local/Cellar/ffmpeg/2.8 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-opencl --enable-libx264 --enable-libmp3lame --enable-libvo-aacenc --enable-libxvid --enable-vda
libavutil 54. 31.100 / 54. 31.100
libavcodec 56. 60.100 / 56. 60.100
libavformat 56. 40.101 / 56. 40.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 40.101 / 5. 40.101
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.101 / 1. 2.101
libpostproc 53. 3.100 / 53. 3.100
““*”.aif”: No such file or directory
logout
[Process completed]
