Skip to content

Commit

Permalink
Merge pull request #4 from rohitggarg/master
Browse files Browse the repository at this point in the history
Adding input seek and duration
  • Loading branch information
xfrr authored May 21, 2018
2 parents 6ad5399 + d3ea886 commit f014321
Show file tree
Hide file tree
Showing 4 changed files with 511 additions and 433 deletions.
76 changes: 38 additions & 38 deletions ffmpeg/ffmpeg.go
Original file line number Diff line number Diff line change
@@ -1,58 +1,58 @@
package ffmpeg

import (
"os/exec"
"bytes"
"strings"
"goffmpeg/utils"
"os/exec"
"bytes"
"strings"
"goffmpeg/utils"
)

type Configuration struct {
FfmpegBin string
FfprobeBin string
ExecCmd string
ExecArgs string
FfmpegBin string
FfprobeBin string
ExecCmd string
ExecArgs string
}

func Configure() (Configuration, error) {
var outFFmpeg bytes.Buffer
var outProbe bytes.Buffer
var outFFmpeg bytes.Buffer
var outProbe bytes.Buffer

execCmd := utils.GetExec()
execFFmpegCommand := utils.GetFFmpegExec()
execFFprobeCommand := utils.GetFFprobeExec()
execArgs := utils.GetExecArgs()
execCmd := utils.GetExec()
execFFmpegCommand := utils.GetFFmpegExec()
execFFprobeCommand := utils.GetFFprobeExec()
execArgs := utils.GetExecArgs()

cmdFFmpeg := exec.Command(execCmd, execArgs, execFFmpegCommand)
cmdProbe := exec.Command(execCmd, execArgs, execFFprobeCommand)
cmdFFmpeg := exec.Command(execCmd, execArgs, execFFmpegCommand)
cmdProbe := exec.Command(execCmd, execArgs, execFFprobeCommand)

cmdFFmpeg.Stdout = &outFFmpeg
cmdProbe.Stdout = &outProbe
cmdFFmpeg.Stdout = &outFFmpeg
cmdProbe.Stdout = &outProbe

err := cmdFFmpeg.Start()
if err != nil {
return Configuration{}, err
}
err := cmdFFmpeg.Start()
if err != nil {
return Configuration{}, err
}

_, err = cmdFFmpeg.Process.Wait()
if err != nil {
return Configuration{}, err
}
_, err = cmdFFmpeg.Process.Wait()
if err != nil {
return Configuration{}, err
}

err = cmdProbe.Start()
if err != nil {
return Configuration{}, err
}
err = cmdProbe.Start()
if err != nil {
return Configuration{}, err
}

_, err = cmdProbe.Process.Wait()
if err != nil {
return Configuration{}, err
}
_, err = cmdProbe.Process.Wait()
if err != nil {
return Configuration{}, err
}

ffmpeg := strings.Replace(outFFmpeg.String(), "\n", "", -1)
fprobe := strings.Replace(outProbe.String(), "\n", "", -1)
ffmpeg := strings.Replace(outFFmpeg.String(), "\n", "", -1)
fprobe := strings.Replace(outProbe.String(), "\n", "", -1)

cnf := Configuration{ffmpeg, fprobe, execCmd, execArgs}
cnf := Configuration{ffmpeg, fprobe, execCmd, execArgs}

return cnf, nil
return cnf, nil
}
Loading

0 comments on commit f014321

Please sign in to comment.