Can now do dash encodings and handles 2 passes or 1 pass dash. Also doesn't do the ffmpeg log if it's only one pass.

master
Zed A. Shaw 4 weeks ago
parent 9d87143a95
commit 597a2ba7c1
  1. 56
      config.json
  2. 1
      config/settings.go
  3. 35
      main.go

@ -7,14 +7,60 @@
"AudioBitrate": 192,
"VideoCodec": "libvpx-vp9",
"CleanFilename": false,
"CRF": 20,
"CRF": 30,
"FPS": 30,
"Tune": "animation",
"Input": "LGo*.mp4",
"Input": "test_video.mp4",
"OutDir": "dash_test",
"Passes": 1,
"Passes": 2,
"Extras": [
"-row-mt", "1",
"-cpu-used", "8",
"-g", "150",
"-keyint_min", "150",
"-tile-columns", "4",
"-tile-rows", "2",
"-frame-parallel", "1",
"-tune-content", "1"
]
},
{
"Format": "webm",
"Scale": "1280:720",
"Resize": false,
"VideoBitrate": 600,
"AudioBitrate": 192,
"VideoCodec": "libvpx-vp9",
"CleanFilename": false,
"CRF": 30,
"FPS": 30,
"Input": "test_video.mp4",
"OutDir": "dash_test",
"Passes": 2,
"Extras": [
"-row-mt", "1",
"-cpu-used", "8",
"-g", "150",
"-keyint_min", "150",
"-tile-columns", "4",
"-tile-rows", "2",
"-frame-parallel", "1",
"-tune-content", "1"
]
},
{
"Format": "webm",
"Scale": "640:360",
"Resize": false,
"VideoBitrate": 300,
"AudioBitrate": 192,
"VideoCodec": "libvpx-vp9",
"CleanFilename": false,
"CRF": 30,
"FPS": 30,
"Input": "test_video.mp4",
"OutDir": "dash_test",
"Passes": 2,
"Extras": [
"-deadline", "realtime",
"-row-mt", "1",
"-cpu-used", "8",
"-g", "150",

@ -17,6 +17,7 @@ type VideoOpts struct {
AudioCodec string
Preset string
CleanFilename bool
Dash bool
CRF int
FPS int
Tune string

@ -31,8 +31,12 @@ func Run(encoding config.VideoOpts, pass int, pid int, input string, output stri
extras := []string{
"-pix_fmt", "yuv420p",
"-pass", fmt.Sprint(pass),
"-passlogfile", fmt.Sprintf("ffmpegpass-%x.log", pid),
}
if encoding.Passes > 1 {
extras = append(extras,
"-pass", fmt.Sprint(pass),
"-passlogfile", fmt.Sprintf("ffmpegpass-%x.log", pid))
}
if encoding.Preset != "" {
@ -45,7 +49,8 @@ func Run(encoding config.VideoOpts, pass int, pid int, input string, output stri
"-aspect", encoding.Scale)
}
if pass != encoding.Passes {
if pass != encoding.Passes || encoding.Dash {
// BUG: warn that dash removes audio
extras = append(extras, "-an")
} else {
encode.AudioCodec(encoding.AudioCodec)
@ -53,25 +58,33 @@ func Run(encoding config.VideoOpts, pass int, pid int, input string, output stri
"-b:a", fmt.Sprint(encoding.AudioBitrate * 1024))
}
if encoding.Test > 0 {
encode.InputOptions("-ss", fmt.Sprintf("00:%d", encoding.TestStart))
extras = append(extras, "-t", fmt.Sprint(encoding.Test))
}
encode.VideoCodec(encoding.VideoCodec).
VideoBitRate(encoding.VideoBitrate * 1024).
FrameRate(encoding.FPS).
ConstantRateFactor(encoding.CRF)
VideoBitRate(encoding.VideoBitrate * 1024).
FrameRate(encoding.FPS).
ConstantRateFactor(encoding.CRF)
extras = append(extras, encoding.Extras...)
if encoding.Dash {
extras = append(extras, "-dash", "1")
}
encode.OutputOptions(extras...)
cmd := encode.InputPath(input).
OutputFormat(encoding.Format).
OutputPath(output).
OutputLogs(os.Stdout).
Overwrite(true).
Build()
OutputFormat(encoding.Format).
OutputPath(output).
OutputLogs(os.Stdout).
Overwrite(true).
Build()
fmt.Println(">", cmd.String())

Loading…
Cancel
Save