Can now generate all versions of a target video with no audio then separate out the audio for dash.

master
Zed A. Shaw 4 weeks ago
parent 597a2ba7c1
commit 78f750a3e8
  1. 30
      config.json
  2. 28
      main.go

@ -4,15 +4,17 @@
"Scale": "1920:1080",
"Resize": false,
"VideoBitrate": 900,
"AudioBitrate": 192,
"AudioCodec": "none",
"VideoCodec": "libvpx-vp9",
"CleanFilename": false,
"CRF": 30,
"FPS": 30,
"Input": "test_video.mp4",
"OutDir": "dash_test",
"Passes": 2,
"Passes": 1,
"Dash": true,
"Extras": [
"-deadline", "realtime",
"-row-mt", "1",
"-cpu-used", "8",
"-g", "150",
@ -28,15 +30,17 @@
"Scale": "1280:720",
"Resize": false,
"VideoBitrate": 600,
"AudioBitrate": 192,
"AudioCodec": "none",
"VideoCodec": "libvpx-vp9",
"CleanFilename": false,
"CRF": 30,
"FPS": 30,
"Input": "test_video.mp4",
"OutDir": "dash_test",
"Passes": 2,
"Passes": 1,
"Dash": true,
"Extras": [
"-deadline", "realtime",
"-row-mt", "1",
"-cpu-used", "8",
"-g", "150",
@ -52,15 +56,17 @@
"Scale": "640:360",
"Resize": false,
"VideoBitrate": 300,
"AudioBitrate": 192,
"AudioCodec": "none",
"VideoCodec": "libvpx-vp9",
"CleanFilename": false,
"CRF": 30,
"FPS": 30,
"Input": "test_video.mp4",
"OutDir": "dash_test",
"Passes": 2,
"Passes": 1,
"Dash": true,
"Extras": [
"-deadline", "realtime",
"-row-mt", "1",
"-cpu-used", "8",
"-g", "150",
@ -70,5 +76,17 @@
"-frame-parallel", "1",
"-tune-content", "1"
]
},
{
"Format": "webm",
"AudioBitrate": 192,
"AudioCodec": "libopus",
"VideoCodec": "none",
"CleanFilename": false,
"CRF": 30,
"FPS": 30,
"Input": "test_video.mp4",
"OutDir": "dash_test",
"Passes": 1
}
]

@ -21,9 +21,14 @@ func ModFile(fname string, encoding config.VideoOpts) string {
base, found := strings.CutSuffix(file, ext)
if !found { panic("no extension found?!") }
dim := strings.Replace(encoding.Scale, ":", ".", 1)
renamed := fmt.Sprint(base, ".", dim, ".", encoding.Format)
return filepath.Join(dir, renamed)
if encoding.Scale == "" && encoding.VideoCodec == "none" {
renamed := fmt.Sprint(base, ".audio.", encoding.Format)
return filepath.Join(dir, renamed)
} else {
dim := strings.Replace(encoding.Scale, ":", ".", 1)
renamed := fmt.Sprint(base, ".", dim, ".", encoding.Format)
return filepath.Join(dir, renamed)
}
}
func Run(encoding config.VideoOpts, pass int, pid int, input string, output string) {
@ -49,8 +54,7 @@ func Run(encoding config.VideoOpts, pass int, pid int, input string, output stri
"-aspect", encoding.Scale)
}
if pass != encoding.Passes || encoding.Dash {
// BUG: warn that dash removes audio
if pass != encoding.Passes || encoding.AudioCodec == "none" {
extras = append(extras, "-an")
} else {
encode.AudioCodec(encoding.AudioCodec)
@ -64,11 +68,14 @@ func Run(encoding config.VideoOpts, pass int, pid int, input string, output stri
extras = append(extras, "-t", fmt.Sprint(encoding.Test))
}
encode.VideoCodec(encoding.VideoCodec).
VideoBitRate(encoding.VideoBitrate * 1024).
FrameRate(encoding.FPS).
ConstantRateFactor(encoding.CRF)
if encoding.VideoCodec == "none" {
extras = append(extras, "-vn")
} else {
encode.VideoCodec(encoding.VideoCodec).
VideoBitRate(encoding.VideoBitrate * 1024).
FrameRate(encoding.FPS).
ConstantRateFactor(encoding.CRF)
}
extras = append(extras, encoding.Extras...)
@ -78,7 +85,6 @@ func Run(encoding config.VideoOpts, pass int, pid int, input string, output stri
encode.OutputOptions(extras...)
cmd := encode.InputPath(input).
OutputFormat(encoding.Format).
OutputPath(output).

Loading…
Cancel
Save