parameters: (options, test_file_name, test_file_location,
                            ref_file_name, ref_file_location)
docstring: Performs a horizontal flip of the reference video to match the test video.
  
    This is done to the match orientation and then crops the ref and test videos
    using the options.test_crop_parameters and options.ref_crop_parameters.
  
    Args:
      options(object): Contains all the provided command line options.
      test_file_name(string): Name of the test video file recording.
      test_file_location(string): Path to the test video file recording.
      ref_file_name(string): Name of the reference video file recording.
      ref_file_location(string): Path to the reference video file recording.
  
    Returns:
      recording_files_and_time(dict): key: value pair with the path to cropped
          test and reference video files.
  
    Raises:
      FfmpegError: If the ffmpeg command fails.
docstring_summary: Performs a horizontal flip of the reference video to match the test video.
docstring_tokens: Performs a horizontal flip of the reference video to match the test video .
function: def FlipAndCropRecordings(options, test_file_name, test_file_location,
                            ref_file_name, ref_file_location):
    """Performs a horizontal flip of the reference video to match the test video.
  
    This is done to the match orientation and then crops the ref and test videos
    using the options.test_crop_parameters and options.ref_crop_parameters.
  
    Args:
      options(object): Contains all the provided command line options.
      test_file_name(string): Name of the test video file recording.
      test_file_location(string): Path to the test video file recording.
      ref_file_name(string): Name of the reference video file recording.
      ref_file_location(string): Path to the reference video file recording.
  
    Returns:
      recording_files_and_time(dict): key: value pair with the path to cropped
          test and reference video files.
  
    Raises:
      FfmpegError: If the ffmpeg command fails.
    """
    print 'Trying to crop videos...'
  
    # Ref file cropping.
    cropped_ref_file_name = 'cropped_' + ref_file_name
    cropped_ref_file = os.path.abspath(
        os.path.join(ref_file_location, cropped_ref_file_name))
  
    ref_video_crop_cmd = [
      options.ffmpeg,
      '-v', 'error',
      '-s', '%dx%d' % (options.frame_width, options.frame_height),
      '-i', '%s' % os.path.join(ref_file_location, ref_file_name),
      '-vf', '%s' % options.ref_crop_parameters,
      '-c:a', 'copy',
      cropped_ref_file
    ]
  
    # Test file cropping.
    cropped_test_file_name = 'cropped_' + test_file_name
    cropped_test_file = os.path.abspath(
        os.path.join(test_file_location, cropped_test_file_name))
  
    test_video_crop_cmd = [
      options.ffmpeg,
      '-v', 'error',
      '-s', '%dx%d' % (options.frame_width, options.frame_height),
      '-i', '%s' % os.path.join(test_file_location, test_file_name),
      '-vf', '%s' % options.test_crop_parameters,
      '-c:a', 'copy',
      cropped_test_file
    ]
  
    ref_crop = subprocess.Popen(ref_video_crop_cmd)
    ref_crop.wait()
    test_crop = subprocess.Popen(test_video_crop_cmd)
    test_crop.wait()
  
    # ffmpeg does not abort when it fails, need to check return code.
    if ref_crop.returncode != 0 or test_crop.returncode != 0:
      # Cleanup recording directories.
      shutil.rmtree(ref_file_location)
      shutil.rmtree(test_file_location)
      raise FfmpegError('Cropping failed, check ffmpeg output.')
    else:
      print 'Ref file cropped to: ' + cropped_ref_file
      print 'Test file cropped to: ' + cropped_test_file
      print 'Cropping done!\n'
  
      # Need to return these so they can be used by other parts.
      cropped_recordings = {
        'cropped_test_file' : cropped_test_file,
        'cropped_ref_file' : cropped_ref_file
      }
      return cropped_recordings
function_tokens: def FlipAndCropRecordings ( options , test_file_name , test_file_location , ref_file_name , ref_file_location ) : print 'Trying to crop videos...' # Ref file cropping. cropped_ref_file_name = 'cropped_' + ref_file_name cropped_ref_file = os . path . abspath ( os . path . join ( ref_file_location , cropped_ref_file_name ) ) ref_video_crop_cmd = [ options . ffmpeg , '-v' , 'error' , '-s' , '%dx%d' % ( options . frame_width , options . frame_height ) , '-i' , '%s' % os . path . join ( ref_file_location , ref_file_name ) , '-vf' , '%s' % options . ref_crop_parameters , '-c:a' , 'copy' , cropped_ref_file ] # Test file cropping. cropped_test_file_name = 'cropped_' + test_file_name cropped_test_file = os . path . abspath ( os . path . join ( test_file_location , cropped_test_file_name ) ) test_video_crop_cmd = [ options . ffmpeg , '-v' , 'error' , '-s' , '%dx%d' % ( options . frame_width , options . frame_height ) , '-i' , '%s' % os . path . join ( test_file_location , test_file_name ) , '-vf' , '%s' % options . test_crop_parameters , '-c:a' , 'copy' , cropped_test_file ] ref_crop = subprocess . Popen ( ref_video_crop_cmd ) ref_crop . wait ( ) test_crop = subprocess . Popen ( test_video_crop_cmd ) test_crop . wait ( ) # ffmpeg does not abort when it fails, need to check return code. if ref_crop . returncode != 0 or test_crop . returncode != 0 : # Cleanup recording directories. shutil . rmtree ( ref_file_location ) shutil . rmtree ( test_file_location ) raise FfmpegError ( 'Cropping failed, check ffmpeg output.' ) else : print 'Ref file cropped to: ' + cropped_ref_file print 'Test file cropped to: ' + cropped_test_file print 'Cropping done!\n' # Need to return these so they can be used by other parts. cropped_recordings = { 'cropped_test_file' : cropped_test_file , 'cropped_ref_file' : cropped_ref_file } return cropped_recordings