Skip to content

Commit 64ea8c1

Browse files
authored
fix #34 should classify mp3 as audio (#35)
* fix #34 should classify mp3 as audio * fix pre-commit * add 4.0 5.0 6.0 snapshot
1 parent 1cee6c1 commit 64ea8c1

File tree

8 files changed

+391
-1
lines changed

8 files changed

+391
-1
lines changed

src/ffmpeg_media_type/info.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def _guess_media_info(
104104

105105
for stream in info.streams:
106106
# NOTE: if there is at least one video stream, the media is video
107-
if stream.codec_type == "video":
107+
if stream.codec_type == "video" and format_name not in ("mp3",):
108108
width = stream.width
109109
height = stream.height
110110

src/ffmpeg_media_type/tests/__snapshots__/4.0/test_info.ambr

+11
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,17 @@
120120
'width': 1280,
121121
})
122122
# ---
123+
# name: test_detect[mp3-with-cover.mp3][mp3-with-cover.mp3]
124+
dict({
125+
'duration': 1.044898,
126+
'format': 'mp3',
127+
'height': 0,
128+
'size': 677673,
129+
'suggest_ext': 'mp3',
130+
'type': 'audio',
131+
'width': 0,
132+
})
133+
# ---
123134
# name: test_detect[overlay.png][overlay.png]
124135
dict({
125136
'duration': 0.0,

src/ffmpeg_media_type/tests/__snapshots__/5.0/test_info.ambr

+11
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,17 @@
120120
'width': 1280,
121121
})
122122
# ---
123+
# name: test_detect[mp3-with-cover.mp3][mp3-with-cover.mp3]
124+
dict({
125+
'duration': 1.044898,
126+
'format': 'mp3',
127+
'height': 0,
128+
'size': 677673,
129+
'suggest_ext': 'mp3',
130+
'type': 'audio',
131+
'width': 0,
132+
})
133+
# ---
123134
# name: test_detect[overlay.png][overlay.png]
124135
dict({
125136
'duration': 0.0,

src/ffmpeg_media_type/tests/__snapshots__/6.0/test_info.ambr

+11
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,17 @@
120120
'width': 1280,
121121
})
122122
# ---
123+
# name: test_detect[mp3-with-cover.mp3][mp3-with-cover.mp3]
124+
dict({
125+
'duration': 1.044898,
126+
'format': 'mp3',
127+
'height': 0,
128+
'size': 677673,
129+
'suggest_ext': 'mp3',
130+
'type': 'audio',
131+
'width': 0,
132+
})
133+
# ---
123134
# name: test_detect[overlay.png][overlay.png]
124135
dict({
125136
'duration': 0.0,

src/ffmpeg_media_type/utils/tests/__snapshots__/4.0/test_ffmpeg.ambr

+112
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,118 @@
794794
]),
795795
})
796796
# ---
797+
# name: test_ffprobe_file[mp3-with-cover.mp3][mp3-with-cover.mp3]
798+
dict({
799+
'format': dict({
800+
'bit_rate': '5188433',
801+
'duration': 1.044898,
802+
'format_long_name': None,
803+
'format_name': 'mp3',
804+
'nb_programs': 0,
805+
'nb_streams': 2,
806+
'probe_score': 51,
807+
'size': 677673,
808+
'start_time': 0.025056,
809+
'tags': dict({
810+
'comment': '',
811+
'date': '2018',
812+
'encoder': 'Lavf60.3.100',
813+
}),
814+
}),
815+
'streams': list([
816+
dict({
817+
'avg_frame_rate': '0/0',
818+
'bit_rate': '128000',
819+
'bits_per_sample': 0,
820+
'channel_layout': 'stereo',
821+
'channels': 2,
822+
'codec_long_name': 'unknown',
823+
'codec_name': 'mp3',
824+
'codec_tag': '0x0000',
825+
'codec_tag_string': '[0][0][0][0]',
826+
'codec_time_base': '1/44100',
827+
'codec_type': 'audio',
828+
'disposition': dict({
829+
'attached_pic': 0,
830+
'clean_effects': 0,
831+
'comment': 0,
832+
'default': 0,
833+
'dub': 0,
834+
'forced': 0,
835+
'hearing_impaired': 0,
836+
'karaoke': 0,
837+
'lyrics': 0,
838+
'original': 0,
839+
'timed_thumbnails': 0,
840+
'visual_impaired': 0,
841+
}),
842+
'duration': '1.044898',
843+
'duration_ts': 14745600,
844+
'height': None,
845+
'index': 0,
846+
'pix_fmt': None,
847+
'profile': None,
848+
'r_frame_rate': '0/0',
849+
'sample_fmt': 'fltp',
850+
'sample_rate': '44100',
851+
'start_pts': 353600,
852+
'start_time': '0.025057',
853+
'tags': dict({
854+
'encoder': 'Lavc60.3.',
855+
'rotate': 0,
856+
}),
857+
'time_base': '1/14112000',
858+
'width': None,
859+
}),
860+
dict({
861+
'avg_frame_rate': '0/0',
862+
'codec_long_name': 'unknown',
863+
'codec_name': 'png',
864+
'codec_tag': '0x0000',
865+
'codec_tag_string': '[0][0][0][0]',
866+
'codec_time_base': '0/1',
867+
'codec_type': 'video',
868+
'coded_height': 500,
869+
'coded_width': 888,
870+
'color_range': 'pc',
871+
'display_aspect_ratio': '222:125',
872+
'disposition': dict({
873+
'attached_pic': 1,
874+
'clean_effects': 0,
875+
'comment': 0,
876+
'default': 0,
877+
'dub': 0,
878+
'forced': 0,
879+
'hearing_impaired': 0,
880+
'karaoke': 0,
881+
'lyrics': 0,
882+
'original': 0,
883+
'timed_thumbnails': 0,
884+
'visual_impaired': 0,
885+
}),
886+
'duration': '1.044900',
887+
'duration_ts': 94041,
888+
'has_b_frames': 0,
889+
'height': 500,
890+
'index': 1,
891+
'level': -99,
892+
'pix_fmt': 'rgb24',
893+
'profile': None,
894+
'r_frame_rate': '90000/1',
895+
'refs': 1,
896+
'sample_aspect_ratio': '1:1',
897+
'start_pts': 2255,
898+
'start_time': '0.025056',
899+
'tags': dict({
900+
'comment': "32x32 pixels 'file icon'",
901+
'rotate': 0,
902+
}),
903+
'time_base': '1/90000',
904+
'width': 888,
905+
}),
906+
]),
907+
})
908+
# ---
797909
# name: test_ffprobe_file[overlay.png][overlay.png]
798910
dict({
799911
'format': dict({

src/ffmpeg_media_type/utils/tests/__snapshots__/5.0/test_ffmpeg.ambr

+122
Original file line numberDiff line numberDiff line change
@@ -901,6 +901,128 @@
901901
]),
902902
})
903903
# ---
904+
# name: test_ffprobe_file[mp3-with-cover.mp3][mp3-with-cover.mp3]
905+
dict({
906+
'format': dict({
907+
'bit_rate': '5188433',
908+
'duration': 1.044898,
909+
'format_long_name': None,
910+
'format_name': 'mp3',
911+
'nb_programs': 0,
912+
'nb_streams': 2,
913+
'probe_score': 51,
914+
'size': 677673,
915+
'start_time': 0.025056,
916+
'tags': dict({
917+
'comment': '',
918+
'date': '2018',
919+
'encoder': 'Lavf60.3.100',
920+
}),
921+
}),
922+
'streams': list([
923+
dict({
924+
'avg_frame_rate': '0/0',
925+
'bit_rate': '128000',
926+
'bits_per_sample': 0,
927+
'channel_layout': 'stereo',
928+
'channels': 2,
929+
'codec_long_name': 'unknown',
930+
'codec_name': 'mp3',
931+
'codec_tag': '0x0000',
932+
'codec_tag_string': '[0][0][0][0]',
933+
'codec_type': 'audio',
934+
'disposition': dict({
935+
'attached_pic': 0,
936+
'captions': 0,
937+
'clean_effects': 0,
938+
'comment': 0,
939+
'default': 0,
940+
'dependent': 0,
941+
'descriptions': 0,
942+
'dub': 0,
943+
'forced': 0,
944+
'hearing_impaired': 0,
945+
'karaoke': 0,
946+
'lyrics': 0,
947+
'metadata': 0,
948+
'original': 0,
949+
'still_image': 0,
950+
'timed_thumbnails': 0,
951+
'visual_impaired': 0,
952+
}),
953+
'duration': '1.044898',
954+
'duration_ts': 14745600,
955+
'height': None,
956+
'index': 0,
957+
'pix_fmt': None,
958+
'profile': None,
959+
'r_frame_rate': '0/0',
960+
'sample_fmt': 'fltp',
961+
'sample_rate': '44100',
962+
'start_pts': 353600,
963+
'start_time': '0.025057',
964+
'tags': dict({
965+
'encoder': 'Lavc60.3.',
966+
'rotate': 0,
967+
}),
968+
'time_base': '1/14112000',
969+
'width': None,
970+
}),
971+
dict({
972+
'avg_frame_rate': '0/0',
973+
'closed_captions': 0,
974+
'codec_long_name': 'unknown',
975+
'codec_name': 'png',
976+
'codec_tag': '0x0000',
977+
'codec_tag_string': '[0][0][0][0]',
978+
'codec_type': 'video',
979+
'coded_height': 500,
980+
'coded_width': 888,
981+
'color_range': 'pc',
982+
'display_aspect_ratio': '222:125',
983+
'disposition': dict({
984+
'attached_pic': 1,
985+
'captions': 0,
986+
'clean_effects': 0,
987+
'comment': 0,
988+
'default': 0,
989+
'dependent': 0,
990+
'descriptions': 0,
991+
'dub': 0,
992+
'forced': 0,
993+
'hearing_impaired': 0,
994+
'karaoke': 0,
995+
'lyrics': 0,
996+
'metadata': 0,
997+
'original': 0,
998+
'still_image': 0,
999+
'timed_thumbnails': 0,
1000+
'visual_impaired': 0,
1001+
}),
1002+
'duration': '1.044900',
1003+
'duration_ts': 94041,
1004+
'film_grain': 0,
1005+
'has_b_frames': 0,
1006+
'height': 500,
1007+
'index': 1,
1008+
'level': -99,
1009+
'pix_fmt': 'rgb24',
1010+
'profile': None,
1011+
'r_frame_rate': '90000/1',
1012+
'refs': 1,
1013+
'sample_aspect_ratio': '1:1',
1014+
'start_pts': 2255,
1015+
'start_time': '0.025056',
1016+
'tags': dict({
1017+
'comment': "32x32 pixels 'file icon'",
1018+
'rotate': 0,
1019+
}),
1020+
'time_base': '1/90000',
1021+
'width': 888,
1022+
}),
1023+
]),
1024+
})
1025+
# ---
9041026
# name: test_ffprobe_file[overlay.png][overlay.png]
9051027
dict({
9061028
'format': dict({

0 commit comments

Comments
 (0)