-
Notifications
You must be signed in to change notification settings - Fork 61
Expand file tree
/
Copy pathffprobe_test.py
More file actions
70 lines (63 loc) · 2.92 KB
/
ffprobe_test.py
File metadata and controls
70 lines (63 loc) · 2.92 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
from __future__ import print_function
import os
from ffprobe import FFProbe
from ffprobe.exceptions import FFProbeError
test_dir = os.path.dirname(os.path.abspath(__file__))
test_videos = [
os.path.join(test_dir, './data/SampleVideo_720x480_5mb.mp4'),
os.path.join(test_dir, './data/SampleVideo_1280x720_1mb.mp4'),
]
# Taken from https://bitmovin.com/mpeg-dash-hls-examples-sample-streams
test_streams = [
'https://bitdash-a.akamaihd.net/content/MI201109210084_1/m3u8s/f08e80da-bf1d-4e3d-8899-f0f6155f6efa.m3u8',
'https://bitdash-a.akamaihd.net/content/sintel/hls/playlist.m3u8'
]
def test_video ():
for test_video in test_videos:
media = FFProbe(test_video)
print('File:', test_video)
print('\tStreams:', len(media.streams))
for index, stream in enumerate(media.streams, 1):
print('\tStream: ', index)
try:
if stream.is_video():
frame_rate = stream.frames() / stream.duration_seconds()
print('\t\tFrame Rate :', frame_rate)
print('\t\tFrame Size :', stream.frame_size())
print('\t\tField order:', stream.field_order)
print('\t\tProgressive:', stream.is_progressive())
print('\t\tInterlaced :', stream.is_interlaced())
print('\t\tDuration:', stream.duration_seconds())
print('\t\tFrames:', stream.frames())
print('\t\tIs video:', stream.is_video())
if stream.is_audio():
print('\t\tAudio channel layout:', stream.audio_channel_layout())
except FFProbeError as e:
print(e)
except Exception as e:
print(e)
print(f"\tFormat:\n\t\tDuration: {media.format.duration}")
def test_stream ():
for test_stream in test_streams:
media = FFProbe(test_stream)
print('File:', test_stream)
print('\tStreams:', len(media.streams))
for index, stream in enumerate(media.streams, 1):
print('\tStream: ', index)
try:
if stream.is_video():
frame_rate = stream.frames() / stream.duration_seconds()
print('\t\tFrame Rate:', frame_rate)
print('\t\tFrame Size:', stream.frame_size())
print('\t\tField order:', stream.field_order)
print('\t\tProgressive:', stream.is_progressive())
print('\t\tInterlaced :', stream.is_interlaced())
print('\t\tDuration:', stream.duration_seconds())
print('\t\tFrames:', stream.frames())
print('\t\tIs video:', stream.is_video())
if stream.is_audio():
print('\t\tAudio channel layout:', stream.audio_channel_layout())
except FFProbeError as e:
print(e)
except Exception as e:
print(e)