From 5d79985b1139a181f6afff0df9563e7d6d917563 Mon Sep 17 00:00:00 2001 From: Yanis Benson Date: Sat, 4 May 2019 07:51:52 +0300 Subject: [PATCH] readme and comments --- index.js | 10 +++++----- readme.md | 10 +++++++++- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index 1af61b8d..c417d3f4 100644 --- a/index.js +++ b/index.js @@ -280,15 +280,15 @@ const fileType = input => { } // File Type Box (https://en.wikipedia.org/wiki/ISO_base_media_file_format) - // It is not required to be first, but is recommended to, almost all mpeg4 files start with ftyp box - // `ftyp` box must contain brand identifier, which must consist of ISO 8859-1 printable characters - // Here we check for 8859-1 printable characters + 1 unprintable for check simplicity - // They all can have mime video/mp4 except application/mp4 special case which is hard to detect. - // For some cases we're specific, everything else falls to video/mp4 with mp4 extension. + // It is not required to be first, but is recommended to, almost all ISO base media files start with ftyp box + // `ftyp` box must contain brand major identifier, which must consist of ISO 8859-1 printable characters + // Here we check for 8859-1 printable characters(for check simplicity, it is a mask which also catches one non-printable character). if ( check([0x66, 0x74, 0x79, 0x70], {offset: 4}) && // `ftyp` (buf[8] & 0x60) !== 0x00 && (buf[9] & 0x60) !== 0x00 && (buf[10] & 0x60) !== 0x00 && (buf[11] & 0x60) !== 0x00 // Brand major ) { + // They all can have mime video/mp4 except application/mp4 special case which is hard to detect. + // For some cases we're specific, everything else falls to video/mp4 with mp4 extension. const brandMajor = buf.toString('utf8', 8, 12); switch (brandMajor) { case 'mif1': diff --git a/readme.md b/readme.md index c41f3bc4..a261cd99 100644 --- a/readme.md +++ b/readme.md @@ -142,7 +142,6 @@ Type: [`stream.Readable`](https://nodejs.org/api/stream.html#stream_class_stream - [`7z`](https://en.wikipedia.org/wiki/7z) - [`dmg`](https://en.wikipedia.org/wiki/Apple_Disk_Image) - [`mp4`](https://en.wikipedia.org/wiki/MPEG-4_Part_14#Filename_extensions) -- [`m4v`](https://en.wikipedia.org/wiki/M4V) - [`mid`](https://en.wikipedia.org/wiki/MIDI) - [`mkv`](https://en.wikipedia.org/wiki/Matroska) - [`webm`](https://en.wikipedia.org/wiki/WebM) @@ -222,6 +221,15 @@ Type: [`stream.Readable`](https://nodejs.org/api/stream.html#stream_class_stream - [`alias`](https://en.wikipedia.org/wiki/Alias_%28Mac_OS%29) - macOS Alias file - [`voc`](https://wiki.multimedia.cx/index.php/Creative_Voice) - Creative Voice File - [`ac3`](https://www.atsc.org/standard/a522012-digital-audio-compression-ac-3-e-ac-3-standard-12172012/) - ATSC A/52 Audio File +- [`3g2`](https://en.wikipedia.org/wiki/3GP_and_3G2#3G2) - Multimedia container format defined by the 3GPP2 for 3G CDMA2000 multimedia services +- [`m4a`](https://en.wikipedia.org/wiki/M4A) - Audio-only MPEG-4 files +- [`m4b`](https://en.wikipedia.org/wiki/M4B) - Audiobook and podcast MPEG-4 files, which also contain metadata including chapter markers, images, and hyperlinks +- [`m4p`](https://en.wikipedia.org/wiki/MPEG-4_Part_14#Filename_extensions) - MPEG-4 files with audio streams encrypted by FairPlay Digital Rights Management as were sold through the iTunes Store +- [`m4v`](https://en.wikipedia.org/wiki/M4V) - MPEG-4 Visual bitstreams +- [`f4a`](https://en.wikipedia.org/wiki/Flash_Video) - Audio-only ISO base media file format used by Adobe Flash Player +- [`f4b`](https://en.wikipedia.org/wiki/Flash_Video) - Audiobook and podcast ISO base media file format used by Adobe Flash Player +- [`f4p`](https://en.wikipedia.org/wiki/Flash_Video) - ISO base media file format protected by Adobe Access DRM used by Adobe Flash Player +- [`f4v`](https://en.wikipedia.org/wiki/Flash_Video) - ISO base media file format used by Adobe Flash Player *SVG isn't included as it requires the whole file to be read, but you can get it [here](https://github.com/sindresorhus/is-svg).*