├── .gitignore
├── .travis.yml
├── README.md
├── build.gradle
├── deploy.sh
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── misc
└── logo.png
├── settings.gradle
└── src
├── main
└── java
│ └── com
│ └── github
│ └── vbauer
│ └── avconv4java
│ ├── core
│ ├── AVCommand.java
│ ├── AVOptions.java
│ └── AVRootOptions.java
│ ├── option
│ ├── AVAudioOptions.java
│ ├── AVCodecOptions.java
│ ├── AVFormatOptions.java
│ ├── AVGenericOptions.java
│ ├── AVMainOptions.java
│ ├── AVSubtitleOptions.java
│ ├── AVVideoOptions.java
│ └── advanced
│ │ ├── AVAdvancedOptions.java
│ │ └── AVAdvancedVideoOptions.java
│ ├── type
│ ├── AVAudioCodecType.java
│ ├── AVCodecFlagType.java
│ ├── AVDebugInfoType.java
│ ├── AVErrorDetectionType.java
│ ├── AVFileFormatType.java
│ ├── AVFormatDebugInfoType.java
│ ├── AVFormatFlagType.java
│ ├── AVHardwareAccelerationType.java
│ ├── AVLogLevelType.java
│ ├── AVMotionEstimationType.java
│ ├── AVMovFlagsType.java
│ ├── AVStreamType.java
│ ├── AVStrictType.java
│ ├── AVTargetFileType.java
│ ├── AVVideoCodecType.java
│ ├── AVVideoSizeType.java
│ ├── AVVideoSyncType.java
│ └── NamedType.java
│ └── util
│ ├── AVUtils.java
│ └── process
│ ├── ProcessExecutor.java
│ └── ProcessInfo.java
└── test
├── kotlin
└── com
│ └── github
│ └── vbauer
│ └── avconv4java
│ ├── common
│ └── TestUtils.kt
│ ├── core
│ ├── AVCommandTest.kt
│ ├── AVOptionsTest.kt
│ └── AVRootOptionsTest.kt
│ ├── option
│ ├── AVAudioOptionsTest.kt
│ ├── AVCodecOptionsTest.kt
│ ├── AVFormatOptionsTest.kt
│ ├── AVGenericOptionsTest.kt
│ ├── AVMainOptionsTest.kt
│ ├── AVSubtitleOptionsTest.kt
│ ├── AVVideoOptionsTest.kt
│ └── advanced
│ │ ├── AVAdvancedOptionsTest.kt
│ │ └── AVAdvancedVideoOptionsTest.kt
│ ├── type
│ ├── ModelTest.kt
│ └── TypeTest.kt
│ └── util
│ ├── AVUtilsTest.kt
│ └── ProcessExecutorTest.kt
└── resources
└── TODO.txt
/.gitignore:
--------------------------------------------------------------------------------
1 | # Created by https://www.gitignore.io
2 |
3 | ### Java ###
4 | # Covered by the "target/" directory
5 | # *.class
6 |
7 | # Mobile Tools for Java (J2ME)
8 | .mtj.tmp/
9 |
10 | # Package Files #
11 | *.war
12 | *.ear
13 |
14 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
15 | hs_err_pid*
16 |
17 |
18 | ### JetBrains ###
19 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm
20 |
21 | *.iml
22 |
23 | ## Directory-based project format:
24 | .idea/
25 | # if you remove the above rule, at least ignore the following:
26 |
27 | # User-specific stuff:
28 | # .idea/workspace.xml
29 | # .idea/tasks.xml
30 | # .idea/dictionaries
31 |
32 | # Sensitive or high-churn files:
33 | # .idea/dataSources.ids
34 | # .idea/dataSources.xml
35 | # .idea/sqlDataSources.xml
36 | # .idea/dynamic.xml
37 | # .idea/uiDesigner.xml
38 |
39 | # Gradle:
40 | # .idea/gradle.xml
41 | # .idea/libraries
42 | build/
43 |
44 | # Mongo Explorer plugin:
45 | # .idea/mongoSettings.xml
46 |
47 | ## File-based project format:
48 | *.ipr
49 | *.iws
50 |
51 | ## Plugin-specific files:
52 |
53 | # IntelliJ
54 | out/
55 |
56 | # mpeltonen/sbt-idea plugin
57 | .idea_modules/
58 |
59 | # JIRA plugin
60 | atlassian-ide-plugin.xml
61 |
62 | # Crashlytics plugin (for Android Studio and IntelliJ)
63 | com_crashlytics_export_strings.xml
64 | crashlytics.properties
65 | crashlytics-build.properties
66 |
67 |
68 | ### Maven ###
69 | target/
70 | pom.xml.tag
71 | pom.xml.releaseBackup
72 | pom.xml.versionsBackup
73 | pom.xml.next
74 | release.properties
75 |
76 |
77 | ### Eclipse ###
78 | *.pydevproject
79 | .metadata
80 | .gradle
81 | bin/
82 | tmp/
83 | *.tmp
84 | *.bak
85 | *.swp
86 | *~.nib
87 | local.properties
88 | .settings/
89 | .loadpath
90 |
91 | # Eclipse Core
92 | .project
93 |
94 | # External tool builders
95 | .externalToolBuilders/
96 |
97 | # Locally stored "Eclipse launch configurations"
98 | *.launch
99 |
100 | # CDT-specific
101 | .cproject
102 |
103 | # JDT-specific (Eclipse Java Development Tools)
104 | .classpath
105 |
106 | # PDT-specific
107 | .buildpath
108 |
109 | # sbteclipse plugin
110 | .target
111 |
112 | # TeXlipse plugin
113 | .texlipse
114 |
115 |
116 | ### Windows ###
117 | # Windows image file caches
118 | Thumbs.db
119 | ehthumbs.db
120 |
121 | # Folder config file
122 | Desktop.ini
123 |
124 | # Recycle Bin used on file shares
125 | $RECYCLE.BIN/
126 |
127 | # Windows Installer files
128 | *.cab
129 | *.msi
130 | *.msm
131 | *.msp
132 |
133 | # Windows shortcuts
134 | *.lnk
135 |
136 |
137 | ### OSX ###
138 | .DS_Store
139 | .AppleDouble
140 | .LSOverride
141 |
142 | # Icon must end with two \r
143 | Icon
144 |
145 |
146 | # Thumbnails
147 | ._*
148 |
149 | # Files that might appear on external disk
150 | .Spotlight-V100
151 | .Trashes
152 |
153 | # Directories potentially created on remote AFP share
154 | .AppleDB
155 | .AppleDesktop
156 | Network Trash Folder
157 | Temporary Items
158 | .apdisk
159 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: java
2 | jdk:
3 | - oraclejdk8
4 | - openjdk11
5 |
6 | sudo: false
7 |
8 | before_install:
9 | - chmod +x gradlew deploy.sh
10 |
11 | script:
12 | - ./gradlew build --stacktrace
13 |
14 | after_success:
15 | - ./gradlew jacocoTestReport coveralls --stacktrace
16 | - bash ./deploy.sh
17 |
18 | before_cache:
19 | - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
20 | cache:
21 | directories:
22 | - $HOME/.gradle/caches/
23 | - $HOME/.gradle/wrapper/
24 |
25 | env:
26 | global:
27 | - TERM=dumb
28 | - GH_REF: github.com/vbauer/avconv4java.git
29 | - secure: "Rki2d/a/sy4/C6/o5hWNX/HOFOFs6vn4IDnrs8viQoGwmbD6czmhbCVAuSchOXns1N69lNU1O3IDSksKk5Omwai0nSyOewsAlq7PoNB12TgEu5MbJOazqZnFqaPLEcyTc6Kkju1b3Qje5XNo5pspxN5ZknXD/fMsZPcFQ5+EwgY="
30 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 | # avconv4java
3 |
4 | [](https://travis-ci.org/vbauer/avconv4java)
5 | [](https://coveralls.io/r/vbauer/avconv4java)
6 | [](http://opensource.org/licenses/Apache-2.0)
7 | [](https://jitpack.io/#vbauer/avconv4java)
8 | [](https://www.codacy.com/app/bauer-vlad/avconv4java)
9 |
10 |
11 | ## Introduction
12 |
13 |
14 |
15 | **avconv** tool is a part of the [Libav](http://libav.org) project (originates from the FFmpeg codebase).
16 | It is a fast and powerful video and audio converter.
17 | Libav supports most common instruction set architectures (including IA-32, x86-64, PowerPC, ARM, etc.) with great performance.
18 |
19 | **avconv4java** is a simple pure-java interface to the [avconv](http://libav.org/avconv.html) command-line tool.
20 | API was designed with KISS principle in mind to be as simple as possible.
21 |
22 | **Online documentation:**
23 |
24 | * [Maven site](https://vbauer.github.io/avconv4java)
25 | * [Javadoc](https://vbauer.github.io/avconv4java/apidocs)
26 |
27 |
28 | ## Features
29 |
30 | * Most avconv commands are supported (and tested in real projects).
31 | * Parallel processing is supported out of box.
32 | * It has a very simple API with fluent interfaces and method chaining.
33 | * Options and operators are transformed into similar method-names, e.g.
34 | * -vcodec libx264 -> .videoCodec(AVVideoCodecType.H264)
35 | * -vcodec libtheora -> .videoCodec(AVVideoCodecType.THEORA)
36 | * -vcodec libtheora -> .videoCodec("libtheora")
37 |
38 |
39 | ## Setup
40 |
41 | Gradle:
42 | ```groovy
43 | repositories {
44 | maven {
45 | url "https://jitpack.io"
46 | }
47 | }
48 |
49 | dependencies {
50 | compile 'com.github.vbauer:avconv4java:1.2.3'
51 | }
52 | ```
53 |
54 | Maven:
55 | ```xml
56 |
57 | jitpack.io
58 | https://jitpack.io
59 |
60 |
61 |
62 | com.github.vbauer
63 | avconv4java
64 | 1.2.3
65 |
66 | ```
67 |
68 |
69 | ## Example
70 |
71 | First of all you need to configure options for avconv command. Builder pattern allows to do it as simple as possible:
72 |
73 | ```java
74 | final AVRootOptions options = AVRootOptions.create("input.avi", "output.mp4")
75 | .builders(
76 | AVMainOptions.create()
77 | .overwriteOutput(),
78 | AVVideoOptions.create()
79 | .proportionalResizeUsingWidth(800)
80 | .videoCodec(AVVideoCodecType.H264)
81 | .movFlags(AVMovFlagsType.FAST_START),
82 | AVAudioOptions.create()
83 | .audioCodec(AVAudioCodecType.VISUAL_ON_AAC)
84 | .audioBitRate(128)
85 | .audioChannelsCount(2)
86 | .sampleRate(11025),
87 | AVCodecOptions.create()
88 | .bitRate(1000)
89 | )
90 | ```
91 |
92 | To execute avconv command with needed options you should use the class com.avconv4java.core.AVCommnad:
93 |
94 | ```java
95 | // It'll be better to configure timeout always. Debug is useful sometimes.
96 | final AVCommand command = AVCommand.create()
97 | .setDebug(true)
98 | .setTimeout(timeout);
99 |
100 | final int returnCode = command.run(options);
101 | final String outputFile = options.getOutputFile();
102 |
103 | Logger.getGlobal().info(
104 | String.format("Output file: %s, return code: %d", outputFile, returnCode)
105 | );
106 |
107 | ```
108 |
109 | This command is equivalent to the following:
110 |
111 |
112 | ```bash
113 | /usr/bin/avconv -i input.avi -y -vf scale=w=800:h=trunc(ow/a/2)*2 -vcodec libx264 -movflags faststart -acodec libvo_aacenc -ab 128k -b 1000k -ac 2 -ar 11025 output.mp4
114 | ```
115 |
116 |
117 | ## FAQ
118 |
119 |
120 | - What is the default avconv path value?
121 | - Environment variable "AVCONV4JAVA_TOOLPATH" will be checked in priority, otherwise it will be "/usr/bin/avconv".
122 |
123 |
124 |
125 | ## Might also like
126 |
127 | * [jconditions](https://github.com/vbauer/jconditions) - Extra conditional annotations for JUnit.
128 | * [jackdaw](https://github.com/vbauer/jackdaw) - Java Annotation Processor which allows to simplify development.
129 | * [houdini](https://github.com/vbauer/houdini) - Type conversion system for Spring framework.
130 | * [herald](https://github.com/vbauer/herald) - Logging annotation for Spring framework.
131 | * [caesar](https://github.com/vbauer/caesar) - Library that allows to create async beans from sync beans.
132 | * [commons-vfs2-cifs](https://github.com/vbauer/commons-vfs2-cifs) - SMB/CIFS provider for Commons VFS.
133 |
134 |
135 | ## License
136 |
137 | ```
138 | Copyright 2014 Vladislav Bauer
139 |
140 | Licensed under the Apache License, Version 2.0 (the "License");
141 | you may not use this file except in compliance with the License.
142 | You may obtain a copy of the License at
143 |
144 | http://www.apache.org/licenses/LICENSE-2.0
145 |
146 | Unless required by applicable law or agreed to in writing, software
147 | distributed under the License is distributed on an "AS IS" BASIS,
148 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
149 | See the License for the specific language governing permissions and
150 | limitations under the License.
151 | ```
152 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 |
2 | plugins {
3 | id 'java'
4 | id 'jacoco'
5 | id 'org.jetbrains.kotlin.jvm' version '1.3.31'
6 | id 'com.github.kt3k.coveralls' version '2.8.2'
7 | id 'com.github.ben-manes.versions' version '0.21.0'
8 | id 'ru.vyarus.quality' version '3.4.0'
9 | id 'ru.vyarus.java-lib' version '1.1.2'
10 | }
11 |
12 | group 'com.github.vbauer'
13 | version '1.2.3'
14 | description 'Pure-java interface to the avconv commandline'
15 |
16 | repositories {
17 | mavenLocal()
18 | mavenCentral()
19 | }
20 |
21 | configurations.provided.extendsFrom configurations.annotationProcessor
22 |
23 | ext.deps = [
24 | testng: '6.14.3',
25 | hamcrest: '2.1',
26 | jpcc: '1.2.0'
27 | ]
28 |
29 | dependencies {
30 | testImplementation "org.testng:testng:${deps.testng}"
31 | testImplementation "org.hamcrest:hamcrest-library:${deps.hamcrest}"
32 | testImplementation "com.pushtorefresh.java-private-constructor-checker:checker:${deps.jpcc}"
33 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
34 | }
35 |
36 | wrapper {
37 | gradleVersion = '5.4.1'
38 | distributionType = Wrapper.DistributionType.ALL
39 | }
40 |
41 | tasks.withType(Javadoc) {
42 | options.addStringOption('Xdoclint:none', '-quiet')
43 | options.addBooleanOption('html5', true)
44 | }
45 |
46 | String javaVersion = JavaVersion.VERSION_1_8
47 |
48 | compileJava {
49 | sourceCompatibility javaVersion
50 | targetCompatibility javaVersion
51 | }
52 |
53 | compileKotlin {
54 | kotlinOptions {
55 | jvmTarget = javaVersion
56 | }
57 | }
58 | compileTestKotlin {
59 | kotlinOptions {
60 | jvmTarget = javaVersion
61 | }
62 | }
63 |
64 | test {
65 | useTestNG()
66 | }
67 |
68 | quality {
69 | pmd = false
70 | }
71 |
72 | jacocoTestReport {
73 | reports {
74 | xml.enabled = true
75 | html.enabled = true
76 | }
77 | }
78 |
79 | pom {
80 | inceptionYear '2013'
81 | licenses {
82 | license {
83 | name 'Apache License, Version 2.0'
84 | url 'http://www.apache.org/licenses/LICENSE-2.0'
85 | distribution 'repo'
86 | }
87 | }
88 | developers {
89 | developer {
90 | id 'vbauer'
91 | name 'Vladislav Bauer'
92 | email 'bauer.vlad@gmail.com'
93 | url 'http://linkedin.com/in/vladislavbauer'
94 | roles {
95 | role 'Developer'
96 | }
97 | }
98 | }
99 | issueManagement {
100 | system 'GitHub Issues'
101 | url 'https://github.com/vbauer/avconv4java/issues'
102 | }
103 | ciManagement {
104 | system 'Travis'
105 | url 'https://travis-ci.org/vbauer/avconv4java'
106 | }
107 | }
108 |
--------------------------------------------------------------------------------
/deploy.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Exit with nonzero exit code if anything fails
4 | set -e
5 |
6 | # Lets work only for master
7 | if ! [ "$TRAVIS_BRANCH" = "master" ]
8 | then
9 | echo "Not a master, not deploying"
10 | exit 0
11 | fi
12 |
13 | # Generate Javadoc
14 | ./gradlew javadoc
15 |
16 | # Go to the generated directory and create a *new* Git repo
17 | cd build/docs/javadoc
18 | git init
19 |
20 | # Inside this git repo we'll pretend to be a new user
21 | git config user.name "Vladislav Bauer"
22 | git config user.email "bauer.vlad@gmail.com"
23 |
24 | # The first and only commit to this new Git repo contains all the
25 | # files present with the commit message "Generate Maven Site"
26 | git add .
27 | git commit -m "Generate Maven Site"
28 |
29 | # Force push from the current repo's master branch to the remote
30 | # repo's gh-pages branch. (All previous history on the gh-pages branch
31 | # will be lost, since we are overwriting it.) We redirect any output to
32 | # /dev/null to hide any sensitive credential data that might otherwise be exposed
33 | git push --force --quiet "https://${GH_TOKEN}@${GH_REF}" master:gh-pages > /dev/null 2>&1
34 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vbauer/avconv4java/a48b6dec8e396a759d7e3660bc2cbcb83c61aab7/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | #
4 | # Copyright 2015 the original author or authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | ##############################################################################
20 | ##
21 | ## Gradle start up script for UN*X
22 | ##
23 | ##############################################################################
24 |
25 | # Attempt to set APP_HOME
26 | # Resolve links: $0 may be a link
27 | PRG="$0"
28 | # Need this for relative symlinks.
29 | while [ -h "$PRG" ] ; do
30 | ls=`ls -ld "$PRG"`
31 | link=`expr "$ls" : '.*-> \(.*\)$'`
32 | if expr "$link" : '/.*' > /dev/null; then
33 | PRG="$link"
34 | else
35 | PRG=`dirname "$PRG"`"/$link"
36 | fi
37 | done
38 | SAVED="`pwd`"
39 | cd "`dirname \"$PRG\"`/" >/dev/null
40 | APP_HOME="`pwd -P`"
41 | cd "$SAVED" >/dev/null
42 |
43 | APP_NAME="Gradle"
44 | APP_BASE_NAME=`basename "$0"`
45 |
46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
48 |
49 | # Use the maximum available, or set MAX_FD != -1 to use that value.
50 | MAX_FD="maximum"
51 |
52 | warn () {
53 | echo "$*"
54 | }
55 |
56 | die () {
57 | echo
58 | echo "$*"
59 | echo
60 | exit 1
61 | }
62 |
63 | # OS specific support (must be 'true' or 'false').
64 | cygwin=false
65 | msys=false
66 | darwin=false
67 | nonstop=false
68 | case "`uname`" in
69 | CYGWIN* )
70 | cygwin=true
71 | ;;
72 | Darwin* )
73 | darwin=true
74 | ;;
75 | MINGW* )
76 | msys=true
77 | ;;
78 | NONSTOP* )
79 | nonstop=true
80 | ;;
81 | esac
82 |
83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
84 |
85 | # Determine the Java command to use to start the JVM.
86 | if [ -n "$JAVA_HOME" ] ; then
87 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
88 | # IBM's JDK on AIX uses strange locations for the executables
89 | JAVACMD="$JAVA_HOME/jre/sh/java"
90 | else
91 | JAVACMD="$JAVA_HOME/bin/java"
92 | fi
93 | if [ ! -x "$JAVACMD" ] ; then
94 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
95 |
96 | Please set the JAVA_HOME variable in your environment to match the
97 | location of your Java installation."
98 | fi
99 | else
100 | JAVACMD="java"
101 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
102 |
103 | Please set the JAVA_HOME variable in your environment to match the
104 | location of your Java installation."
105 | fi
106 |
107 | # Increase the maximum file descriptors if we can.
108 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
109 | MAX_FD_LIMIT=`ulimit -H -n`
110 | if [ $? -eq 0 ] ; then
111 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
112 | MAX_FD="$MAX_FD_LIMIT"
113 | fi
114 | ulimit -n $MAX_FD
115 | if [ $? -ne 0 ] ; then
116 | warn "Could not set maximum file descriptor limit: $MAX_FD"
117 | fi
118 | else
119 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
120 | fi
121 | fi
122 |
123 | # For Darwin, add options to specify how the application appears in the dock
124 | if $darwin; then
125 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
126 | fi
127 |
128 | # For Cygwin, switch paths to Windows format before running java
129 | if $cygwin ; then
130 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
131 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
132 | JAVACMD=`cygpath --unix "$JAVACMD"`
133 |
134 | # We build the pattern for arguments to be converted via cygpath
135 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
136 | SEP=""
137 | for dir in $ROOTDIRSRAW ; do
138 | ROOTDIRS="$ROOTDIRS$SEP$dir"
139 | SEP="|"
140 | done
141 | OURCYGPATTERN="(^($ROOTDIRS))"
142 | # Add a user-defined pattern to the cygpath arguments
143 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
144 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
145 | fi
146 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
147 | i=0
148 | for arg in "$@" ; do
149 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
150 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
151 |
152 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
153 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
154 | else
155 | eval `echo args$i`="\"$arg\""
156 | fi
157 | i=$((i+1))
158 | done
159 | case $i in
160 | (0) set -- ;;
161 | (1) set -- "$args0" ;;
162 | (2) set -- "$args0" "$args1" ;;
163 | (3) set -- "$args0" "$args1" "$args2" ;;
164 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
165 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
166 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
167 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
168 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
169 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
170 | esac
171 | fi
172 |
173 | # Escape application args
174 | save () {
175 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
176 | echo " "
177 | }
178 | APP_ARGS=$(save "$@")
179 |
180 | # Collect all arguments for the java command, following the shell quoting and substitution rules
181 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
182 |
183 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
184 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
185 | cd "$(dirname "$0")"
186 | fi
187 |
188 | exec "$JAVACMD" "$@"
189 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem http://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
33 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
34 |
35 | @rem Find java.exe
36 | if defined JAVA_HOME goto findJavaFromJavaHome
37 |
38 | set JAVA_EXE=java.exe
39 | %JAVA_EXE% -version >NUL 2>&1
40 | if "%ERRORLEVEL%" == "0" goto init
41 |
42 | echo.
43 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
44 | echo.
45 | echo Please set the JAVA_HOME variable in your environment to match the
46 | echo location of your Java installation.
47 |
48 | goto fail
49 |
50 | :findJavaFromJavaHome
51 | set JAVA_HOME=%JAVA_HOME:"=%
52 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
53 |
54 | if exist "%JAVA_EXE%" goto init
55 |
56 | echo.
57 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
58 | echo.
59 | echo Please set the JAVA_HOME variable in your environment to match the
60 | echo location of your Java installation.
61 |
62 | goto fail
63 |
64 | :init
65 | @rem Get command-line arguments, handling Windows variants
66 |
67 | if not "%OS%" == "Windows_NT" goto win9xME_args
68 |
69 | :win9xME_args
70 | @rem Slurp the command line arguments.
71 | set CMD_LINE_ARGS=
72 | set _SKIP=2
73 |
74 | :win9xME_args_slurp
75 | if "x%~1" == "x" goto execute
76 |
77 | set CMD_LINE_ARGS=%*
78 |
79 | :execute
80 | @rem Setup the command line
81 |
82 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
83 |
84 | @rem Execute Gradle
85 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
86 |
87 | :end
88 | @rem End local scope for the variables with windows NT shell
89 | if "%ERRORLEVEL%"=="0" goto mainEnd
90 |
91 | :fail
92 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
93 | rem the _cmd.exe /c_ return code!
94 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
95 | exit /b 1
96 |
97 | :mainEnd
98 | if "%OS%"=="Windows_NT" endlocal
99 |
100 | :omega
101 |
--------------------------------------------------------------------------------
/misc/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vbauer/avconv4java/a48b6dec8e396a759d7e3660bc2cbcb83c61aab7/misc/logo.png
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = 'avconv4java'
2 |
--------------------------------------------------------------------------------
/src/main/java/com/github/vbauer/avconv4java/core/AVCommand.java:
--------------------------------------------------------------------------------
1 | package com.github.vbauer.avconv4java.core;
2 |
3 | import com.github.vbauer.avconv4java.util.AVUtils;
4 | import com.github.vbauer.avconv4java.util.process.ProcessExecutor;
5 | import com.github.vbauer.avconv4java.util.process.ProcessInfo;
6 |
7 | import java.util.LinkedList;
8 | import java.util.List;
9 | import java.util.concurrent.atomic.AtomicReference;
10 |
11 | /**
12 | * Class that represents a avconv command.
13 | *
14 | * @author Vladislav Bauer
15 | */
16 |
17 | public class AVCommand {
18 |
19 | public static final String DEFAULT_TOOL_PATH = "/usr/bin/avconv";
20 | public static final String SYSTEM_PROPERTY_TOOL_PATH = "AVCONV4JAVA_TOOLPATH";
21 |
22 | private static final AtomicReference GLOBAL_TOOL_PATH = new AtomicReference<>(getDefaultToolPath());
23 |
24 |
25 | private boolean debug;
26 | private String toolPath;
27 | private Long timeout;
28 |
29 |
30 | public static String getDefaultToolPath() {
31 | final String env = AVUtils.getSystemProperty(SYSTEM_PROPERTY_TOOL_PATH);
32 | return env == null ? DEFAULT_TOOL_PATH : env;
33 | }
34 |
35 | public static String setGlobalToolPath(final String toolPath) {
36 | AVCommand.GLOBAL_TOOL_PATH.set(toolPath);
37 | return toolPath;
38 | }
39 |
40 | public static String getGlobalToolPath() {
41 | return AVCommand.GLOBAL_TOOL_PATH.get();
42 | }
43 |
44 |
45 | public ProcessInfo run(final AVOptions operation) throws Exception {
46 | final List flags = operation.build();
47 | return run(flags);
48 | }
49 |
50 | public ProcessInfo run(final List flags) throws Exception {
51 | final List arguments = prepareArguments(flags);
52 | return ProcessExecutor.execute(arguments, getTimeout(), isDebug());
53 | }
54 |
55 |
56 | public boolean isDebug() {
57 | return debug;
58 | }
59 |
60 | public AVCommand setDebug(final Boolean debug) {
61 | this.debug = Boolean.TRUE.equals(debug);
62 | return this;
63 | }
64 |
65 | public Long getTimeout() {
66 | return timeout;
67 | }
68 |
69 | public AVCommand setTimeout(final Long timeout) {
70 | this.timeout = timeout;
71 | return this;
72 | }
73 |
74 | public String getToolPath() {
75 | return toolPath;
76 | }
77 |
78 | public AVCommand setToolPath(final String toolPath) {
79 | this.toolPath = toolPath;
80 | return this;
81 | }
82 |
83 |
84 | /*
85 | * Internal API.
86 | */
87 |
88 | protected List prepareArguments(final List flags) {
89 | final String path = calculateToolPath();
90 | final List parameters = new LinkedList<>();
91 |
92 | parameters.add(path);
93 | if (flags != null) {
94 | parameters.addAll(flags);
95 | }
96 | return parameters;
97 | }
98 |
99 | protected String calculateToolPath() {
100 | final String toolPath = getToolPath();
101 | return toolPath == null ? getGlobalToolPath() : toolPath;
102 | }
103 |
104 | }
105 |
--------------------------------------------------------------------------------
/src/main/java/com/github/vbauer/avconv4java/core/AVOptions.java:
--------------------------------------------------------------------------------
1 | package com.github.vbauer.avconv4java.core;
2 |
3 | import com.github.vbauer.avconv4java.type.AVStreamType;
4 | import com.github.vbauer.avconv4java.util.AVUtils;
5 |
6 | import java.util.Collection;
7 | import java.util.LinkedList;
8 | import java.util.List;
9 |
10 | /**
11 | * Basic class for options.
12 | *
13 | * @author Vladislav Bauer
14 | */
15 |
16 | public class AVOptions {
17 |
18 | private final List options = new LinkedList<>();
19 | private final List arguments = new LinkedList<>();
20 |
21 |
22 | public static AVOptions create() {
23 | return new AVOptions();
24 | }
25 |
26 |
27 | @Override
28 | public String toString() {
29 | return AVUtils.join(build());
30 | }
31 |
32 |
33 | public AVOptions flags(final Collection