|
1 | 1 | from __future__ import print_function |
2 | 2 |
|
3 | 3 | import os |
| 4 | +import pytest |
4 | 5 | from ffprobe import FFProbe |
5 | 6 | from ffprobe.exceptions import FFProbeError |
6 | 7 |
|
7 | 8 | test_dir = os.path.dirname(os.path.abspath(__file__)) |
8 | 9 |
|
9 | 10 | test_videos = [ |
10 | | - os.path.join(test_dir, './data/SampleVideo_720x480_5mb.mp4'), |
11 | | - os.path.join(test_dir, './data/SampleVideo_1280x720_1mb.mp4'), |
| 11 | + # os.path.join(test_dir, './data/SampleVideo_720x480_5mb.mp4'), |
| 12 | + # os.path.join(test_dir, './data/SampleVideo_1280x720_1mb.mp4'), |
| 13 | + # os.path.join(test_dir, './data/landscape.mov'), |
| 14 | + os.path.join(test_dir, './data/portrait.mov'), |
12 | 15 | ] |
13 | 16 |
|
14 | 17 | # Taken from https://bitmovin.com/mpeg-dash-hls-examples-sample-streams |
|
17 | 20 | 'https://bitdash-a.akamaihd.net/content/sintel/hls/playlist.m3u8' |
18 | 21 | ] |
19 | 22 |
|
20 | | -def test_video (): |
21 | | - for test_video in test_videos: |
22 | | - media = FFProbe(test_video) |
23 | | - print('File:', test_video) |
24 | | - print('\tStreams:', len(media.streams)) |
25 | | - for index, stream in enumerate(media.streams, 1): |
26 | | - print('\tStream: ', index) |
27 | | - try: |
28 | | - if stream.is_video(): |
29 | | - frame_rate = stream.frames() / stream.duration_seconds() |
30 | | - print('\t\tFrame Rate:', frame_rate) |
31 | | - print('\t\tFrame Size:', stream.frame_size()) |
32 | | - print('\t\tDuration:', stream.duration_seconds()) |
33 | | - print('\t\tFrames:', stream.frames()) |
34 | | - print('\t\tIs video:', stream.is_video()) |
35 | | - except FFProbeError as e: |
36 | | - print(e) |
37 | | - except Exception as e: |
38 | | - print(e) |
39 | | - |
40 | | -def test_stream (): |
41 | | - for test_stream in test_streams: |
42 | | - media = FFProbe(test_stream) |
43 | | - print('File:', test_stream) |
44 | | - print('\tStreams:', len(media.streams)) |
45 | | - for index, stream in enumerate(media.streams, 1): |
46 | | - print('\tStream: ', index) |
47 | | - try: |
48 | | - if stream.is_video(): |
49 | | - frame_rate = stream.frames() / stream.duration_seconds() |
50 | | - print('\t\tFrame Rate:', frame_rate) |
51 | | - print('\t\tFrame Size:', stream.frame_size()) |
52 | | - print('\t\tDuration:', stream.duration_seconds()) |
53 | | - print('\t\tFrames:', stream.frames()) |
54 | | - print('\t\tIs video:', stream.is_video()) |
55 | | - except FFProbeError as e: |
56 | | - print(e) |
57 | | - except Exception as e: |
58 | | - print(e) |
| 23 | + |
| 24 | +class TestFfprobe: |
| 25 | + |
| 26 | + def test_video(self): |
| 27 | + for test_video in test_videos: |
| 28 | + media = FFProbe(test_video) |
| 29 | + print('File:', test_video) |
| 30 | + print('\tStreams:', len(media.streams)) |
| 31 | + for index, stream in enumerate(media.streams, 1): |
| 32 | + print('\tStream: ', index) |
| 33 | + try: |
| 34 | + if stream.is_video(): |
| 35 | + frame_rate = stream.frames() / stream.duration_seconds() |
| 36 | + print('\t\tFrame Rate:', frame_rate) |
| 37 | + print('\t\tFrame Size:', stream.frame_size()) |
| 38 | + print('\t\tDuration:', stream.duration_seconds()) |
| 39 | + print('\t\tFrames:', stream.frames()) |
| 40 | + print('\t\tIs video:', stream.is_video()) |
| 41 | + print('\t\tRotation:', stream.frame_rotation()) |
| 42 | + except FFProbeError as e: |
| 43 | + print(e) |
| 44 | + except Exception as e: |
| 45 | + print(e) |
| 46 | + |
| 47 | + @pytest.mark.skip(reason="stream data no longer exists") |
| 48 | + def test_stream(self): |
| 49 | + for test_stream in test_streams: |
| 50 | + media = FFProbe(test_stream) |
| 51 | + print('File:', test_stream) |
| 52 | + print('\tStreams:', len(media.streams)) |
| 53 | + for index, stream in enumerate(media.streams, 1): |
| 54 | + print('\tStream: ', index) |
| 55 | + try: |
| 56 | + if stream.is_video(): |
| 57 | + frame_rate = stream.frames() / stream.duration_seconds() |
| 58 | + print('\t\tFrame Rate:', frame_rate) |
| 59 | + print('\t\tFrame Size:', stream.frame_size()) |
| 60 | + print('\t\tDuration:', stream.duration_seconds()) |
| 61 | + print('\t\tFrames:', stream.frames()) |
| 62 | + print('\t\tIs video:', stream.is_video()) |
| 63 | + print('\t\tRotation:', stream.rotation) |
| 64 | + except FFProbeError as e: |
| 65 | + print(e) |
| 66 | + except Exception as e: |
| 67 | + print(e) |
0 commit comments