|
@@ -40,39 +40,6 @@ def parsebag(f, output_dir, target_topic):
|
|
|
return count
|
|
|
|
|
|
|
|
|
-def main():
|
|
|
- input_dir = sys.argv[1]
|
|
|
-
|
|
|
- output_dir = sys.argv[2]
|
|
|
-
|
|
|
- topic = '/camera/color/image_raw'
|
|
|
-
|
|
|
- num_count = parsebag(input_dir, output_dir, topic)
|
|
|
- print("解析完成")
|
|
|
-
|
|
|
- dirt = os.path.join(output_dir, input_dir.split('/')[-1].split('.')[0] + '_' + 'image')
|
|
|
-
|
|
|
-
|
|
|
- bagtime = int(input_dir.split('/')[-1].split('.')[0].split('_')[-1])
|
|
|
- hz = str(float(num_count / bagtime))
|
|
|
- print(hz)
|
|
|
-
|
|
|
- command = ['ffmpeg', '-f', 'image2', '-r', hz, '-pattern_type', 'glob', '-i'] + [dirt + '/*.jpg'] + ['-tag:v',
|
|
|
- 'avc1',
|
|
|
- '-y'] + [
|
|
|
- dirt + '/camera.mp4']
|
|
|
- p = Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
|
- p.communicate()
|
|
|
- list1 = os.listdir(dirt)
|
|
|
- for i in list1:
|
|
|
- if i.split('.')[-1] == 'jpg':
|
|
|
- os.remove(os.path.join(dirt, i))
|
|
|
-
|
|
|
-
|
|
|
-if __name__ == '__main__':
|
|
|
- main()
|
|
|
-
|
|
|
-
|
|
|
def parse1(topic, input_bag_file, output_mp4_dir):
|
|
|
input_dir = input_bag_file
|
|
|
output_dir = output_mp4_dir
|