Skip to content

Commit

Permalink
[feat] Multi inputs support
Browse files Browse the repository at this point in the history
  • Loading branch information
rixtox committed Sep 29, 2021
1 parent 748ab8b commit a614e24
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
18 changes: 18 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch Package",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}",
"args": [
"/Users/rix/Downloads/白蛇2:青蛇劫起.Green.Snake.2021.2160p.DV.WEB-DL.H265.DDP5.1.Atmos-10003@BBQDDQ.COM.mp4"
]
}
]
}
21 changes: 17 additions & 4 deletions mp4dovi.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,18 @@ func trakHandler(rw *os.File) func(Header) error {
}
}

func run(mp4file string) (err error) {
func processFile(mp4file string) (err error) {
var (
rw *os.File
h *Header
)

if rw, err = os.OpenFile(mp4file, os.O_RDWR, 0); err != nil {
return fmt.Errorf(`cannot open file "%s": %w`, mp4file, err)
}
defer rw.Close()

fmt.Printf(`Processing %s ...\n`, mp4file)

if _, err = rw.Seek(0, io.SeekStart); err != nil {
return fmt.Errorf(`failed to seek: %w`, err)
Expand All @@ -144,18 +148,27 @@ func run(mp4file string) (err error) {
return
}

func run(mp4files []string) (err error) {
for _, mp4file := range mp4files {
if err = processFile(mp4file); err != nil {
return fmt.Errorf(`failed processing file %s: %w`, mp4file, err)
}
}
return
}

func help() {
fmt.Println(`Usage: mp4dovi <file>`)
fmt.Println(`Usage: mp4dovi <file>...`)
}

func main() {

if len(os.Args) != 2 {
if len(os.Args) < 2 {
help()
os.Exit(1)
}

if err := run(os.Args[1]); err != nil {
if err := run(os.Args[1:]); err != nil {
log.Fatal(err)
}
}

0 comments on commit a614e24

Please sign in to comment.