Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bun shell can't get output when using mp4dump #12679

Open
lvzhenbo opened this issue Jul 20, 2024 · 3 comments · May be fixed by #11950
Open

bun shell can't get output when using mp4dump #12679

lvzhenbo opened this issue Jul 20, 2024 · 3 comments · May be fixed by #11950
Labels
bug Something isn't working needs triage

Comments

@lvzhenbo
Copy link

What version of Bun is running?

1.1.20+ae1948925

What platform is your computer?

Microsoft Windows NT 10.0.22631.0 x64

What steps can reproduce the bug?

https://github.com/axiomatic-systems/Bento4

import { $ } from "bun";

async function getPssh(file: string) {
  // const mp4dump = Bun.spawn([
  //   "./mp4dump.exe",
  //   "--verbosity",
  //   "3",
  //   "--format",
  //   "json",
  //   file,
  // ]);
  // await mp4dump.exited;
  // if (mp4dump.exitCode !== 0) {
  //   throw new Error(`mp4dump process exited with code ${mp4dump.exitCode}`);
  // }
  const jsonInfo =
    await $`./mp4dump.exe --verbosity 3 --format json ${file}`.json();
  console.log(jsonInfo);

  // const jsonInfo = await new Response(mp4dump.stdout).json();

  let psshData = "";

  for (const temp of jsonInfo) {
    if (temp["name"] === "moov") {
      for (const child of temp["children"]) {
        if (
          "system_id" in child &&
          child["system_id"] ===
            "[ed ef 8b a9 79 d6 4a ce a3 c8 27 dc d5 1d 21 ed]"
        ) {
          psshData = child["data"];
          break;
        }
      }
      break;
    }
  }

  psshData = psshData.replace("[", "").replace("]", "").replace(/\s+/g, "");
  return Buffer.from(psshData, "hex").toString("base64");
}
const filePath = process.argv[2];
getPssh(filePath)
  .then((pssh) => console.log(pssh))
  .catch((error) => console.error(error));

What is the expected behavior?

There should be an output

What do you see instead?

Nothing.
image

Additional information

Is the program interrupted because the output is too large?

@lvzhenbo lvzhenbo added bug Something isn't working needs triage labels Jul 20, 2024
@Jarred-Sumner
Copy link
Collaborator

what if you do

import { $ } from "bun";

async function getPssh(file: string) {
  // const mp4dump = Bun.spawn([
  //   "./mp4dump.exe",
  //   "--verbosity",
  //   "3",
  //   "--format",
  //   "json",
  //   file,
  // ]);
  // await mp4dump.exited;
  // if (mp4dump.exitCode !== 0) {
  //   throw new Error(`mp4dump process exited with code ${mp4dump.exitCode}`);
  // }
  const jsonInfo =
    await $`./mp4dump.exe --verbosity 3 --format json ${file}`.json();
  console.log(jsonInfo);

  // const jsonInfo = await new Response(mp4dump.stdout).json();

  let psshData = "";

  for (const temp of jsonInfo) {
    if (temp["name"] === "moov") {
      for (const child of temp["children"]) {
        if (
          "system_id" in child &&
          child["system_id"] ===
            "[ed ef 8b a9 79 d6 4a ce a3 c8 27 dc d5 1d 21 ed]"
        ) {
          psshData = child["data"];
          break;
        }
      }
      break;
    }
  }

  psshData = psshData.replace("[", "").replace("]", "").replace(/\s+/g, "");
  return Buffer.from(psshData, "hex").toString("base64");
}
const filePath = process.argv[2];
await getPssh(filePath)

@lvzhenbo
Copy link
Author

@Jarred-Sumner This works, but why, I think it should be the same from the syntax side of the equation

@Jarred-Sumner
Copy link
Collaborator

Fixed by #11950

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants