-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
31 changed files
with
2,976 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
package main | ||
|
||
import ( | ||
"os" | ||
|
||
log "github.com/sirupsen/logrus" | ||
"github.com/urfave/cli/v2" | ||
"github.com/yearnfar/gexrender/internal/gexrender" | ||
_ "github.com/yearnfar/gexrender/internal/gexrender/action" | ||
) | ||
|
||
func main() { | ||
app := &cli.App{ | ||
Name: "gexrender-cli", | ||
Usage: "gexrender standalone renderer", | ||
Version: "1.0.0", | ||
Flags: []cli.Flag{ | ||
&cli.StringFlag{ | ||
Name: "f", | ||
Aliases: []string{"file"}, | ||
Usage: "提供一个包含作业的json文件的相对或绝对路径代替从参数中使用json。", | ||
}, | ||
&cli.StringFlag{ | ||
Name: "b", | ||
Aliases: []string{"binary"}, | ||
Usage: "手动指定aerender二进制文件的路径,您可以将其留空以依赖于自动查找。", | ||
}, | ||
&cli.StringFlag{ | ||
Name: "w", | ||
Aliases: []string{"workpath"}, | ||
Usage: "手动覆盖gexrender默认工作目录tmpdir/gexrender。", | ||
}, | ||
&cli.BoolFlag{ | ||
Name: "stop-on-error", | ||
Usage: "如果发生处理/呈现错误,则强制aerender停止,否则aerender将报告错误并继续工作。", | ||
}, | ||
&cli.BoolFlag{ | ||
Name: "no-license", | ||
Usage: "禁止创建ae_render_only_node.txt文件(默认启用),该文件允许免费使用试用版的Adobe After Effects。", | ||
}, | ||
&cli.BoolFlag{ | ||
Name: "force-patch", | ||
Usage: "强制(重新)安装commandLineRenderer.jsx补丁。", | ||
}, | ||
&cli.BoolFlag{ | ||
Name: "debug", | ||
Usage: "启用aerender的转储命令和其他调试内容。", | ||
}, | ||
&cli.BoolFlag{ | ||
Name: "skip-cleanup", | ||
Usage: "强制在呈现完成后保留临时数据。", | ||
}, | ||
&cli.BoolFlag{ | ||
Name: "multi-frames", | ||
Usage: "(来自Adobe官网): 根据系统配置和首选项设置,可以创建更多进程来同时渲染多个帧。(参见内存和多处理首选项)。", | ||
}, | ||
&cli.BoolFlag{ | ||
Name: "max-memory-percent", | ||
Usage: `(来自Adobe官网): 指定After Effects可以使用的内存的总百分比。对于这两个值,如果安装的RAM小于给定的数量(n gb),则该值是安装的RAM的百分比,否则为n的百分比。n的值为32位Windows的2gb、64位Windows的4gb和Mac OS的3.5 GB。`, | ||
}, | ||
&cli.BoolFlag{ | ||
Name: "image-cache-percent", | ||
Usage: "(来自Adobe官网):指定用于缓存已渲染图片和镜头的最大内存百分比。", | ||
}, | ||
&cli.BoolFlag{ | ||
Name: "reuse", | ||
Usage: `(来自Adobe官网):重用当前正在运行的After Effects实例(如果找到的话)来执行gexrender。当使用一个已经运行的实例时,当渲染完成时,aerender将首选项保存到磁盘,但在效果完成后不会退出。如果没有使用这个参数,即使一个After Effects已经在运行,aerender也会启动一个新的实例. 当呈现完成时,它退出该实例,并且不保存首选项。`, | ||
}, | ||
}, | ||
Action: func(c *cli.Context) error { | ||
setting := &gexrender.Setting{ | ||
ConfigFile: c.String("f"), | ||
WorkPath: c.String("w"), | ||
StopOnError: c.Bool("stop-on-error"), | ||
NoLicense: c.Bool("no-license"), | ||
ForceCommandLinePatch: c.Bool("force-patch"), | ||
Debug: c.Bool("debug"), | ||
SkipCleanup: c.Bool("skip-cleanup"), | ||
MultiFrames: c.Bool("multi-frames"), | ||
Reuse: c.Bool("reuse"), | ||
MaxMemoryPercent: c.Int("max-memory-percent"), | ||
ImageCachePercent: c.Int("image-cache-percent"), | ||
} | ||
|
||
if c.String("f") == "" { | ||
if c.NArg() == 0 { | ||
log.Fatal("you need to provide a gexrender job json as an argument") | ||
} else { | ||
setting.Config = c.Args().First() | ||
} | ||
} | ||
|
||
err := gexrender.Render(setting) | ||
if err != nil { | ||
log.Error(err) | ||
return err | ||
} | ||
|
||
return nil | ||
}, | ||
} | ||
|
||
err := app.Run(os.Args) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module github.com/yearnfar/gexrender | ||
|
||
go 1.13 | ||
|
||
require ( | ||
github.com/go-playground/locales v0.13.0 | ||
github.com/go-playground/universal-translator v0.17.0 | ||
github.com/go-playground/validator/v10 v10.0.1 | ||
github.com/json-iterator/go v1.1.9 | ||
github.com/matoous/go-nanoid v1.1.0 | ||
github.com/sirupsen/logrus v1.4.2 | ||
github.com/urfave/cli/v2 v2.0.0 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= | ||
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY= | ||
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= | ||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= | ||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||
github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A= | ||
github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= | ||
github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q= | ||
github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= | ||
github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no= | ||
github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= | ||
github.com/go-playground/validator/v10 v10.0.1 h1:QgDDZpXlR/L3atIL2PbFt0TpazbtN7N6PxTGcgcyEUg= | ||
github.com/go-playground/validator/v10 v10.0.1/go.mod h1:uOYAAleCW8F/7oMFd6aG0GOhaH6EGOAJShg8Id5JGkI= | ||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= | ||
github.com/json-iterator/go v1.1.9 h1:9yzud/Ht36ygwatGx56VwCZtlI/2AD15T1X2sjSuGns= | ||
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= | ||
github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk= | ||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= | ||
github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y= | ||
github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= | ||
github.com/matoous/go-nanoid v1.1.0 h1:B4BSMxTVgYrCHqtovL/adb8GFkE4mPCNntOOrdZLeCk= | ||
github.com/matoous/go-nanoid v1.1.0/go.mod h1:L+uFUqrYwDgNWu5R02GrSxxcqX7ghiFuKPlKEOZ90GE= | ||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc= | ||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= | ||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 h1:Esafd1046DLDQ0W1YjYsBW+p8U2u7vzgW2SQVmlNazg= | ||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= | ||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | ||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||
github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q= | ||
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= | ||
github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo= | ||
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= | ||
github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4= | ||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= | ||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= | ||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= | ||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= | ||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= | ||
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= | ||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= | ||
github.com/urfave/cli/v2 v2.0.0 h1:+HU9SCbu8GnEUFtIBfuUNXN39ofWViIEJIp6SURMpCg= | ||
github.com/urfave/cli/v2 v2.0.0/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ= | ||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894 h1:Cz4ceDQGXuKRnVBDTS23GTn/pU5OE2C0WrNTOYK1Uuc= | ||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= | ||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= | ||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= | ||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= | ||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package gexrender | ||
|
||
import ( | ||
"encoding/json" | ||
) | ||
|
||
// Action 其他操作 | ||
type Action struct { | ||
Action string `json:"action" validate:"required"` | ||
Parameter json.RawMessage `json:"parameter" validate:"required"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package action | ||
|
||
import ( | ||
"encoding/json" | ||
"errors" | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
"strings" | ||
|
||
"github.com/yearnfar/gexrender/internal/gexrender" | ||
"github.com/yearnfar/gexrender/internal/pkg/util" | ||
) | ||
|
||
// CopyFile 拷贝文件 | ||
type Copy struct{} | ||
|
||
// Invoke 执行 | ||
func (c *Copy) Invoke(job *gexrender.Job, data []byte) (err error) { | ||
param := ©Param{} | ||
err = json.Unmarshal(data, param) | ||
if err != nil { | ||
return | ||
} | ||
|
||
err = param.Valid(job) | ||
if err != nil { | ||
return | ||
} | ||
|
||
err = util.CopyFile(param.Input, param.Output) | ||
if err != nil { | ||
err = fmt.Errorf("copy file err: %w, src: %s, dest: %s", err, param.Input, param.Output) | ||
return | ||
} | ||
return | ||
} | ||
|
||
type copyParam struct { | ||
Input string `json:"input"` | ||
Output string `json:"output"` | ||
} | ||
|
||
// Valid 校验 | ||
func (p *copyParam) Valid(job *gexrender.Job) (err error) { | ||
if p.Input == "" { | ||
err = errors.New("input can't be empty") | ||
return | ||
} else if !filepath.IsAbs(p.Input) { | ||
p.Input = filepath.Join(job.WorkPath, p.Input) | ||
} | ||
|
||
if !util.IsFile(p.Input) { | ||
err = fmt.Errorf("文件%s不存在", p.Input) | ||
return | ||
} | ||
|
||
if p.Output == "" { | ||
err = errors.New("output can't be empty") | ||
return | ||
} else if !filepath.IsAbs(p.Output) { | ||
p.Output = filepath.Join(job.WorkPath, p.Output) | ||
} | ||
|
||
if strings.HasSuffix(p.Output, "/") && !util.IsDir(p.Output) { | ||
err = os.MkdirAll(p.Output, 0755) | ||
if err != nil { | ||
err = fmt.Errorf("创建目录失败:%w", err) | ||
return | ||
} | ||
} | ||
return | ||
} | ||
|
||
func init() { | ||
gexrender.Register("@gexrender/action-copy", &Copy{}) | ||
} |
Oops, something went wrong.