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 1 month ago
parent 9d87143a95
commit 597a2ba7c1
  1. 56
      config.json
  2. 1
      config/settings.go
  3. 17
      main.go

@ -7,14 +7,60 @@
"AudioBitrate": 192, "AudioBitrate": 192,
"VideoCodec": "libvpx-vp9", "VideoCodec": "libvpx-vp9",
"CleanFilename": false, "CleanFilename": false,
"CRF": 20, "CRF": 30,
"FPS": 30, "FPS": 30,
"Tune": "animation", "Input": "test_video.mp4",
"Input": "LGo*.mp4",
"OutDir": "dash_test", "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": [ "Extras": [
"-deadline", "realtime",
"-row-mt", "1", "-row-mt", "1",
"-cpu-used", "8", "-cpu-used", "8",
"-g", "150", "-g", "150",

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

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

Loading…
Cancel
Save