- Joined
- May 30, 2018
- Messages
- 27
- Reaction score
- 4
I have been using the Gobot sample code to display video into mplayer, and do a simple takeoff/landing.
How can I use mplayer to save the video stream to a file? I've seen something called -dumpstream (and -dumpfile) but I don't know how I'd apply this here.
Code:
package main
import (
"fmt"
"os/exec"
"time"
"gobot.io/x/gobot"
"gobot.io/x/gobot/platforms/dji/tello"
)
func main() {
drone := tello.NewDriver("8890")
work := func() {
mplayer := exec.Command("mplayer","-fps", "25", "-")
mplayerIn, _ := mplayer.StdinPipe()
if err := mplayer.Start(); err != nil {
fmt.Println(err)
return
}
drone.On(tello.ConnectedEvent, func(data interface{}) {
fmt.Println("Connected")
drone.StartVideo()
drone.SetVideoEncoderRate(5)
gobot.Every(100*time.Millisecond, func() {
drone.StartVideo()
})
})
drone.TakeOff()
gobot.After(5*time.Second, func() {
drone.Land()
})
drone.On(tello.VideoFrameEvent, func(data interface{}) {
pkt := data.([]byte)
if _, err := mplayerIn.Write(pkt); err != nil {
fmt.Println(err)
}
})
}
robot := gobot.NewRobot("tello",
[]gobot.Connection{},
[]gobot.Device{drone},
work,
)
robot.Start()
}
How can I use mplayer to save the video stream to a file? I've seen something called -dumpstream (and -dumpfile) but I don't know how I'd apply this here.