commit 77972bf7c37f93dca8ab1fcf8c413eccddac3869
parent 24e28dc550af255c474da9520a2ec339d82fd079
Author: Jack Mordaunt <jackmordaunt@gmail.com>
Date: Mon, 19 Nov 2018 15:18:19 +1300
[+] Make the FFmpeg instance configurable.
Diffstat:
5 files changed, 38 insertions(+), 10 deletions(-)
diff --git a/cmd/desktop/main.go b/cmd/desktop/main.go
@@ -24,6 +24,7 @@ var (
devServer string
verbose bool
headless bool
+ ffmpeg string
static http.Handler // responsible for serving UI files.
)
@@ -33,6 +34,7 @@ func init() {
flag.StringVar(&devServer, "dev-proxy", "", "proxy to forward to (eg, yarn run serve)")
flag.BoolVar(&verbose, "v", false, "verbose mode")
flag.BoolVar(&headless, "headless", false, "headless mode; run only the server")
+ flag.StringVar(&ffmpeg, "ffmpeg", "", "custom path to ffmpeg binary")
flag.Parse()
if devServer != "" {
original := devServer
@@ -56,13 +58,14 @@ func main() {
ui := &UI{
App: &Giffer{
Downloader: &giffer.Downloader{
- Dir: "tmp/download",
+ Dir: "Giffer.app/Contents/Resources/tmp/download",
},
FFMpeg: &giffer.FFMpeg{
Debug: verbose,
+ Use: "Giffer.app/Contents/Resources/ffmpeg",
},
Store: &gifdb{
- Dir: "tmp/gifs",
+ Dir: "Giffer.app/Contents/Resources/tmp/gifs",
},
},
Router: mux.NewRouter(),
diff --git a/download.go b/download.go
@@ -36,6 +36,7 @@ import (
// Downloader is responsible for downloading videos.
type Downloader struct {
Dir string
+ FFmpeg string
}
// Download the video from URL into Dir and return the full path to the
@@ -45,6 +46,7 @@ func (dl Downloader) Download(
start, end float64,
q Quality,
) (string, error) {
+
input := fmt.Sprintf("%s_%f_%f_%s", URL, start, end, q)
h, err := hash(input)
if err != nil {
@@ -68,6 +70,7 @@ func (dl Downloader) Download(
if err := os.MkdirAll(dir, 0755); err != nil && !os.IsExist(err) {
return "", errors.Wrap(err, "preparing directories")
}
+ config.FFmpeg = dl.FFmpeg
tmp, err := Download(URL, start, end, q)
if err != nil {
return "", err
diff --git a/ffmpeg.go b/ffmpeg.go
@@ -11,6 +11,10 @@ import (
// FFMpeg wraps the ffmpeg binary.
type FFMpeg struct {
+ // Use is a path to an ffmpeg binary.
+ // If empty, system path is used.
+ Use string
+ // Debug logs the ffmpeg command.
Debug bool
}
@@ -26,7 +30,11 @@ func (f FFMpeg) Convert(
var (
out bytes.Buffer
args []string
+ bin = "ffmpeg"
)
+ if f.Use != "" {
+ bin = f.Use
+ }
args = append(args, "-i", video)
if width > 0 || height > 0 || fps > 0 {
var vfargs []string
@@ -50,13 +58,13 @@ func (f FFMpeg) Convert(
"-f", format, "-",
)
if f.Debug {
- log.Printf("ffmpeg %s", strings.Join(args, " "))
+ log.Printf("%s %s", bin, strings.Join(args, " "))
}
cmd := CmdPipe{
Out: &out,
Debug: f.Debug,
Stack: []*exec.Cmd{
- exec.Command("ffmpeg", args...),
+ exec.Command(bin, args...),
},
}
return &out, cmd.Run()
diff --git a/go.mod b/go.mod
@@ -3,16 +3,20 @@ module github.com/jackmordaunt/giffer
require (
github.com/GeertJohan/go.rice v0.0.0-20170420135705-c02ca9a983da
github.com/OneOfOne/xxhash v1.2.2
+ github.com/PuerkitoBio/goquery v1.5.0 // indirect
github.com/cespare/xxhash v1.1.0 // indirect
github.com/daaku/go.zipexe v0.0.0-20150329023125-a5fe2436ffcb // indirect
github.com/gorilla/context v1.1.1 // indirect
github.com/gorilla/mux v1.6.2
github.com/gorilla/websocket v1.4.0
github.com/hashicorp/go-multierror v1.0.0
- github.com/jackmordaunt/video-downloader v0.0.0-20181113035814-f0fc43af906f
+ github.com/jackmordaunt/icns v1.0.0
+ github.com/jackmordaunt/video-downloader v0.0.0-20181119020849-85e768ecd131
github.com/kardianos/osext v0.0.0-20170510131534-ae77be60afb1 // indirect
+ github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 // indirect
github.com/pkg/errors v0.8.0
- github.com/zserge/lorca v0.1.0
+ github.com/zserge/lorca v0.1.1
github.com/zserge/webview v0.0.0-20181018084947-f390a2df9ec5
golang.org/x/crypto v0.0.0-20181112202954-3d3f9f413869
+ golang.org/x/sys v0.0.0-20181116161606-93218def8b18 // indirect
)
diff --git a/go.sum b/go.sum
@@ -6,6 +6,8 @@ github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/PuerkitoBio/goquery v1.4.1 h1:smcIRGdYm/w7JSbcdeLHEMzxmsBQvl8lhf0dSw2nzMI=
github.com/PuerkitoBio/goquery v1.4.1/go.mod h1:T9ezsOHcCrDCgA8aF1Cqr3sSYbO/xgdy8/R/XiIMAhA=
+github.com/PuerkitoBio/goquery v1.5.0 h1:uGvmFXOA73IKluu/F84Xd1tt/z07GYm8X49XKHP7EJk=
+github.com/PuerkitoBio/goquery v1.5.0/go.mod h1:qD2PgZ9lccMbQlc7eEOjaeRlFQON7xY8kdmcsrnKqMg=
github.com/andybalholm/cascadia v1.0.0 h1:hOCXnnZ5A+3eVDX8pvgl4kofXv2ELss0bKcqRySc45o=
github.com/andybalholm/cascadia v1.0.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y=
github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko=
@@ -24,8 +26,10 @@ github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/U
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
github.com/hashicorp/go-multierror v1.0.0 h1:iVjPR7a6H0tWELX5NxNe7bYopibicUzc7uPribsnS6o=
github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
-github.com/jackmordaunt/video-downloader v0.0.0-20181113035814-f0fc43af906f h1:s8lYjFD/vbFKQ6NkbDCkdTtWRb2LCNCtQXODb3EERgA=
-github.com/jackmordaunt/video-downloader v0.0.0-20181113035814-f0fc43af906f/go.mod h1:0wZq7bsiv4eGa0JACeruRKck7gkYwIqJA/urPORdDh4=
+github.com/jackmordaunt/icns v1.0.0 h1:RYSxplerf/l/DUd09AHtITwckkv/mqjVv4DjYdPmAMQ=
+github.com/jackmordaunt/icns v1.0.0/go.mod h1:7TTQVEuGzVVfOPPlLNHJIkzA6CoV7aH1Dv9dW351oOo=
+github.com/jackmordaunt/video-downloader v0.0.0-20181119020849-85e768ecd131 h1:01N1HmUsweYcdXWs4y+3Gpfuum2yNm1v7FbY8W3/atA=
+github.com/jackmordaunt/video-downloader v0.0.0-20181119020849-85e768ecd131/go.mod h1:0wZq7bsiv4eGa0JACeruRKck7gkYwIqJA/urPORdDh4=
github.com/kardianos/osext v0.0.0-20170510131534-ae77be60afb1 h1:PJPDf8OUfOK1bb/NeTKd4f1QXZItOX389VN3B6qC8ro=
github.com/kardianos/osext v0.0.0-20170510131534-ae77be60afb1/go.mod h1:1NbS8ALrpOvjt0rHPNLyCIeMtbizbir8U//inJ+zuB8=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
@@ -39,12 +43,14 @@ github.com/mattn/go-isatty v0.0.4 h1:bnP0vzxcAdeI1zdubAl5PjU6zsERjGZb7raWodagDYs
github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
github.com/mattn/go-runewidth v0.0.3 h1:a+kO+98RDGEfo6asOGMmpodZq4FNtnGP54yps8BzLR4=
github.com/mattn/go-runewidth v0.0.3/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
+github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 h1:zYyBkD/k9seD2A7fsi6Oo2LfFZAehjjQMERAvZLEDnQ=
+github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8=
github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72 h1:qLC7fQah7D6K1B0ujays3HV9gkFtllcxhzImRR7ArPQ=
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
-github.com/zserge/lorca v0.1.0 h1:2kD6J29C7lMT8gfiFSgItrNT7FC8M71arC9AMDqch9o=
-github.com/zserge/lorca v0.1.0/go.mod h1:gTrVdXKyWxNhc8aUb1Uu3s0mY343arR1T6jUtxmBxR8=
+github.com/zserge/lorca v0.1.1 h1:MJtObbHdRxWgqd1f8SvD7ai/3KgutSByDNcasRAzJGI=
+github.com/zserge/lorca v0.1.1/go.mod h1:gTrVdXKyWxNhc8aUb1Uu3s0mY343arR1T6jUtxmBxR8=
github.com/zserge/webview v0.0.0-20181018084947-f390a2df9ec5 h1:1zYVGLwZR4gPRQdEiOBf9s63ZHGfCkQ/p99d1zHuZBQ=
github.com/zserge/webview v0.0.0-20181018084947-f390a2df9ec5/go.mod h1:a1CV8KR4Dd1eP2g+mEijGOp+HKczwdKHWyx0aPHKvo4=
golang.org/x/crypto v0.0.0-20181112202954-3d3f9f413869 h1:kkXA53yGe04D0adEYJwEVQjeBppL01Exg+fnMjfUraU=
@@ -53,7 +59,11 @@ golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73r
golang.org/x/net v0.0.0-20181102091132-c10e9556a7bc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20181108082009-03003ca0c849 h1:FSqE2GGG7wzsYUsWiQ8MZrvEd1EOyU3NCF0AW3Wtltg=
golang.org/x/net v0.0.0-20181108082009-03003ca0c849/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20181114220301-adae6a3d119a h1:gOpx8G595UYyvj8UK4+OFyY4rx037g3fmfhe5SasG3U=
+golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8 h1:YoY1wS6JYVRpIfFngRf2HHo9R9dAne3xbkGOQ5rJXjU=
golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20181116161606-93218def8b18 h1:Wh+XCfg3kNpjhdq2LXrsiOProjtQZKme5XUx7VcxwAw=
+golang.org/x/sys v0.0.0-20181116161606-93218def8b18/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
gopkg.in/cheggaaa/pb.v1 v1.0.26 h1:KbH37VyQGNNrLEz+fflXwuLLxnPNoWwUwBF783VJWUg=
gopkg.in/cheggaaa/pb.v1 v1.0.26/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw=