Droplet for Two-Pass, ProRes to x264 BD-compatible streams

I needed this for work, so I decided to learn Applescript. I can only confirm that it works for ProRes sources. I just tested it with an H.264 file and it converts, but I have no idea if it’s BD-compatible. Changes and suggestions are very welcome!

-- Two-Pass Bluray Encoder - x264 - v2.0
-- This is a droplet for 2-pass encoding of 1080p (--Fake-Interlaced) x264 streams for Bluray compatibility. This stream will be accepted by Encore CS5 as compliant.
-- This droplet requires x264 compiled with ffms.
-- Make sure you have installed an 8-bit build of x264. At the time of this writing, the Bluray standard does not allow for 10-bit video nor does Encore accept it.
-- NOTE: This droplet will not work should any other running process name contain x264.


on open {dropped_item}
	set source to POSIX path of dropped_item
	set app_name to "x264"
	set the_pid to "1111"
	
	do shell script "usr/local/bin/x264 " & "--input-csp yuv422p --bitrate 39000 --preset veryslow --tune film --fps 29.97 --input-res 1920x1080 --bluray-compat --pic-struct --vbv-maxrate 40000 --vbv-bufsize 30000 --level 4.1 --keyint 30 --slices 4 --fake-interlaced --colorprim bt709 --transfer bt709 --colormatrix bt709 --sar 1:1 --pass 1 --stats " & quoted form of source & "_2pass.log -o " & quoted form of source & ".264 " & quoted form of source
	
	
	repeat until the_pid is ""
		set the_pid to (do shell script "ps ax | grep " & (quoted form of app_name) & " | grep -v grep | awk '{print $1}'")
		if the_pid is not "" then
			-- display dialog "Running" & the quoted form of the_pid -- For troubleshooting the_pid output
			delay 5
		else
			
			do shell script "usr/local/bin/x264 " & "--input-csp yuv422p --bitrate 39000 --preset veryslow --tune film --fps 29.97 --input-res 1920x1080 --bluray-compat --pic-struct --vbv-maxrate 40000 --vbv-bufsize 30000 --level 4.1 --keyint 30 --slices 4 --fake-interlaced --colorprim bt709 --transfer bt709 --colormatrix bt709 --sar 1:1 --pass 2 --stats " & quoted form of source & "_2pass.log -o " & quoted form of source & ".264 " & quoted form of source
		end if
	end repeat
end open