File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env python
2
+ from __future__ import unicode_literals , print_function
3
+ import argparse
4
+ import ffmpeg
5
+ import sys
6
+
7
+
8
+ parser = argparse .ArgumentParser (description = 'Get video information' )
9
+ parser .add_argument ('in_filename' , help = 'Input filename' )
10
+
11
+
12
+ if __name__ == '__main__' :
13
+ args = parser .parse_args ()
14
+ probe = ffmpeg .probe (args .in_filename )
15
+ video_info = next ((stream for stream in probe ['streams' ] if stream ['codec_type' ] == 'video' ), None )
16
+ if video_info is None :
17
+ print ('No video stream found' , file = sys .stderr )
18
+ sys .exit (1 )
19
+
20
+ width = int (video_info ['width' ])
21
+ height = int (video_info ['height' ])
22
+ num_frames = int (video_info ['nb_frames' ])
23
+ print ('width: {}' .format (width ))
24
+ print ('height: {}' .format (height ))
25
+ print ('num_frames: {}' .format (num_frames ))
You can’t perform that action at this time.
0 commit comments