Skip to content

Commit

Permalink
fix #34 should classify mp3 as audio (#35)
Browse files Browse the repository at this point in the history
* fix #34 should classify mp3 as audio

* fix pre-commit

* add 4.0 5.0 6.0 snapshot
  • Loading branch information
lucemia authored Oct 11, 2023
1 parent 1cee6c1 commit 64ea8c1
Show file tree
Hide file tree
Showing 8 changed files with 391 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ffmpeg_media_type/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def _guess_media_info(

for stream in info.streams:
# NOTE: if there is at least one video stream, the media is video
if stream.codec_type == "video":
if stream.codec_type == "video" and format_name not in ("mp3",):
width = stream.width
height = stream.height

Expand Down
11 changes: 11 additions & 0 deletions src/ffmpeg_media_type/tests/__snapshots__/4.0/test_info.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,17 @@
'width': 1280,
})
# ---
# name: test_detect[mp3-with-cover.mp3][mp3-with-cover.mp3]
dict({
'duration': 1.044898,
'format': 'mp3',
'height': 0,
'size': 677673,
'suggest_ext': 'mp3',
'type': 'audio',
'width': 0,
})
# ---
# name: test_detect[overlay.png][overlay.png]
dict({
'duration': 0.0,
Expand Down
11 changes: 11 additions & 0 deletions src/ffmpeg_media_type/tests/__snapshots__/5.0/test_info.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,17 @@
'width': 1280,
})
# ---
# name: test_detect[mp3-with-cover.mp3][mp3-with-cover.mp3]
dict({
'duration': 1.044898,
'format': 'mp3',
'height': 0,
'size': 677673,
'suggest_ext': 'mp3',
'type': 'audio',
'width': 0,
})
# ---
# name: test_detect[overlay.png][overlay.png]
dict({
'duration': 0.0,
Expand Down
11 changes: 11 additions & 0 deletions src/ffmpeg_media_type/tests/__snapshots__/6.0/test_info.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,17 @@
'width': 1280,
})
# ---
# name: test_detect[mp3-with-cover.mp3][mp3-with-cover.mp3]
dict({
'duration': 1.044898,
'format': 'mp3',
'height': 0,
'size': 677673,
'suggest_ext': 'mp3',
'type': 'audio',
'width': 0,
})
# ---
# name: test_detect[overlay.png][overlay.png]
dict({
'duration': 0.0,
Expand Down
112 changes: 112 additions & 0 deletions src/ffmpeg_media_type/utils/tests/__snapshots__/4.0/test_ffmpeg.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,118 @@
]),
})
# ---
# name: test_ffprobe_file[mp3-with-cover.mp3][mp3-with-cover.mp3]
dict({
'format': dict({
'bit_rate': '5188433',
'duration': 1.044898,
'format_long_name': None,
'format_name': 'mp3',
'nb_programs': 0,
'nb_streams': 2,
'probe_score': 51,
'size': 677673,
'start_time': 0.025056,
'tags': dict({
'comment': '',
'date': '2018',
'encoder': 'Lavf60.3.100',
}),
}),
'streams': list([
dict({
'avg_frame_rate': '0/0',
'bit_rate': '128000',
'bits_per_sample': 0,
'channel_layout': 'stereo',
'channels': 2,
'codec_long_name': 'unknown',
'codec_name': 'mp3',
'codec_tag': '0x0000',
'codec_tag_string': '[0][0][0][0]',
'codec_time_base': '1/44100',
'codec_type': 'audio',
'disposition': dict({
'attached_pic': 0,
'clean_effects': 0,
'comment': 0,
'default': 0,
'dub': 0,
'forced': 0,
'hearing_impaired': 0,
'karaoke': 0,
'lyrics': 0,
'original': 0,
'timed_thumbnails': 0,
'visual_impaired': 0,
}),
'duration': '1.044898',
'duration_ts': 14745600,
'height': None,
'index': 0,
'pix_fmt': None,
'profile': None,
'r_frame_rate': '0/0',
'sample_fmt': 'fltp',
'sample_rate': '44100',
'start_pts': 353600,
'start_time': '0.025057',
'tags': dict({
'encoder': 'Lavc60.3.',
'rotate': 0,
}),
'time_base': '1/14112000',
'width': None,
}),
dict({
'avg_frame_rate': '0/0',
'codec_long_name': 'unknown',
'codec_name': 'png',
'codec_tag': '0x0000',
'codec_tag_string': '[0][0][0][0]',
'codec_time_base': '0/1',
'codec_type': 'video',
'coded_height': 500,
'coded_width': 888,
'color_range': 'pc',
'display_aspect_ratio': '222:125',
'disposition': dict({
'attached_pic': 1,
'clean_effects': 0,
'comment': 0,
'default': 0,
'dub': 0,
'forced': 0,
'hearing_impaired': 0,
'karaoke': 0,
'lyrics': 0,
'original': 0,
'timed_thumbnails': 0,
'visual_impaired': 0,
}),
'duration': '1.044900',
'duration_ts': 94041,
'has_b_frames': 0,
'height': 500,
'index': 1,
'level': -99,
'pix_fmt': 'rgb24',
'profile': None,
'r_frame_rate': '90000/1',
'refs': 1,
'sample_aspect_ratio': '1:1',
'start_pts': 2255,
'start_time': '0.025056',
'tags': dict({
'comment': "32x32 pixels 'file icon'",
'rotate': 0,
}),
'time_base': '1/90000',
'width': 888,
}),
]),
})
# ---
# name: test_ffprobe_file[overlay.png][overlay.png]
dict({
'format': dict({
Expand Down
122 changes: 122 additions & 0 deletions src/ffmpeg_media_type/utils/tests/__snapshots__/5.0/test_ffmpeg.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -901,6 +901,128 @@
]),
})
# ---
# name: test_ffprobe_file[mp3-with-cover.mp3][mp3-with-cover.mp3]
dict({
'format': dict({
'bit_rate': '5188433',
'duration': 1.044898,
'format_long_name': None,
'format_name': 'mp3',
'nb_programs': 0,
'nb_streams': 2,
'probe_score': 51,
'size': 677673,
'start_time': 0.025056,
'tags': dict({
'comment': '',
'date': '2018',
'encoder': 'Lavf60.3.100',
}),
}),
'streams': list([
dict({
'avg_frame_rate': '0/0',
'bit_rate': '128000',
'bits_per_sample': 0,
'channel_layout': 'stereo',
'channels': 2,
'codec_long_name': 'unknown',
'codec_name': 'mp3',
'codec_tag': '0x0000',
'codec_tag_string': '[0][0][0][0]',
'codec_type': 'audio',
'disposition': dict({
'attached_pic': 0,
'captions': 0,
'clean_effects': 0,
'comment': 0,
'default': 0,
'dependent': 0,
'descriptions': 0,
'dub': 0,
'forced': 0,
'hearing_impaired': 0,
'karaoke': 0,
'lyrics': 0,
'metadata': 0,
'original': 0,
'still_image': 0,
'timed_thumbnails': 0,
'visual_impaired': 0,
}),
'duration': '1.044898',
'duration_ts': 14745600,
'height': None,
'index': 0,
'pix_fmt': None,
'profile': None,
'r_frame_rate': '0/0',
'sample_fmt': 'fltp',
'sample_rate': '44100',
'start_pts': 353600,
'start_time': '0.025057',
'tags': dict({
'encoder': 'Lavc60.3.',
'rotate': 0,
}),
'time_base': '1/14112000',
'width': None,
}),
dict({
'avg_frame_rate': '0/0',
'closed_captions': 0,
'codec_long_name': 'unknown',
'codec_name': 'png',
'codec_tag': '0x0000',
'codec_tag_string': '[0][0][0][0]',
'codec_type': 'video',
'coded_height': 500,
'coded_width': 888,
'color_range': 'pc',
'display_aspect_ratio': '222:125',
'disposition': dict({
'attached_pic': 1,
'captions': 0,
'clean_effects': 0,
'comment': 0,
'default': 0,
'dependent': 0,
'descriptions': 0,
'dub': 0,
'forced': 0,
'hearing_impaired': 0,
'karaoke': 0,
'lyrics': 0,
'metadata': 0,
'original': 0,
'still_image': 0,
'timed_thumbnails': 0,
'visual_impaired': 0,
}),
'duration': '1.044900',
'duration_ts': 94041,
'film_grain': 0,
'has_b_frames': 0,
'height': 500,
'index': 1,
'level': -99,
'pix_fmt': 'rgb24',
'profile': None,
'r_frame_rate': '90000/1',
'refs': 1,
'sample_aspect_ratio': '1:1',
'start_pts': 2255,
'start_time': '0.025056',
'tags': dict({
'comment': "32x32 pixels 'file icon'",
'rotate': 0,
}),
'time_base': '1/90000',
'width': 888,
}),
]),
})
# ---
# name: test_ffprobe_file[overlay.png][overlay.png]
dict({
'format': dict({
Expand Down
Loading

0 comments on commit 64ea8c1

Please sign in to comment.