Skip to content

Commit 57c3c09

Browse files
authored
fix #103, codec_name is not required since data stream won't have cod… (#104)
* fix #103, codec_name is not required since data stream won't have codec name * update snapshot * update snapshot
1 parent bf08f93 commit 57c3c09

13 files changed

+76
-9
lines changed

src/ffmpeg_media_type/info.py

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ def detect(uri: str | Path) -> MediaInfo:
6363

6464
# NOTE: handle ffmpeg's image compatibility
6565
if format_name == "image2":
66+
assert info.streams[0].codec_name
6667
format_name = info.streams[0].codec_name
6768

6869
# NOTE: detect file extension

src/ffmpeg_media_type/schema.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,9 @@ class FFProbeStream:
151151
"""
152152
The stream codec type.
153153
"""
154-
codec_name: str
154+
codec_name: str | None = None
155155
"""
156-
The stream codec name.
156+
The stream codec name. If the stream is a data stream, this field will be set to None
157157
"""
158158
codec_long_name: str | None = None
159159
"""
Binary file not shown.

src/ffmpeg_media_type/tests/__snapshots__/test_info/test_detect[188794898-eeb81e4b-b33a-4bdf-85a8-3b4b8460b88a.png].json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"duration": null,
2+
"duration": 0,
33
"format": "png_pipe",
44
"height": 259,
55
"size": 47210,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"duration": 89.6,
3+
"format": "mov,mp4,m4a,3gp,3g2,mj2",
4+
"height": 1080,
5+
"size": 15080282,
6+
"suggest_ext": "mp4",
7+
"type": "video",
8+
"width": 1920
9+
}

src/ffmpeg_media_type/tests/__snapshots__/test_info/test_detect[9c7ee468-24a3-4930-9832-73f0f6001ab1.webp].json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"duration": null,
2+
"duration": 0,
33
"format": "webp_pipe",
44
"height": 787,
55
"size": 55242,

src/ffmpeg_media_type/tests/__snapshots__/test_info/test_detect[animated-webp.webp].json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"duration": null,
2+
"duration": 0,
33
"format": "webp_pipe",
44
"height": 225,
55
"size": 4242,

src/ffmpeg_media_type/tests/__snapshots__/test_info/test_detect[cd89b1bf161582d55161f5ba94d03cc7728825c2.jpe].json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"duration": null,
2+
"duration": 0,
33
"format": "jpeg_pipe",
44
"height": 3144,
55
"size": 12642182,

src/ffmpeg_media_type/tests/__snapshots__/test_info/test_detect[lionic_vp8x_1109.webp].json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"duration": null,
2+
"duration": 0,
33
"format": "webp_pipe",
44
"height": 520,
55
"size": 344360,

src/ffmpeg_media_type/tests/__snapshots__/test_info/test_detect[maxresdefault.jpg-sdafdeagwdsadf].json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"duration": null,
2+
"duration": 0,
33
"format": "jpeg_pipe",
44
"height": 720,
55
"size": 99802,

src/ffmpeg_media_type/tests/__snapshots__/test_info/test_detect[overlay.png].json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"duration": null,
2+
"duration": 0,
33
"format": "png_pipe",
44
"height": 117,
55
"size": 2212,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"format": {
3+
"duration": "89.600000",
4+
"format_long_name": "QuickTime / MOV",
5+
"format_name": "mov,mp4,m4a,3gp,3g2,mj2",
6+
"probe_score": 100,
7+
"size": "15080282",
8+
"start_time": "0.000000"
9+
},
10+
"streams": [
11+
{
12+
"codec_long_name": "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10",
13+
"codec_name": "h264",
14+
"codec_type": "video",
15+
"height": 1080,
16+
"index": 0,
17+
"pix_fmt": "yuv420p",
18+
"profile": "High",
19+
"r_frame_rate": "30/1",
20+
"tags": {
21+
"rotate": 0
22+
},
23+
"width": 1920
24+
},
25+
{
26+
"codec_long_name": "AAC (Advanced Audio Coding)",
27+
"codec_name": "aac",
28+
"codec_type": "audio",
29+
"height": null,
30+
"index": 1,
31+
"pix_fmt": null,
32+
"profile": "LC",
33+
"r_frame_rate": "0/0",
34+
"tags": {
35+
"rotate": 0
36+
},
37+
"width": null
38+
},
39+
{
40+
"codec_long_name": null,
41+
"codec_name": null,
42+
"codec_type": "data",
43+
"height": null,
44+
"index": 2,
45+
"pix_fmt": null,
46+
"profile": null,
47+
"r_frame_rate": "0/0",
48+
"tags": {
49+
"rotate": 0
50+
},
51+
"width": null
52+
}
53+
]
54+
}

src/ffmpeg_media_type/utils/tests/__snapshots__/test_thumbnail.ambr

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
# name: test_thumbnail[201432913186_fish.gif]
99
True
1010
# ---
11+
# name: test_thumbnail[3c289a15d14d8b6775ec0a2cd233da70b963de5a.mp4]
12+
True
13+
# ---
1114
# name: test_thumbnail[4ox1IBJxK3cVd0uJA6gOtceSP3g.jpg]
1215
True
1316
# ---

0 commit comments

Comments
 (0)