Browse Source

Put all videos into a mkv video container (also without converting webms, should work with VLC)

master
Jan-Lukas Else 6 months ago
parent
commit
b4959e43ea
1 changed files with 31 additions and 73 deletions
  1. +31
    -73
      bbb-download.go

+ 31
- 73
bbb-download.go View File

@@ -143,7 +143,7 @@ func main() {
"-i", path.Join(presentationId, imgnames[j]),
"-t", fmt.Sprint(durations[j]),
"-pix_fmt", "yuv420p",
"-vf", "scale=-1:720",
"-vf", "scale=-1:1080",
path.Join(presentationId, vidnames[j]))
err = cmd.Run()
if err != nil {
@@ -188,101 +188,59 @@ func main() {
fmt.Println("slide videos merged")

// download webcams
webcamsFile := ""
fmt.Println("downloading webcams")
err = DownloadFile(path.Join(presentationId, "webcams.webm"), webcamsWebmUrl)
if err != nil {
err = DownloadFile(path.Join(presentationId, "orig-webcams.mp4"), webcamsMp4Url)
err = DownloadFile(path.Join(presentationId, "webcams.mp4"), webcamsMp4Url)
if err != nil {
fmt.Println("Failed to download webcams:", err.Error())
return
}
cmd = exec.Command("ffmpeg",
"-i", path.Join(presentationId, "orig-webcams.mp4"),
"-framerate", "1",
"-q:a", "0",
"-q:v", "0",
"-vf", "scale=-1:720",
path.Join(presentationId, "webcams.mp4"))
err = cmd.Run()
if err != nil {
fmt.Println("Failed to convert orig-webcams.mp4 to MP4:", err.Error())
return
fmt.Println("No webcams")
} else {
fmt.Println("webcams.mp4 file is downloaded")
webcamsFile = path.Join(presentationId, "webcams.mp4")
}
} else {
// Successful download, convert to MP4
fmt.Println("webcams.webm file is downloaded")
fmt.Println("converting webcams.webm to webcams.mp4")
cmd = exec.Command("ffmpeg",
"-i", path.Join(presentationId, "webcams.webm"),
"-framerate", "1",
"-q:a", "0",
"-q:v", "0",
"-vf", "scale=-1:720",
path.Join(presentationId, "webcams.mp4"))
err = cmd.Run()
if err != nil {
fmt.Println("Failed to convert webcams.webm to MP4:", err.Error())
return
}
webcamsFile = path.Join(presentationId, "webcams.webm")
}

// download deskshare
deskshare := true
deskshareFile := ""
fmt.Println("downloading deskshare")
err = DownloadFile(path.Join(presentationId, "deskshare.webm"), deskshareWebmUrl)
if err != nil {
err = DownloadFile(path.Join(presentationId, "orig-deskshare.mp4"), deskshareMp4Url)
err = DownloadFile(path.Join(presentationId, "deskshare.mp4"), deskshareMp4Url)
if err != nil {
fmt.Println("No deskshare")
deskshare = false
} else {
cmd = exec.Command("ffmpeg",
"-i", path.Join(presentationId, "orig-deskshare.mp4"),
"-framerate", "1",
"-q:a", "0",
"-q:v", "0",
"-vf", "scale=-1:720",
path.Join(presentationId, "deskshare.mp4"))
err = cmd.Run()
if err != nil {
fmt.Println("Failed to convert orig-deskshare.mp4 to MP4:", err.Error())
return
}
fmt.Println("deskshare.mp4 file is downloaded")
deskshareFile = path.Join(presentationId, "deskshare.mp4")
}
} else {
// Successful download, convert to MP4
fmt.Println("deskshare.webm file is downloaded")
fmt.Println("converting deskshare.webm to deskshare.mp4")
cmd = exec.Command("ffmpeg",
"-i", path.Join(presentationId, "deskshare.webm"),
"-framerate", "1",
"-q:a", "0",
"-q:v", "0",
"-vf", "scale=-1:720",
path.Join(presentationId, "deskshare.mp4"))
err = cmd.Run()
if err != nil {
fmt.Println("Failed to convert deskshare.webm to MP4:", err.Error())
return
}
deskshareFile = path.Join(presentationId, "deskshare.webm")
}

fmt.Println("merging slides, webcams and deskshare side by side")
cmd = exec.Command("ffmpeg",
"-i", path.Join(presentationId, "slides.mp4"),
"-i", path.Join(presentationId, "webcams.mp4"),
"-i", path.Join(presentationId, "deskshare.mp4"),
"-framerate", "1",
"-filter_complex", "hstack=inputs=3",
meetingName+".mp4")
if !deskshare {
cmd = exec.Command("ffmpeg",
"-i", path.Join(presentationId, "slides.mp4"),
"-i", path.Join(presentationId, "webcams.mp4"),
"-framerate", "1",
"-filter_complex", "hstack=inputs=2",
meetingName+".mp4")
streams := 1
cmd = exec.Command("ffmpeg", "-i", path.Join(presentationId, "slides.mp4"))
if webcamsFile != "" {
cmd.Args = append(cmd.Args, "-i")
cmd.Args = append(cmd.Args, webcamsFile)
streams++
}
if deskshareFile != "" {
cmd.Args = append(cmd.Args, "-i")
cmd.Args = append(cmd.Args, deskshareFile)
streams++
}
cmd.Args = append(cmd.Args, "-c")
cmd.Args = append(cmd.Args, "copy")
for i := 0; i < streams; i++ {
cmd.Args = append(cmd.Args, "-map")
cmd.Args = append(cmd.Args, strconv.Itoa(i))
}
cmd.Args = append(cmd.Args, meetingName+".mkv")
err = cmd.Run()
if err != nil {
fmt.Println("Failed to merge slides and webcams:", err.Error())


Loading…
Cancel
Save