-
Notifications
You must be signed in to change notification settings - Fork 569
添加 vap CLI,便于命令行调用 #301
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
utc8
wants to merge
2
commits into
Tencent:master
Choose a base branch
from
utc8:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
添加 vap CLI,便于命令行调用 #301
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,3 @@ | ||
| build/* | ||
|
|
||
| !build/libs/ |
This file contains hidden or 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,22 @@ | ||
| vap-cli | ||
| --- | ||
|
|
||
| # 使用教程 | ||
| 1. 获取 jar | ||
|
|
||
| - 方法一:[下载执行文件](https://github.com/Tencent/vap/raw/master/Android/PlayerProj/cli/build/libs/cli-1.0.jar) | ||
|
|
||
| - 方法2️二:使用 gradle 编译出 jar 产物 | ||
| > 要提前编译 animtool | ||
| > | ||
| > jar 产物默认在 `Android/PlayerProj/cli/build/libs/cli-1.0.jar` | ||
|
|
||
| 2. 执行 jar | ||
|
|
||
| 示例: | ||
| ```bash | ||
| java -jar cli-1.0.jar \ | ||
| --ffmpeg /path/to/mac/ffmpeg \ | ||
| --mp4edit /path/to/mac/mp4edit \ | ||
| -i /path/to/test_demo/simple_demo | ||
| ``` |
This file contains hidden or 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,31 @@ | ||
| plugins { | ||
| id 'java' | ||
| } | ||
|
|
||
| group 'org.example' | ||
| version '1.0' | ||
|
|
||
| repositories { | ||
| mavenCentral() | ||
| } | ||
|
|
||
| dependencies { | ||
| implementation project(path: ':animtool') | ||
| testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1' | ||
| testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1' | ||
| implementation 'info.picocli:picocli:4.7.1' | ||
| } | ||
|
|
||
| test { | ||
| useJUnitPlatform() | ||
| } | ||
|
|
||
| jar { | ||
| manifest { | ||
| attributes "Main-Class": "com.tencent.vapcli.Main" | ||
| } | ||
|
|
||
| from { | ||
| configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } | ||
| } | ||
| } |
Binary file not shown.
118 changes: 118 additions & 0 deletions
118
Android/PlayerProj/cli/src/main/java/com/tencent/vapcli/Main.java
This file contains hidden or 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,118 @@ | ||
| /* | ||
| * Tencent is pleased to support the open source community by making vap available. | ||
| * | ||
| * Copyright (C) 2020 THL A29 Limited, a Tencent company. All rights reserved. | ||
| * | ||
| * Licensed under the MIT License (the "License"); you may not use this file except in | ||
| * compliance with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://opensource.org/licenses/MIT | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software distributed under the License is | ||
| * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, | ||
| * either express or implied. See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package com.tencent.vapcli; | ||
|
|
||
| import com.tencent.qgame.playerproj.animtool.AnimTool; | ||
| import com.tencent.qgame.playerproj.animtool.CommonArg; | ||
| import picocli.CommandLine; | ||
| import picocli.CommandLine.Command; | ||
| import picocli.CommandLine.Option; | ||
|
|
||
| import java.util.concurrent.Callable; | ||
|
|
||
|
|
||
| @Command(name = "vapcli", mixinStandardHelpOptions = true, version = "1.0", | ||
| description = "Vap CLI") | ||
| public class Main implements Callable<Integer> { | ||
|
|
||
| @Option(names = {"--ffmpeg"}, description = "ffmpeg命令路径,如 /path/to/ffmpeg", required = true) | ||
| private String ffmpegBin = "ffmpeg"; | ||
|
|
||
| @Option(names = {"--mp4edit"}, description = "mp4edit命令路径,如 /path/to/mp4edit", required = true) | ||
| private String mp4editBin = "mp4edit"; | ||
|
|
||
| @Option(names = {"--h265"}, description = "是否开启h265") | ||
| private boolean enableH265 = false; | ||
|
|
||
| @Option(names = {"--enableCrf"}, description = "是否开启可变码率") | ||
| private boolean enableCrf = false; | ||
|
|
||
| @Option(names = {"--fps"}, description = "fps") | ||
| private int fps = 24; | ||
|
|
||
| @Option(names = {"-i", "--input-dir"}, description = "素材文件夹路径", required = true) | ||
| private String inputDir; | ||
|
|
||
| @Option(names = {"--scale"}, description = "alpha 区域缩放大小 (0.5 - 1)") | ||
| private float scale = 0.5f; | ||
|
|
||
| @Option(names = {"--bitrate"}, description = "码率") | ||
| private int bitrate = 2000; | ||
|
|
||
| @Option(names = {"--crf"}, description = "0(无损) - 50(最大压缩)") | ||
| private int crf = 29; | ||
|
|
||
| @Override | ||
| public Integer call() throws Exception { | ||
| final CommonArg commonArg = new CommonArg(); | ||
|
|
||
| commonArg.ffmpegCmd = this.ffmpegBin; | ||
| commonArg.mp4editCmd = this.mp4editBin; | ||
| commonArg.enableH265 = this.enableH265; | ||
| commonArg.fps = this.fps; | ||
| commonArg.inputPath = this.inputDir; | ||
| commonArg.scale = this.scale; | ||
| commonArg.bitrate = this.bitrate; | ||
| commonArg.crf = this.crf; | ||
|
|
||
| System.out.println("all args:"); | ||
| for(String str: commonArg.toString().replaceFirst("CommonArg\\{", "").split(", ")) { | ||
| System.out.println("\t" + str); | ||
| } | ||
|
|
||
| AnimTool animTool = new AnimTool(); | ||
|
|
||
| animTool.setToolListener(new AnimTool.IToolListener() { | ||
| @Override | ||
| public void onProgress(float progress) { | ||
| int p = (int)(progress * 100f); | ||
| System.out.println("onProgress: " + (Math.min(p, 99)) + "%"); | ||
| } | ||
|
|
||
| @Override | ||
| public void onWarning(String msg) { | ||
| System.err.println("onWarning: " + msg); | ||
| } | ||
|
|
||
| @Override | ||
| public void onError() { | ||
| System.err.println("onError!!!!!!!!"); | ||
| System.exit(1); | ||
| } | ||
|
|
||
| @Override | ||
| public void onComplete() { | ||
| System.out.println("onComplete: " + commonArg.outputPath); | ||
| System.exit(0); | ||
| } | ||
| }); | ||
|
|
||
| try { | ||
| animTool.create(commonArg, true); | ||
| } catch (Exception e) { | ||
| e.printStackTrace(); | ||
| System.exit(1); | ||
| } | ||
|
|
||
| return 0; | ||
| } | ||
|
|
||
| public static void main(String[] args) { | ||
| System.out.println("Vap CLI START"); | ||
|
|
||
| new CommandLine(new Main()).execute(args); | ||
| } | ||
| } | ||
This file contains hidden or 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 |
|---|---|---|
| @@ -1 +1 @@ | ||
| include ':app', ':animtool', ':animplayer' | ||
| include ':app', ':animtool', ':animplayer', ":cli" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.