-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_all_vid_length.py
53 lines (47 loc) · 1.48 KB
/
get_all_vid_length.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import sys
import seaborn as sns
import os
from tqdm import tqdm
from itertools import combinations
from sklearn.preprocessing import StandardScaler
import numpy as np
import argparse
import matplotlib.pyplot as plt
import pandas as pd
import itertools
import subprocess
def get_length(input_video):
result = subprocess.run(
[
"ffprobe",
"-v",
"error",
"-show_entries",
"format=duration",
"-of",
"default=noprint_wrappers=1:nokey=1",
input_video,
],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
)
return float(result.stdout)
all_videos = pd.read_csv("all_videos.csv")
duration = list(map(lambda x: x[1]["end"] - x[1]["beg"], all_videos.iterrows()))
mean_duration = sum(duration) // len(duration)
db_path = "/mnt/d/gdrive/LibrasCorpus/Santa Catarina/Inventario Libras"
itens = os.listdir(db_path)
itens = list(map(lambda x: os.path.join(db_path, x), itens))
video_durations = []
for item in tqdm(itens):
videos = list(filter(lambda x: ".mp4" in x, os.listdir(item)))
videos = list(map(lambda x: os.path.join(item, x), videos))
for v in videos:
try:
video_durations.append(get_length(v))
except:
continue
mean_length = sum(video_durations) // len(video_durations)
print(sum(video_durations))
print(mean_length)
print(sorted(video_durations, reverse=True)[0])