Reputation: 31
I Have Created a Bash Shell script.. With that i can crop and convert video locally..
nohup ffmpeg -i "$c1" -vf "$crop_value1" -b 1800k "/home/Cropped/""$name1"_cropped.mp4"" > crop1.txt &
PID1=$!
nohup ffmpeg -i "$c2" -vf "$crop_value2" -b 1800k "/home/Cropped/""$name2"_cropped.mp4"" > crop2.txt &
PID2=$!
nohup ffmpeg -i "$c3" -vf "$crop_value3" -b 1800k "/home/Cropped/""$name3"_cropped.mp4"" > crop3.txt &
PID3=$!
nohup ffmpeg -i "$c4" -vf "$crop_value4" -b 1800k "/home/Cropped/""$name4"_cropped.mp4"" > crop4.txt &
PID4=$!
wait $PID1
wait $PID2
wait $PID3
wait $PID4
As Above Code Shows Im Using 4 Conversion In background In Local Server And I'm Using Wait PID To Check Whether Conversation Finished Or Not.
My Problem Is Its taking very late to Convert.. So I Thinking Of Converting One Conversion In Local Sever And Another Three In Different Remote Server Through SSH Example:
ssh [email protected] "nohup ffmpeg -i "$c1" -vf "$crop_value1" -b 1800k "/home/Cropped/""$name1"_cropped.mp4"" > crop1.txt &"
My Problem Is After Executing Remote Commands How Can I Get Remote PID And Use PID Wait Option For All Remote Connection.
Upvotes: 0
Views: 152
Reputation: 781761
Put the ssh
command in the background, not the remote command:
ssh [email protected] "nohup ffmpeg -i "$c1" -vf "$crop_value1" -b 1800k \
"/home/Cropped/""$name1"_cropped.mp4"" > crop1.txt" &
PID1=$!
BTW, you don't need a wait
command for each background process. If you run wait
with no argument, it waits for all background processes.
Upvotes: 1