Skip to content

Commit

Permalink
Merge pull request #2 from codenoobforreal/videoinfo
Browse files Browse the repository at this point in the history
Videoinfo
  • Loading branch information
codenoobforreal authored Dec 20, 2024
2 parents 0e1169c + 6b0c9e9 commit 68fe0c2
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 56 deletions.
5 changes: 5 additions & 0 deletions .changeset/tame-tigers-heal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@codenoobforreal/commonflow": patch
---

Give the user more information about the output.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# commonflow

CLI to simplify your daily workflow
CLI to simplify your day!

## usage
## sub command list

- transcode-videos

### transcode-videos

```bash
npx @codenoobforreal/commmonflow transcode-videos /path/to/input/path /path/to/output/path
Expand Down
52 changes: 2 additions & 50 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
"eslint-config-prettier": "^9.1.0",
"globals": "^15.14.0",
"is-in-ci": "^1.0.0",
"playwright": "^1.49.1",
"prettier": "^3.4.2",
"tsup": "^8.3.5",
"typescript": "^5.7.2",
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const program = new Command();
program
.name("commonflow")
.description(`CLI to simplify your daily workflow`)
.version("0.1.1");
.version("0.1.2");
program
.command("transcode-videos")
.description(`Transcode all video files in the input path to the output path`)
Expand Down
2 changes: 1 addition & 1 deletion src/tasks/transcode-video.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export async function runTranscodeVideosSubProgram(args: TranscodeVideoArgs) {
if ((line as string).includes("Lsize")) {
const size = lsizeStringCapture(line as string);
const duration = timeStringCapture(line as string);
yield `output stat: ${duration} ${size}`;
yield `transcode stat: ${duration} ${size} ${output}`;
}
};
await transcodeVideo(shellCommand, ffmpegInfoTransform);
Expand Down
16 changes: 15 additions & 1 deletion src/utils.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { test, expect, describe } from "vitest";
import { formatFileSize, formatDuration } from "./utils";
import {
formatFileSize,
formatDuration,
formatFfmpegTimeString,
} from "./utils";

describe("utils function", () => {
describe("formatFileSize", () => {
Expand Down Expand Up @@ -32,4 +36,14 @@ describe("utils function", () => {
expect(formatDuration(3700)).toBe(`1h1m40s`);
});
});
describe("formatFfmpegTimeString", () => {
test("discard all meaningless zero", () => {
expect(formatFfmpegTimeString("00:00:05.80")).toBe("05.80");
expect(formatFfmpegTimeString("00:00:50.80")).toBe("50.80");
expect(formatFfmpegTimeString("00:10:05.80")).toBe("10:05.80");
expect(formatFfmpegTimeString("00:01:05.80")).toBe("01:05.80");
expect(formatFfmpegTimeString("10:10:05.80")).toBe("10:10:05.80");
expect(formatFfmpegTimeString("01:10:05.80")).toBe("01:10:05.80");
});
});
});
12 changes: 12 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@ export function formatDuration(duration: number) {
}
}

// eg: 00:00:05.80
export function formatFfmpegTimeString(str: string) {
const [h, m] = str.split(":");
if (h === "00") {
if (m === "00") {
return str.slice(6);
}
return str.slice(3);
}
return str;
}

export function now() {
return new Date().getTime();
}
Expand Down

0 comments on commit 68fe0c2

Please sign in to comment.