diff --git a/combine-videos-side-by-side.sh b/combine-videos-side-by-side.sh index 7349a9c..cf2994a 100755 --- a/combine-videos-side-by-side.sh +++ b/combine-videos-side-by-side.sh @@ -21,7 +21,7 @@ USAGE="USAGE: ./combine-videos-side-by-side.sh input1 input2 output" : ${2?$USAGE} : ${3?$USAGE} -INTERMEDIATE_FILE=intermediate-$3 +INTERMEDIATE_FILE=$3.intermediate.mp4 # Combine videos side-by-side, adapted from https://stackoverflow.com/a/42257415/2219998 ffmpeg -i $1 -i $2 -filter_complex hstack -vsync cfr -r:v 30 $INTERMEDIATE_FILE diff --git a/record_adb.py b/record_adb.py index f793ac1..0cb1600 100644 --- a/record_adb.py +++ b/record_adb.py @@ -15,10 +15,8 @@ # The consistency allows us to compare said video. def main(args): method = args.input - recording_name = './sdcard/output.mp4' + device_path = './sdcard/output.mp4' - if args.output is not None: - recording_name = './sdcard/' + args.output if method in 'touch' and (args.coordinate_x is None or args.coordinate_y is None): print('--touch requires --coordinate-x --coordinate-y to use the touch input') sys.exit() @@ -26,8 +24,14 @@ def main(args): # print('--intent requires --package ') # sys.exit() - check_for_existing_process() - record_process = subprocess.Popen(['adb', 'shell', 'screenrecord'] + [recording_name]) + kill_existing_processes("org.mozilla") + kill_existing_processes("com.android.chrome") + kill_existing_processes("org.chromium.chrome") + time.sleep(3) + + # Start the recording. screenrecord --bugreport puts timestamps at the top of the video and adds + # a frame with device information at the beginning. + record_process = subprocess.Popen(['adb', 'shell', 'screenrecord', '--bugreport'] + [device_path]) time.sleep(3) # TODO allow intent trigger @@ -35,7 +39,10 @@ def main(args): # record_with_intent(args.package) # else: simulate_input(args.coordinate_x, args.coordinate_y) - pull_recording(record_process, recording_name) + time.sleep(5) + record_process.kill() + time.sleep(5) + pull_recording(device_path, args.output) # def record_with_intent(package): # activity_start = subprocess.Popen(['adb', 'shell', 'am', 'start-activity', package +'/.App', @@ -48,28 +55,25 @@ def simulate_input(x, y): tap_event.wait() -def pull_recording(record_process, recording_name): - time.sleep(5) - record_process.kill() - time.sleep(5) - proc = subprocess.Popen(['adb', 'pull'] + [recording_name]) +def pull_recording(device_path, output): + proc = subprocess.Popen(['adb', 'pull', device_path, output]) proc.wait() -def check_for_existing_process(): +def kill_existing_processes(package_substr): adb_ps_command = subprocess.Popen(['adb', 'shell', 'ps', '-A', '-o', 'NAME'], stdout=subprocess.PIPE) try: - mozilla_processes = subprocess.check_output(('grep', 'org.mozilla'), stdin=adb_ps_command.stdout) + matching_processes = subprocess.check_output(('grep', package_substr), stdin=adb_ps_command.stdout) adb_ps_command.wait() - packages_found = mozilla_processes.decode('utf-8').split('\n') + packages_found = matching_processes.decode('utf-8').split('\n') for package in packages_found: - if package is '': + if package == '': continue kill_process = subprocess.Popen(['adb', 'shell', 'am', 'force-stop'] + [package]) kill_process.wait() print('Successfully killed process %s' % package) except subprocess.CalledProcessError as e: - print("no mozilla processes found") + print("no processes matching %s found, not killing any" % package_substr) return