@magusn/vid
Advanced tools
+1
-1
@@ -5,3 +5,3 @@ { | ||
| "description": "cli helper for ffmpeg", | ||
| "version": "0.6.0", | ||
| "version": "0.6.1", | ||
| "author": "magus", | ||
@@ -8,0 +8,0 @@ "license": "MIT", |
+20
-3
@@ -36,2 +36,3 @@ import path from 'path'; | ||
| metadata.video.bitrate = int(video_probe.bit_rate); | ||
| metadata.video.duration = float(video_probe.duration); | ||
@@ -113,3 +114,3 @@ metadata.audio = {}; | ||
| if (argv.crop) { | ||
| const rect = await handleUserCrop({ argv, inputPath }); | ||
| const rect = await handleUserCrop({ argv, metadata, inputPath }); | ||
@@ -232,2 +233,3 @@ if (argv.verbose) { | ||
| const int = (n) => parseInt(n, 10); | ||
| const float = (n) => parseFloat(n); | ||
@@ -246,5 +248,6 @@ async function confirmGate(message) { | ||
| async function handleUserCrop({ argv, inputPath }) { | ||
| async function handleUserCrop({ argv, metadata, inputPath }) { | ||
| console.log('In order to crop we will open a still frame from the video for you to edit'); | ||
| console.log('Delete the area you want to select for your crop region'); | ||
| await confirmGate('Okay, got it.'); | ||
@@ -254,4 +257,10 @@ | ||
| const cropImageOutputPath = path.join(inputPath, cropImageFilename); | ||
| // get crop seconds, default to halfway point of video | ||
| const unsafeCropSeconds = argv['crop-frame-seconds'] || metadata.video.duration / 2; | ||
| // ensure crop seconds are within video duration | ||
| const cropSeconds = clamp(unsafeCropSeconds, 0, metadata.video.duration); | ||
| // write out tmp cropping image | ||
| const cropSeconds = argv['crop-frame-seconds'] || 0; | ||
| const stillCropFrame = [ | ||
@@ -262,4 +271,8 @@ 'ffmpeg -hide_banner -loglevel error', | ||
| ].join(' '); | ||
| // console.debug({ stillCropFrame, cropSeconds, unsafeCropSeconds, metadata }); | ||
| CLI.execSync(stillCropFrame); | ||
| CLI.execSync(`open ${cropImageOutputPath}`); | ||
| await confirmGate('Are you done?'); | ||
@@ -320,1 +333,5 @@ | ||
| } | ||
| function clamp(value, min, max) { | ||
| return Math.min(Math.max(value, min), max); | ||
| } |
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
28007
1.82%747
1.22%