parameters: (input_record, output_record)
docstring: Entrance of processing.
docstring_summary: Entrance of processing.
docstring_tokens: Entrance of processing .
function: def restore_record(input_record, output_record):
      """Entrance of processing."""
      # Define working dirs that store intermediate results in the middle of processing
      work_dir = 'restore_video_work_dir_{}'.format(
          datetime.datetime.fromtimestamp(time.time()).strftime('%Y-%m-%d-%H-%M-%S'))
  
      # Decode videos
      converters = {}
      for topic in VIDEO_CHANNELS:
          converters[topic] = VideoConverter(work_dir, topic)
  
      reader = RecordReader(input_record)
      for message in reader.read_messages():
          if message.topic in VIDEO_CHANNELS:
              converters[message.topic].write_frame(message)
  
      image_dir = os.path.join(work_dir, 'images')
      makedirs(image_dir)
      for topic in VIDEO_CHANNELS:
          converters[topic].close_writer()
          converters[topic].decode()
          converters[topic].move_images(image_dir)
  
      # Restore target record file
      writer = RecordWriter(0, 0)
      writer.open(output_record)
      topic_descs = {}
      counter = 0
      reader = RecordReader(input_record)
      for message in reader.read_messages():
          message_content = message.message
          message_topic = message.topic
          if message.topic in VIDEO_CHANNELS:
              message_content = retrieve_image(image_dir, message)
              message_topic = VIDEO_IMAGE_MAP[message.topic]
              if not message_content:
                  continue
          counter += 1
          if counter % 1000 == 0:
              logging.info('rewriting {} th message to record {}'.format(counter, output_record))
          writer.write_message(message_topic, message_content, message.timestamp)
          if message_topic not in topic_descs:
              topic_descs[message_topic] = reader.get_protodesc(message_topic)
              writer.write_channel(message_topic, message.data_type, topic_descs[message_topic])
      writer.close()
  
      logging.info('All Done, converted record: {}'.format(output_record))
function_tokens: def restore_record ( input_record , output_record ) : # Define working dirs that store intermediate results in the middle of processing work_dir = 'restore_video_work_dir_{}' . format ( datetime . datetime . fromtimestamp ( time . time ( ) ) . strftime ( '%Y-%m-%d-%H-%M-%S' ) ) # Decode videos converters = { } for topic in VIDEO_CHANNELS : converters [ topic ] = VideoConverter ( work_dir , topic ) reader = RecordReader ( input_record ) for message in reader . read_messages ( ) : if message . topic in VIDEO_CHANNELS : converters [ message . topic ] . write_frame ( message ) image_dir = os . path . join ( work_dir , 'images' ) makedirs ( image_dir ) for topic in VIDEO_CHANNELS : converters [ topic ] . close_writer ( ) converters [ topic ] . decode ( ) converters [ topic ] . move_images ( image_dir ) # Restore target record file writer = RecordWriter ( 0 , 0 ) writer . open ( output_record ) topic_descs = { } counter = 0 reader = RecordReader ( input_record ) for message in reader . read_messages ( ) : message_content = message . message message_topic = message . topic if message . topic in VIDEO_CHANNELS : message_content = retrieve_image ( image_dir , message ) message_topic = VIDEO_IMAGE_MAP [ message . topic ] if not message_content : continue counter += 1 if counter % 1000 == 0 : logging . info ( 'rewriting {} th message to record {}' . format ( counter , output_record ) ) writer . write_message ( message_topic , message_content , message . timestamp ) if message_topic not in topic_descs : topic_descs [ message_topic ] = reader . get_protodesc ( message_topic ) writer . write_channel ( message_topic , message . data_type , topic_descs [ message_topic ] ) writer . close ( ) logging . info ( 'All Done, converted record: {}' . format ( output_record ) )