From cac22540c00e6ea8cc80d4a82e0b7843b96bb4c1 Mon Sep 17 00:00:00 2001 From: saxon Date: Wed, 4 Jul 2018 22:44:39 +0930 Subject: [PATCH] Using flag for rtmp url --- revid/cmd/h264-file-to-flv-rtmp/main.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/revid/cmd/h264-file-to-flv-rtmp/main.go b/revid/cmd/h264-file-to-flv-rtmp/main.go index 389cc239..082bd549 100644 --- a/revid/cmd/h264-file-to-flv-rtmp/main.go +++ b/revid/cmd/h264-file-to-flv-rtmp/main.go @@ -28,33 +28,41 @@ LICENSE package main import ( + "flag" + "log" "time" - "fmt" "bitbucket.org/ausocean/av/revid" ) const ( inputFile = "../../../../test/test-data/av/input/betterInput.h264" - rtmpUrl = "rtmp://a.rtmp.youtube.com/live2/v70c-qu3x-2bs4-esek" frameRate = "25" runDuration = 120 * time.Second ) // Test h264 inputfile to flv format into rtmp using librtmp c wrapper func main() { + // Get the rtmp url from a cmd flag + rtmpUrlPtr := flag.String("rtmpUrl", "", "The rtmp url you would like to stream to.") + flag.Parse() + if *rtmpUrlPtr == "" { + log.Println("No RTMP url passed!") + return + } + config := revid.Config{ Input: revid.File, InputFileName: inputFile, InputCodec: revid.H264, Output: revid.Rtmp, RtmpMethod: revid.LibRtmp, - RtmpUrl: rtmpUrl, + RtmpUrl: *rtmpUrlPtr, Packetization: revid.Flv, } revidInst, err := revid.New(config, nil) if err != nil { - fmt.Printf("Should not of have got an error!: %v\n", err.Error()) + log.Printf("Should not of have got an error!: %v\n", err.Error()) return } revidInst.Start()