feedeas 0.1.0-alpha.17 → 0.1.0-alpha.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/cli/index.js +51 -47
  2. package/package.json +1 -1
package/dist/cli/index.js CHANGED
@@ -3844,17 +3844,30 @@ import { FFmpeg } from "@ffmpeg/ffmpeg";
3844
3844
  function isNodeRuntime() {
3845
3845
  return typeof process !== "undefined" && !!process.versions?.node;
3846
3846
  }
3847
- async function convertWithNodeFfmpeg(pcmPath, outputPath) {
3847
+ function buildCodecArgs(options) {
3848
+ if (options.format === "wav") {
3849
+ return ["-c:a", "pcm_s16le"];
3850
+ }
3851
+ if (typeof options.mp3Quality === "number") {
3852
+ return ["-c:a", "libmp3lame", "-q:a", String(options.mp3Quality)];
3853
+ }
3854
+ return ["-c:a", "libmp3lame", "-b:a", options.mp3Bitrate || "128k"];
3855
+ }
3856
+ async function convertWithNodeFfmpeg(options) {
3857
+ const { pcmPath, outputPath, sampleRate, channels, durationSec } = options;
3858
+ const codecArgs = buildCodecArgs(options);
3848
3859
  await new Promise((resolve, reject) => {
3849
3860
  const ffmpeg = spawn6("ffmpeg", [
3850
3861
  "-f",
3851
3862
  "s16le",
3852
3863
  "-ar",
3853
- "24000",
3864
+ String(sampleRate),
3854
3865
  "-ac",
3855
- "1",
3866
+ String(channels),
3856
3867
  "-i",
3857
3868
  pcmPath,
3869
+ ...typeof durationSec === "number" ? ["-t", String(durationSec)] : [],
3870
+ ...codecArgs,
3858
3871
  "-y",
3859
3872
  outputPath
3860
3873
  ], { stdio: "inherit" });
@@ -3865,7 +3878,8 @@ async function convertWithNodeFfmpeg(pcmPath, outputPath) {
3865
3878
  ffmpeg.on("error", (err) => reject(err));
3866
3879
  });
3867
3880
  }
3868
- async function convertWithWasm(pcmPath, outputPath) {
3881
+ async function convertWithWasm(options) {
3882
+ const { pcmPath, outputPath, sampleRate, channels, durationSec } = options;
3869
3883
  const ffmpeg = new FFmpeg();
3870
3884
  const baseDir = typeof process !== "undefined" && typeof process.cwd === "function" ? process.cwd() : ".";
3871
3885
  const coreDir = path14.resolve(baseDir, "node_modules/@ffmpeg/core/dist");
@@ -3875,31 +3889,31 @@ async function convertWithWasm(pcmPath, outputPath) {
3875
3889
  await ffmpeg.load({ coreURL, wasmURL, workerURL });
3876
3890
  const pcmBytes = await fs15.promises.readFile(pcmPath);
3877
3891
  await ffmpeg.writeFile("input.pcm", pcmBytes);
3892
+ const codecArgs = buildCodecArgs(options);
3893
+ const outputName = options.format === "wav" ? "output.wav" : "output.mp3";
3878
3894
  await ffmpeg.exec([
3879
3895
  "-f",
3880
3896
  "s16le",
3881
3897
  "-ar",
3882
- "24000",
3898
+ String(sampleRate),
3883
3899
  "-ac",
3884
- "1",
3900
+ String(channels),
3885
3901
  "-i",
3886
3902
  "input.pcm",
3887
- "-codec:a",
3888
- "libmp3lame",
3889
- "-b:a",
3890
- "128k",
3891
- "output.mp3"
3903
+ ...typeof durationSec === "number" ? ["-t", String(durationSec)] : [],
3904
+ ...codecArgs,
3905
+ outputName
3892
3906
  ]);
3893
- const output = await ffmpeg.readFile("output.mp3");
3907
+ const output = await ffmpeg.readFile(outputName);
3894
3908
  await fs15.promises.writeFile(outputPath, output);
3895
3909
  }
3896
- async function convertPcmToMp3(options) {
3897
- const { pcmPath, outputPath } = options;
3910
+ async function convertPcmToAudio(options) {
3911
+ const { pcmPath } = options;
3898
3912
  let useWasm = !isNodeRuntime();
3899
3913
  try {
3900
3914
  try {
3901
3915
  if (!useWasm) {
3902
- await convertWithNodeFfmpeg(pcmPath, outputPath);
3916
+ await convertWithNodeFfmpeg(options);
3903
3917
  return;
3904
3918
  }
3905
3919
  } catch (err) {
@@ -3910,7 +3924,7 @@ async function convertPcmToMp3(options) {
3910
3924
  }
3911
3925
  if (useWasm) {
3912
3926
  try {
3913
- await convertWithWasm(pcmPath, outputPath);
3927
+ await convertWithWasm(options);
3914
3928
  return;
3915
3929
  } catch (err) {
3916
3930
  throw new Error(
@@ -3930,6 +3944,15 @@ async function convertPcmToMp3(options) {
3930
3944
  }
3931
3945
  }
3932
3946
  }
3947
+ async function convertPcmToMp3(options) {
3948
+ await convertPcmToAudio({
3949
+ ...options,
3950
+ format: "mp3",
3951
+ sampleRate: 24e3,
3952
+ channels: 1,
3953
+ mp3Bitrate: "128k"
3954
+ });
3955
+ }
3933
3956
 
3934
3957
  // src/cli/commands/audio.ts
3935
3958
  var audioCommand = new Command6("generate:audio");
@@ -4020,7 +4043,6 @@ async function generateGeminiAudio(text, apiKey, voiceName) {
4020
4043
  import { Command as Command7 } from "commander";
4021
4044
  import fs17 from "fs";
4022
4045
  import path16 from "path";
4023
- import { spawn as spawn7 } from "child_process";
4024
4046
  var bgmCommand = new Command7("generate:bgm");
4025
4047
  bgmCommand.alias("bgm").alias("music").description("Generate background music with Gemini Lyria (Live Music API)").argument("<prompt-or-file>", "Music prompt text or path to a text file").option("-o, --output <filename>", "Output filename (relative to assets/ or absolute path)", "bgm.mp3").option("-k, --api-key <key>", "Gemini API key (or set GEMINI_API_KEY env var)").option("-d, --duration <seconds>", "Target duration in seconds (5-300)", "30").option("--seed <number>", "Optional seed for reproducible output").option("--json", "Emit machine-readable JSON output").action(async (promptOrFile, options) => {
4026
4048
  try {
@@ -4185,40 +4207,22 @@ async function convertPcmToOutput(pcmBuffer, outputPath, format, durationSec) {
4185
4207
  if (!fs17.existsSync(outputDir)) fs17.mkdirSync(outputDir, { recursive: true });
4186
4208
  const tempPcmPath = path16.join(outputDir, `temp_bgm_${Date.now()}.pcm`);
4187
4209
  fs17.writeFileSync(tempPcmPath, pcmBuffer);
4188
- const codecArgs = format === "wav" ? ["-c:a", "pcm_s16le"] : ["-c:a", "libmp3lame", "-q:a", "2"];
4189
- try {
4190
- await new Promise((resolve, reject) => {
4191
- const ffmpeg = spawn7("ffmpeg", [
4192
- "-f",
4193
- "s16le",
4194
- "-ar",
4195
- "48000",
4196
- "-ac",
4197
- "2",
4198
- "-i",
4199
- tempPcmPath,
4200
- "-t",
4201
- String(durationSec),
4202
- ...codecArgs,
4203
- "-y",
4204
- outputPath
4205
- ], { stdio: "inherit" });
4206
- ffmpeg.on("close", (code) => {
4207
- if (code === 0) resolve();
4208
- else reject(new Error(`FFmpeg exited with code ${code}`));
4209
- });
4210
- ffmpeg.on("error", reject);
4211
- });
4212
- } finally {
4213
- if (fs17.existsSync(tempPcmPath)) fs17.unlinkSync(tempPcmPath);
4214
- }
4210
+ await convertPcmToAudio({
4211
+ pcmPath: tempPcmPath,
4212
+ outputPath,
4213
+ format,
4214
+ sampleRate: 48e3,
4215
+ channels: 2,
4216
+ durationSec,
4217
+ mp3Quality: format === "mp3" ? 2 : void 0
4218
+ });
4215
4219
  }
4216
4220
 
4217
4221
  // src/cli/commands/asset.ts
4218
4222
  import { Command as Command8 } from "commander";
4219
4223
  import fs18 from "fs";
4220
4224
  import path17 from "path";
4221
- import { spawn as spawn8 } from "child_process";
4225
+ import { spawn as spawn7 } from "child_process";
4222
4226
  var assetCommand = new Command8("asset").description("Asset information and management");
4223
4227
  assetCommand.command("info <file>").description("Show detailed information about an asset").action(async (file) => {
4224
4228
  const assetPath = path17.resolve(process.cwd(), "assets", file);
@@ -4301,7 +4305,7 @@ async function getImageDimensions(filePath) {
4301
4305
  }
4302
4306
  async function getAudioInfo(filePath) {
4303
4307
  return new Promise((resolve, reject) => {
4304
- const ffprobe = spawn8("ffprobe", [
4308
+ const ffprobe = spawn7("ffprobe", [
4305
4309
  "-v",
4306
4310
  "error",
4307
4311
  "-show_entries",
@@ -5271,7 +5275,7 @@ var __dirname5 = path21.dirname(__filename5);
5271
5275
  var program = new Command16();
5272
5276
  var telemetry = new PostHogTelemetryService();
5273
5277
  var commandStartTimes = /* @__PURE__ */ new WeakMap();
5274
- program.name("feedeas").description("CLI for Feedeas - AI-native video creation tool").version("0.1.0-alpha.17");
5278
+ program.name("feedeas").description("CLI for Feedeas - AI-native video creation tool").version("0.1.0-alpha.18");
5275
5279
  program.hook("preAction", (_thisCommand, actionCommand) => {
5276
5280
  commandStartTimes.set(actionCommand, Date.now());
5277
5281
  telemetry.trackCommandStarted(actionCommand);
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "feedeas",
3
3
  "module": "index.ts",
4
4
  "type": "module",
5
- "version": "0.1.0-alpha.17",
5
+ "version": "0.1.0-alpha.18",
6
6
  "devDependencies": {
7
7
  "@tailwindcss/vite": "^4.1.18",
8
8
  "@types/bun": "latest",