Skip to content

Commit

Permalink
Merge pull request #16 from rohitggarg/master
Browse files Browse the repository at this point in the history
Fixing execution model and making compatible with windows.
Added progress check flag, only open stderr if progress required.
Adding back the ffmpeg process cmd handle.
Fixed up Filter command.
  • Loading branch information
xfrr authored Jul 3, 2018
2 parents ba176bd + 97ab829 commit 53ebb30
Show file tree
Hide file tree
Showing 8 changed files with 297 additions and 395 deletions.
26 changes: 14 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,11 @@ func main() {
// Handle error...

// Start transcoder process
done, err := trans.Run()
done := trans.Run()

// This channel is used to wait for the process to end
<-done
err = <-done
// Handle error...

}
```
Expand All @@ -59,28 +60,29 @@ func main() {
// Handle error...

// Start transcoder process
done, err := trans.Run()
done := trans.Run()

// Returns a channel to get the transcoding progress
progress, err := trans.Output()
progress := trans.Output()

// Example of printing transcoding progress
for msg := range progress {
fmt.Println(msg)
}

// This channel is used to wait for the transcoding process to end
<-done
err = <-done

}
```
# Progress properties
```golang
type Progress struct {
FramesProcessed string
CurrentTime string
CurrentBitrate string
Progress float64
FramesProcessed string
CurrentTime string
CurrentBitrate string
Progress float64
Speed string
}
```
# Media setters
Expand Down Expand Up @@ -139,18 +141,18 @@ func main() {
trans.MediaFile().SetPreset("ultrafast")

// Start transcoder process
done, err := trans.Run()
done := trans.Run()

// Returns a channel to get the transcoding progress
progress, err := trans.Output()
progress := trans.Output()

// Example of printing transcoding progress
for msg := range progress {
fmt.Println(msg)
}

// This channel is used to wait for the transcoding process to end
<-done
err = <-done

}
```
Expand Down
30 changes: 7 additions & 23 deletions ffmpeg/ffmpeg.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,49 +10,33 @@ import (
type Configuration struct {
FfmpegBin string
FfprobeBin string
ExecCmd string
ExecArgs string
}

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

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(execFFmpegCommand[0], execFFmpegCommand[1])
cmdProbe := exec.Command(execFFprobeCommand[0], execFFprobeCommand[1])

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

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

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

err = cmdProbe.Start()
err = cmdProbe.Run()
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)

cnf := Configuration{ffmpeg, fprobe, execCmd, execArgs}
ffmpeg := strings.Replace(outFFmpeg.String(), utils.LineSeparator(), "", -1)
fprobe := strings.Replace(outProbe.String(), utils.LineSeparator(), "", -1)

cnf := Configuration{ffmpeg, fprobe}
return cnf, nil
}
Loading

0 comments on commit 53ebb30

Please sign in to comment.