@brainsights/media-tools
Advanced tools
Comparing version 3.3.3 to 3.4.0
@@ -7,2 +7,5 @@ const _ = require("lodash"); | ||
const toBoolean = (value) => "Yes" == value ? true : false; | ||
const toFloat = (value) => parseFloat(value); | ||
const toInteger = (value) => parseInt(value); | ||
const toMS = (value) => parseFloat(value).toFixed(3) * 1000; | ||
@@ -13,6 +16,5 @@ class MediaInfo | ||
{ | ||
let generalInfo = _.find(info.file.track, (track) => "General" == track._type); | ||
let generalInfo = _.find(info.media.track, (track) => "General" == track._type); | ||
if(!_.includes(generalInfo, "internetMediaType")) | ||
generalInfo["internetMediaType"] = mime.lookup(generalInfo["fileExtension"]); | ||
generalInfo["internetmediatype"] = mime.lookup(generalInfo["fileextension"]); | ||
@@ -41,6 +43,7 @@ generalInfo = _.transform(generalInfo, (result, value, key) => { | ||
"format": "format", | ||
"overallBitRate": "overall_bit_rate", | ||
"overallBitRateMode": "overall_bit_rate_mode", | ||
"internetMediaType": "internet_media_type", | ||
"fileSize": "bytes", | ||
"overallbitrate": "overall_bit_rate", | ||
"overallbitratemode": "overall_bit_rate_mode", | ||
"internetmediatype": "internet_media_type", | ||
"filesize": "bytes", | ||
"fileextension": "extension", | ||
} | ||
@@ -52,3 +55,7 @@ } | ||
return { | ||
"overall_bit_rate_mode": toLowerCase, | ||
"duration": toMS, | ||
"overall_bit_rate": toInteger, | ||
"overall_bit_rate_mode": toLowerCase, | ||
"bytes": toInteger, | ||
"fileextension": toLowerCase, | ||
}; | ||
@@ -55,0 +62,0 @@ } |
@@ -5,2 +5,5 @@ const _ = require("lodash"); | ||
const toBoolean = (value) => "Yes" == value ? true : false; | ||
const toFloat = (value) => parseFloat(value); | ||
const toInteger = (value) => parseInt(value); | ||
const toMS = (value) => parseFloat(value).toFixed(3) * 1000; | ||
@@ -11,2 +14,5 @@ class MediaTrackInfo | ||
{ | ||
if(!info.hasOwnProperty("_typeorder")) | ||
info["_typeorder"] = 1; | ||
info = _.transform(info, (result, value, key) => { | ||
@@ -31,23 +37,20 @@ if(key in MediaTrackInfo.keymap) { | ||
"streamorder": "index", | ||
"streamIdentifier": "type_index", | ||
"_typeorder": "type_index", | ||
"format": "format", | ||
"compressionMode": "compression_mode", | ||
"streamSize": "stream_size", | ||
"streamsize": "bytes", | ||
"duration": "duration", | ||
"bitrate": "bit_rate", | ||
"bitrateMode": "bit_rate_mode", | ||
"codec": "codec", | ||
"codecid": "codec", | ||
"width": "width", | ||
"height": "height", | ||
"displayAspectRatio": "display_aspect_ratio", | ||
"frameCount": "frame_count", | ||
"frameRate": "frame_rate", | ||
"frameRateMode": "frame_rate_mode", | ||
"bitsPixelFrame": "quality", | ||
"channelS": "channels", | ||
"channelSOriginal": "channels_original", | ||
"samplingRate": "sampling_rate", | ||
"framecount": "frame_count", | ||
"framerate": "frame_rate", | ||
"framerateMode": "frame_rate_mode", | ||
"channels": "channels", | ||
"samplingrate": "sampling_rate", | ||
"default": "is_default", | ||
"forced": "is_forced", | ||
"bitDepth": "bit_depth", | ||
"bitdepth": "bit_depth", | ||
"language": "language", | ||
@@ -61,6 +64,18 @@ } | ||
"type": toLowerCase, | ||
"compression_mode": toLowerCase, | ||
"index": toInteger, | ||
"type_index": (value) => toInteger(value) - 1, | ||
"bytes": toInteger, | ||
"duration": toMS, | ||
"bit_rate": toInteger, | ||
"width": toInteger, | ||
"height": toInteger, | ||
"display_aspect_ratio": toFloat, | ||
"frame_count": toInteger, | ||
"frame_rate": toFloat, | ||
"frame_rate_mode": toLowerCase, | ||
"channels": toInteger, | ||
"sampling_rate": toInteger, | ||
"is_default": toBoolean, | ||
"is_forced": toBoolean, | ||
"bit_depth": toInteger, | ||
}; | ||
@@ -67,0 +82,0 @@ } |
@@ -105,3 +105,3 @@ const path = require("path"); | ||
let mediaTracksInfo = _.map(_.filter(info.file.track, (track) => _.includes(["Video", "Audio", "Text", "Image"], track._type)), (track) => new MediaTrackInfo(track, path)); | ||
let mediaTracksInfo = _.map(_.filter(info.media.track, (track) => _.includes(["Video", "Audio", "Text", "Image"], track._type)), (track) => new MediaTrackInfo(track, path)); | ||
let mediaTracks = new MediaTracks(_.map(mediaTracksInfo, (mediaTrackInfo) => { | ||
@@ -108,0 +108,0 @@ return new (_.find(MediaTrack, (clazz) => clazz.type == mediaTrackInfo.type))(media, mediaTrackInfo); |
{ | ||
"name": "@brainsights/media-tools", | ||
"version": "3.3.3", | ||
"version": "3.4.0", | ||
"description": "Tools for reading metadata and transcoding media files.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -0,8 +1,42 @@ | ||
process.env.FFMPEG_BIN_PATH = "/home/ack/software/ffmpeg-4.0.2-64bit-static/ffmpeg"; | ||
process.env.FFPROBE_BIN_PATH = "/home/ack/software/ffmpeg-4.0.2-64bit-static/ffprobe"; | ||
const Media = require("../"); | ||
const tests = [ | ||
// { dir: "image", in: "1000x2000.png", out: "1000x2000.png", }, | ||
// { dir: "image", in: "1080x1920.png", out: "1080x1920.png", }, | ||
// { dir: "image", in: "1280x720.png", out: "1280x720.png", }, | ||
// { dir: "image", in: "1440x2560.png", out: "1440x2560.png", }, | ||
// { dir: "image", in: "1920x1080.png", out: "1920x1080.png", }, | ||
// { dir: "image", in: "2000x1000.png", out: "2000x1000.png", }, | ||
// { dir: "image", in: "240x320.png", out: "240x320.png", }, | ||
// { dir: "image", in: "2560x1440.png", out: "2560x1440.png", }, | ||
// { dir: "image", in: "2560x1450.png", out: "2560x1450.png", }, | ||
// { dir: "image", in: "2570x1440.png", out: "2570x1440.png", }, | ||
// { dir: "image", in: "300x300.png", out: "300x300.png", }, | ||
// { dir: "image", in: "320x240.png", out: "320x240.png", }, | ||
// { dir: "image", in: "360x640.png", out: "360x640.png", }, | ||
// { dir: "image", in: "480x640.png", out: "480x640.png", }, | ||
// { dir: "image", in: "640x360.png", out: "640x360.png", }, | ||
// { dir: "image", in: "640x480.png", out: "640x480.png", }, | ||
// { dir: "image", in: "720x1280.png", out: "720x1280.png", }, | ||
// { dir: "audio", in: "3s.mp3", out: "3s.weba", }, | ||
// { dir: "audio", in: "28m59s.wav", out: "28m59s.weba" }, | ||
// { dir: "audio", in: "3.webm", out: "3.weba" }, | ||
// { dir: "video+audio", in: "560x320-6s.mp4", out: "560x320-6s.webm", }, | ||
// { dir: "video+audio", in: "3840x2160-23s.mkv", out: "3840x2160-23s.webm", }, | ||
// { dir: "video+audio", in: "1920x800-10s.mkv", out: "1920x800-10s.webm", }, | ||
{ dir: "video+audio", in: "1920x1080-2m23s.mkv", out: "1920x1080-2m23s.webm" }, | ||
// { dir: "video+audio", in: "broken.mkv", out: "broken.webm" } | ||
]; | ||
(async () => { | ||
let media = await Media.load("/tmp/118ab199b49c4ca64357e68ae627bde9/zotdctZlTua0i2UO-Pc1VQ.mkv"); | ||
console.log(media.fullInfo); | ||
media = await Media.load("./test/out/image/media_preview-720x1280.png"); | ||
console.log(media.fullInfo); | ||
try { | ||
for(let test of tests) { | ||
let mediaIn = await Media.load(`${__dirname}/in/${test.dir}/${test.in}`); | ||
console.log(mediaIn.fullInfo); | ||
} | ||
} catch(e) { | ||
console.trace(e); | ||
} | ||
})(); |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
29230
909
6