1
0
mirror of https://github.com/hybridgroup/gobot.git synced 2025-05-14 19:29:32 +08:00

tello: switch simple video playback example to use MPlayer

Signed-off-by: Ron Evans <ron@hybridgroup.com>
This commit is contained in:
Ron Evans 2018-04-20 10:29:45 +02:00
parent 9875acbe06
commit 5bae84594f

View File

@ -3,8 +3,8 @@
// Do not build by default. // Do not build by default.
/* /*
You must have ffmpeg and ffplay installed in order to run this code. it will connect to the Tello You must have MPlayer (https://mplayerhq.hu) installed in order to run this code. it will connect to the Tello
and then open a window using ffplay showing the streaming video. and then open a window using MPlayer showing the streaming video.
How to run How to run
@ -26,9 +26,9 @@ func main() {
drone := tello.NewDriver("8890") drone := tello.NewDriver("8890")
work := func() { work := func() {
ffplay := exec.Command("ffplay", "-fast", "-i", "pipe:0") mplayer := exec.Command("mplayer", "-fps", "25", "-")
ffplayIn, _ := ffplay.StdinPipe() mplayerIn, _ := mplayer.StdinPipe()
if err := ffplay.Start(); err != nil { if err := mplayer.Start(); err != nil {
fmt.Println(err) fmt.Println(err)
return return
} }
@ -37,14 +37,14 @@ func main() {
fmt.Println("Connected") fmt.Println("Connected")
drone.StartVideo() drone.StartVideo()
drone.SetVideoEncoderRate(4) drone.SetVideoEncoderRate(4)
gobot.Every(250*time.Millisecond, func() { gobot.Every(100*time.Millisecond, func() {
drone.StartVideo() drone.StartVideo()
}) })
}) })
drone.On(tello.VideoFrameEvent, func(data interface{}) { drone.On(tello.VideoFrameEvent, func(data interface{}) {
pkt := data.([]byte) pkt := data.([]byte)
if _, err := ffplayIn.Write(pkt); err != nil { if _, err := mplayerIn.Write(pkt); err != nil {
fmt.Println(err) fmt.Println(err)
} }
}) })