def extract(self, bag_file, topics, tmp_dir, output_dir, product_factory):
    video_file = (output_dir + '/output.mp4')
    xdisplay_id = 99
    logo_file = ((self._resource_directory + '/') + self._configuration['logo'])
    font_file = ((self._resource_directory + '/') + self._configuration['font'])
    rviz_file = ((self._resource_directory + '/') + self._configuration['rviz_file'])
    if self.config('rewrite_rviz_file'):
        rviz_file = self._rewrite_rviz_file(rviz_file, tmp_dir)
    if os.path.exists(video_file):
        return False
    name = os.path.basename(bag_file)
    rviz_name = os.path.basename(self._configuration['rviz_file'])
    text = ((((name + ' | ') + rviz_name) + ' | ') + str(datetime.datetime.today()))
    self._logger.info(('Video id: ' + text))
    xephyr_size = ('%dx%d' % (self.config('width'), self.config('height')))
    xephyr_cmd = ('Xephyr -ac -nocursor -screen %s -br -reset -terminate :%d' % (xephyr_size, xdisplay_id))
    xvfb_size = ('%dx%dx%d' % (self.config('width'), self.config('height'), self.config('color_depth')))
    xvfb_cmd = ('Xvfb :%d -screen 0 %s' % (xdisplay_id, xvfb_size))
    roscore_cmd = 'roscore'
    rosbag_player_cmd = ('rosbag play --clock --hz 1000 -q %s' % bag_file)
    rviz_splash_option = ''
    if self.config('splash_screen'):
        rviz_splash_option = (' -s %s' % ((self._resource_directory + '/') + self.config('splash_screen')))
    if (os.environ.get('DISPLAY') is not None):
        rviz_vgl_cmd = ('vglrun -- rviz -d %s%s' % (rviz_file, rviz_splash_option))
    else:
        rviz_vgl_cmd = ('rviz -d %s%s' % (rviz_file, rviz_splash_option))
    ffmpeg_grab_size = ('%dx%d' % (self.config('width'), self.config('height')))
    ffmpeg_cmd = ('ffmpeg -loglevel warning -video_size %s -framerate 25 -f x11grab -i :%d.0+0,0 -i %s -filter_complex "overlay=%d:%d,drawtext=text=\\\'%s\\\':x=%d:y=%d:fontfile=%s:fontsize=16:fontcolor=white:shadowcolor=black:shadowx=2:shadowy=2" -movflags +faststart %s' % (ffmpeg_grab_size, xdisplay_id, logo_file, self._configuration['logo_x'], self._configuration['logo_y'], text, self._configuration['text_x'], self._configuration['text_y'], font_file, (output_dir + '/output.mp4')))
    self._logger.info(ffmpeg_cmd)
    cmd_group = CommandGroup()
    try:
        roscore = cmd_group.Command(roscore_cmd)
        if (os.environ.get('RBB_HEADLESS') == 'force'):
            headless = True
        else:
            headless = self.config('headless')
            if (headless == 'auto'):
                headless = (os.environ.get('RBB_HEADLESS') == 1)
        if headless:
            print('Running in headless mode! (Xvfb)')
            framebuffer = cmd_group.Command(xvfb_cmd)
        else:
            framebuffer = cmd_group.Command(xephyr_cmd)
        rviz = cmd_group.Command(rviz_vgl_cmd, {'DISPLAY': (':%d.0' % xdisplay_id)})
        ffmpeg = cmd_group.Command(ffmpeg_cmd)
        rosbag_player = cmd_group.Command(rosbag_player_cmd)
        move_mouse = cmd_group.Command(('xdotool mousemove %d %d' % (self.config('width'), self.config('height'))), {'DISPLAY': (':%d.0' % xdisplay_id)})
        rosparam_sim_time = cmd_group.Command('rosparam set use_sim_time true')
        roscore.run()
        framebuffer.run()
        time.sleep(1)
        if (roscore.is_running() and framebuffer.is_running()):
            self._logger.info('Roscore&Xephyr up!')
            rviz.run()
            ffmpeg.run()
            time.sleep(0.5)
            if (rviz.is_running() and ffmpeg.is_running()):
                move_mouse.run()
                rosparam_sim_time.run()
                self._logger.info('Rviz&ffmpeg up!')
                rosbag_player.run()
                while (rosbag_player.is_running() and rviz.is_running()):
                    time.sleep(1)
                ffmpeg.send_sigint()
                ffmpeg.join()
        else:
            self._logger.failure('Couldnt start roscore or xephyr')
    finally:
        cmd_group.ensure_terminated()
    product = product_factory.new()
    product.set_type('video')
    product.set_title(self.config('title'))
    product.set_topics(topics)
    product.add_file('video.mp4', 'output.mp4', mime='video/mp4')
    return [product]
def extract(self, bag_file, topics, tmp_dir, output_dir, product_factory):
    video_file = (output_dir + '/output.mp4')
    xdisplay_id = 99
    logo_file = ((self._resource_directory + '/') + self._configuration['logo'])
    font_file = ((self._resource_directory + '/') + self._configuration['font'])
    rviz_file = ((self._resource_directory + '/') + self._configuration['rviz_file'])
    if self.config('rewrite_rviz_file'):
        rviz_file = self._rewrite_rviz_file(rviz_file, tmp_dir)
    if os.path.exists(video_file):
        return False
    name = os.path.basename(bag_file)
    rviz_name = os.path.basename(self._configuration['rviz_file'])
    text = ((((name + ' | ') + rviz_name) + ' | ') + str(datetime.datetime.today()))
    self._logger.info(('Video id: ' + text))
    xephyr_size = ('%dx%d' % (self.config('width'), self.config('height')))
    xephyr_cmd = ('Xephyr -ac -nocursor -screen %s -br -reset -terminate :%d' % (xephyr_size, xdisplay_id))
    xvfb_size = ('%dx%dx%d' % (self.config('width'), self.config('height'), self.config('color_depth')))
    xvfb_cmd = ('Xvfb :%d -screen 0 %s' % (xdisplay_id, xvfb_size))
    roscore_cmd = 'roscore'
    rosbag_player_cmd = ('rosbag play --clock --hz 1000 -q %s' % bag_file)
    rviz_splash_option = 
    if self.config('splash_screen'):
        rviz_splash_option = (' -s %s' % ((self._resource_directory + '/') + self.config('splash_screen')))
    if (os.environ.get('DISPLAY') is not None):
        rviz_vgl_cmd = ('vglrun -- rviz -d %s%s' % (rviz_file, rviz_splash_option))
    else:
        rviz_vgl_cmd = ('rviz -d %s%s' % (rviz_file, rviz_splash_option))
    ffmpeg_grab_size = ('%dx%d' % (self.config('width'), self.config('height')))
    ffmpeg_cmd = ('ffmpeg -loglevel warning -video_size %s -framerate 25 -f x11grab -i :%d.0+0,0 -i %s -filter_complex "overlay=%d:%d,drawtext=text=\\\'%s\\\':x=%d:y=%d:fontfile=%s:fontsize=16:fontcolor=white:shadowcolor=black:shadowx=2:shadowy=2" -movflags +faststart %s' % (ffmpeg_grab_size, xdisplay_id, logo_file, self._configuration['logo_x'], self._configuration['logo_y'], text, self._configuration['text_x'], self._configuration['text_y'], font_file, (output_dir + '/output.mp4')))
    self._logger.info(ffmpeg_cmd)
    cmd_group = CommandGroup()
    try:
        roscore = cmd_group.Command(roscore_cmd)
        if (os.environ.get('RBB_HEADLESS') == 'force'):
            headless = True
        else:
            headless = self.config('headless')
            if (headless == 'auto'):
                headless = (os.environ.get('RBB_HEADLESS') == 1)
        if headless:
            print('Running in headless mode! (Xvfb)')
            framebuffer = cmd_group.Command(xvfb_cmd)
        else:
            framebuffer = cmd_group.Command(xephyr_cmd)
        rviz = cmd_group.Command(rviz_vgl_cmd, {'DISPLAY': (':%d.0' % xdisplay_id)})
        ffmpeg = cmd_group.Command(ffmpeg_cmd)
        rosbag_player = cmd_group.Command(rosbag_player_cmd)
        move_mouse = cmd_group.Command(('xdotool mousemove %d %d' % (self.config('width'), self.config('height'))), {'DISPLAY': (':%d.0' % xdisplay_id)})
        rosparam_sim_time = cmd_group.Command('rosparam set use_sim_time true')
        roscore.run()
        framebuffer.run()
        time.sleep(1)
        if (roscore.is_running() and framebuffer.is_running()):
            self._logger.info('Roscore&Xephyr up!')
            rviz.run()
            ffmpeg.run()
            time.sleep(0.5)
            if (rviz.is_running() and ffmpeg.is_running()):
                move_mouse.run()
                rosparam_sim_time.run()
                self._logger.info('Rviz&ffmpeg up!')
                rosbag_player.run()
                while (rosbag_player.is_running() and rviz.is_running()):
                    time.sleep(1)
                ffmpeg.send_sigint()
                ffmpeg.join()
        else:
            self._logger.failure('Couldnt start roscore or xephyr')
    finally:
        cmd_group.ensure_terminated()
    product = product_factory.new()
    product.set_type('video')
    product.set_title(self.config('title'))
    product.set_topics(topics)
    product.add_file('video.mp4', 'output.mp4', mime='video/mp4')
    return [product]