Created
June 27, 2025 23:57
-
-
Save j0sh/5c402790df13f490a00a81bba651b8f5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
// go run encode.go infile out.ts sw | |
import ( | |
"log" | |
"os" | |
"github.com/livepeer/lpms/ffmpeg" | |
) | |
func main() { | |
if len(os.Args) <= 1 { | |
log.Fatal("missing input name") | |
} | |
fname := os.Args[1] | |
var out string | |
if len(os.Args) <= 2 { | |
out = "out.ts" | |
} else { | |
out = os.Args[2] | |
} | |
accel := ffmpeg.Nvidia | |
if len(os.Args) >= 4 { | |
s := os.Args[3] | |
if "nv" == s { | |
// default | |
accel = ffmpeg.Nvidia | |
} else if "sw" == s { | |
accel = ffmpeg.Software | |
} else { | |
log.Println("unrecognized accel, using default nvidia") | |
accel = ffmpeg.Nvidia | |
} | |
} | |
log.Println("Using output", out) | |
ffmpeg.FfmpegSetLogLevel(ffmpeg.FFLogTrace) | |
prof := ffmpeg.P240p30fps16x9 | |
prof.Framerate = 0 // pass through | |
if _, err := ffmpeg.Transcode3(&ffmpeg.TranscodeOptionsIn{ | |
Fname: fname, | |
Accel: accel, | |
}, []ffmpeg.TranscodeOptions{{ | |
Oname: out, | |
Profile: prof, | |
Accel: accel, | |
AudioEncoder: ffmpeg.ComponentOptions{Name: "drop"}, | |
}}); err != nil { | |
panic(err) | |
} | |
log.Println("all done") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment