Spaces:
Configuration error
Configuration error
Download third_party/InternVideo/InternVideo2/multi_modality/preprocess/utils.py from mazpie/genrl: direct link, hf CLI and curl.
- Browser
- Download file 499 Bytes
-
https://huggingface.co/spaces/mazpie/genrl/resolve/main/third_party/InternVideo/InternVideo2/multi_modality/preprocess/utils.py
- Command line
-
hf download hf://spaces/mazpie/genrl/third_party/InternVideo/InternVideo2/multi_modality/preprocess/utils.py
-
curl -L -o utils.py https://huggingface.co/spaces/mazpie/genrl/resolve/main/third_party/InternVideo/InternVideo2/multi_modality/preprocess/utils.py
499 Bytes
| import json | |
| import subprocess | |
| def get_video_duration(filename): | |
| result = subprocess.check_output( | |
| f'ffprobe -v quiet -show_streams -select_streams v:0 -of json "{filename}"', shell=True | |
| ).decode() | |
| fields = json.loads(result)["streams"][0] | |
| duration = float(fields["duration"]) | |
| return duration | |
| if __name__ == "__main__": | |
| import os | |
| fp = os.path.join(os.environ["SL_DATA_DIR"], "videos_images/webvid_10m_2fps_224/22920757.mp4") | |
| print(get_video_duration(fp)) | |