mirror of
https://github.com/xfrr/goffmpeg.git
synced 2025-12-24 12:12:34 +08:00
53ebb30281ea36709926f8bb0890dc6cc3b636d6
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.
Goffmpeg
FFMPEG wrapper written in GO which allows to obtain the progress.
Dependencies
Supported platforms
- Linux
- OS X
- Windows
Getting started
How to transcode a media file
go get github.com/xfrr/goffmpeg
package main
import (
"github.com/xfrr/goffmpeg/transcoder"
)
var inputPath = "/data/testmov"
var outputPath = "/data/testmp4.mp4"
func main() {
// Create new instance of transcoder
trans := new(transcoder.Transcoder)
// Initialize transcoder passing the input file path and output file path
err := trans.Initialize( inputPath, outputPath )
// Handle error...
// Start transcoder process
done := trans.Run()
// This channel is used to wait for the process to end
err = <-done
// Handle error...
}
How to get the transcoding progress
...
func main() {
// Create new instance of transcoder
trans := new(transcoder.Transcoder)
// Initialize transcoder passing the input file path and output file path
err := trans.Initialize( inputPath, outputPath )
// Handle error...
// Start transcoder process
done := trans.Run()
// Returns a channel to get the transcoding progress
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
err = <-done
}
Progress properties
type Progress struct {
FramesProcessed string
CurrentTime string
CurrentBitrate string
Progress float64
Speed string
}
Media setters
Those options can be set before starting the transcoding.
SetAspect
SetResolution
SetVideoBitRate
SetVideoBitRateTolerance
SetVideoMaxBitrate
SetVideoMinBitRate
SetVideoCodec
SetFrameRate
SetMaxKeyFrame
SetMinKeyFrame
SetKeyframeInterval
SetAudioCodec
SetAudioBitRate
SetAudioChannels
SetBufferSize
SetThreads
SetPreset
SetTune
SetAudioProfile
SetVideoProfile
SetDuration
SetDurationInput
SetSeekTime
SetSeekTimeInput
SetSeekUsingTsInput
SetQuality
SetCopyTs
SetMuxDelay
SetInputPath
SetNativeFramerateInput
SetRtmpLive
SetHlsSegmentDuration
SetHlsPlaylistType
SetOutputPath
SetOutputFormat
Example
func main() {
// Create new instance of transcoder
trans := new(transcoder.Transcoder)
// Initialize transcoder passing the input file path and output file path
err := trans.Initialize( inputPath, outputPath )
// Handle error...
// SET FRAME RATE TO MEDIAFILE
trans.MediaFile().SetFrameRate(70)
// SET ULTRAFAST PRESET TO MEDIAFILE
trans.MediaFile().SetPreset("ultrafast")
// Start transcoder process
done := trans.Run()
// Returns a channel to get the transcoding progress
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
err = <-done
}
Building...
Languages
Go
99.7%
Makefile
0.3%