@@ -75,6 +75,13 @@ describe('codecs test suite', () => {
7575 } ) ) . equals ( 'audio/mpeg' ) ;
7676 } ) ;
7777
78+ it ( 'detects M4A audio' , ( ) => {
79+ expect ( getShortMIMEString ( {
80+ format : { filename : 'sample.m4a' , format_name : 'mov,mp4,m4a,3gp,3g2,mj2' } ,
81+ streams : [ { codec_type : 'video' , } , { codec_type : 'audio' } ] ,
82+ } ) ) . equals ( 'audio/mp4' ) ;
83+ } ) ;
84+
7885 it ( 'detects MP4 video' , ( ) => {
7986 expect ( getShortMIMEString ( {
8087 format : { format_name : 'mov,mp4,m4a,3gp,3g2,mj2' } ,
@@ -306,24 +313,21 @@ describe('codecs test suite', () => {
306313
307314 describe ( 'MP4A / AAC' , ( ) => {
308315 /** @type {ProbeInfo } */
309- let info ;
310-
311- beforeEach ( ( ) => {
312- info = {
313- format : { format_name : 'mov,mp4,m4a,3gp,3g2,mj2' } ,
314- streams : [ {
315- codec_type : 'audio' ,
316- codec_tag_string : 'mp4a' ,
317- } ] ,
318- } ;
319- } ) ;
316+ let baseInfo = {
317+ format : { format_name : 'mov,mp4,m4a,3gp,3g2,mj2' } ,
318+ streams : [ {
319+ codec_type : 'audio' ,
320+ codec_tag_string : 'mp4a' ,
321+ } ] ,
322+ } ;
320323
321324 it ( 'throws when unknown' , ( ) => {
322- expect ( ( ) => getFullMIMEString ( info ) ) . to . throw ( ) ;
325+ expect ( ( ) => getFullMIMEString ( baseInfo ) ) . to . throw ( ) ;
323326 } ) ;
324327
325328 describe ( 'Profile tests' , ( ) => {
326329 it ( 'recognizes AAC-LC' , ( ) => {
330+ const info = structuredClone ( baseInfo ) ;
327331 info . streams [ 0 ] . profile = 'LC' ;
328332 expect ( getFullMIMEString ( info ) )
329333 . to . be . a ( 'string' )
@@ -332,13 +336,24 @@ describe('codecs test suite', () => {
332336 } ) ;
333337
334338 it ( 'handles codec_name=aac but no codec_tag_string' , ( ) => {
339+ const info = structuredClone ( baseInfo ) ;
335340 info . streams [ 0 ] . profile = 'LC' ;
336341 info . streams [ 0 ] . codec_tag_string = '[0][0][0][0]' ;
337342 info . streams [ 0 ] . codec_name = 'aac' ;
338343 expect ( getFullMIMEString ( info ) )
339344 . to . be . a ( 'string' )
340345 . and . equals ( 'audio/mp4; codecs="mp4a.40.2"' ) ;
341346 } ) ;
347+
348+ it ( 'handles m4a file with MJPEG stream' , ( ) => {
349+ const info = structuredClone ( baseInfo ) ;
350+ info . format . filename = 'sample.m4a' ;
351+ info . streams [ 0 ] . profile = 'LC' ;
352+ info . streams . push ( { codec_name : 'mjpeg' , codec_type : 'video' , profile : 'Baseline' } ) ;
353+ expect ( getFullMIMEString ( info ) )
354+ . to . be . a ( 'string' )
355+ . and . equals ( 'audio/mp4; codecs="mp4a.40.2"' ) ;
356+ } )
342357 } ) ;
343358
344359 describe ( 'MP4 / FLAC' , ( ) => {
@@ -374,7 +389,7 @@ describe('codecs test suite', () => {
374389 expect ( getFullMIMEString ( vInfo ) )
375390 . to . be . a ( 'string' )
376391 . and . equals ( 'video/mp4; codecs="flac"' ) ;
377-
392+
378393 } ) ;
379394 } ) ;
380395
0 commit comments