-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
21 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,30 @@ | ||
import imageType from 'image-type'; | ||
|
||
//webm and aac for audio files | ||
//webm and mp4 for audio files | ||
function webm(buffer) { | ||
return buffer[0] === 26 && | ||
buffer[1] === 69 && | ||
buffer[2] === 223 && | ||
buffer[3] === 163 ? 'webm' : ''; | ||
} | ||
|
||
function aac(buffer) { | ||
console.log(buffer[0], buffer[1]); | ||
return buffer[0] === 255 && (buffer[1] === 241 || buffer[1] === 249) ? 'aac' : ''; | ||
//apple shit | ||
function mp4(buffer) { | ||
console.log(buffer[0], buffer[1], buffer[2], buffer[3], buffer[4], buffer[5], buffer[6], buffer[7], buffer[8]); | ||
return buffer[0] === 102 && | ||
buffer[1] === 116 && | ||
buffer[2] === 121 && | ||
buffer[3] === 112 && | ||
buffer[4] === 112 && | ||
(buffer[5] === 105 || buffer[5] === 77) && | ||
(buffer[6] === 115 || buffer[6] === 83) && | ||
(buffer[7] === 111 || buffer[7] === 78) && | ||
(buffer[8] === 109 || buffer[8] === 86) ? 'mp4' : ''; | ||
} | ||
|
||
export function realFileExtension_(buffer) { | ||
return async function () { | ||
let r = await imageType(buffer); | ||
return r.ext || webm(buffer) || aac(buffer) || ''; | ||
return r.ext || webm(buffer) || mp4(buffer) || ''; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters