diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2020-05-30 17:27:04 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2020-05-30 17:27:04 +0200 |
| commit | 0890fdd951d021308550a0db2e7b6f2593512957 (patch) | |
| tree | a0050b153242ccde662fc0a957a79fc7a7edc4b4 /cli/app/utils/video_utils.py | |
initial site copied in
Diffstat (limited to 'cli/app/utils/video_utils.py')
| -rw-r--r-- | cli/app/utils/video_utils.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/cli/app/utils/video_utils.py b/cli/app/utils/video_utils.py new file mode 100644 index 0000000..992f0f8 --- /dev/null +++ b/cli/app/utils/video_utils.py @@ -0,0 +1,23 @@ + +from pymediainfo import MediaInfo + +def mediainfo(fp_in): + """Returns abbreviated video/audio metadata for video files + :param fp_in: filepath""" + + result = {} + media_info_raw = MediaInfo.parse(fp_in).to_data() + + for d in media_info_raw['tracks']: + if d['track_type'] == 'Video': + result = { + 'codec_cc': d['codec_cc'], + 'duration': int(d['duration']), + 'display_aspect_ratio': float(d['display_aspect_ratio']), + 'width': int(d['width']), + 'height': int(d['height']), + 'frame_rate': float(d['frame_rate']), + 'frame_count': int(d['frame_count']), + } + + return result
\ No newline at end of file |
