├── .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 | [![Build Status](http://img.shields.io/travis/vbauer/avconv4java.svg?style=flat)](https://travis-ci.org/vbauer/avconv4java) 5 | [![Coverage Status](https://coveralls.io/repos/vbauer/avconv4java/badge.svg)](https://coveralls.io/r/vbauer/avconv4java) 6 | [![License](http://img.shields.io/badge/License-Apache%2C%20Version%202.0-blue.svg?style=flat)](http://opensource.org/licenses/Apache-2.0) 7 | [![Maven](https://img.shields.io/github/tag/vbauer/avconv4java.svg?label=maven)](https://jitpack.io/#vbauer/avconv4java) 8 | [![Codacy Badge](https://api.codacy.com/project/badge/grade/a57d77abf87a4f77a27ca0bef1038b91)](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 flags) { 34 | return AVUtils.isEmpty(flags) ? this : flags(flags.toArray(new Object[0])); 35 | } 36 | 37 | public AVOptions flags(final Object... flags) { 38 | if (!AVUtils.isEmpty(flags)) { 39 | final List newFlags = new LinkedList<>(); 40 | for (final Object flag : flags) { 41 | if (flag == null) { 42 | return this; 43 | } 44 | newFlags.add(String.valueOf(flag)); 45 | } 46 | arguments.addAll(newFlags); 47 | } 48 | return this; 49 | } 50 | 51 | public AVOptions builders(final Collection builders) { 52 | return AVUtils.isEmpty(builders) ? this : builders(builders.toArray(new AVOptions[builders.size()])); 53 | } 54 | 55 | public AVOptions builders(final AVOptions... builders) { 56 | if (!AVUtils.isEmpty((Object[]) builders)) { 57 | for (final AVOptions builder : builders) { 58 | if (builder instanceof AVRootOptions) { 59 | throw new IllegalArgumentException("It's impossible to add root options as child node"); 60 | } 61 | this.options.add(builder); 62 | } 63 | } 64 | return this; 65 | } 66 | 67 | public List build() { 68 | final List result = new LinkedList<>(); 69 | result.addAll(arguments); 70 | for (final AVOptions builder : options) { 71 | result.addAll(builder.build()); 72 | } 73 | return result; 74 | } 75 | 76 | 77 | protected final String kb(final Number value) { 78 | return value == null ? null : value + "k"; 79 | } 80 | 81 | protected final String sec(final Double position) { 82 | return format("%.2f", position); 83 | } 84 | 85 | protected final Integer even(final Integer value) { 86 | return value == null ? null : value - value % 2; 87 | } 88 | 89 | protected final String format(final String filter, final Object... params) { 90 | return filter == null || AVUtils.hasNull(params) ? null : String.format(filter, params); 91 | } 92 | 93 | protected final String specifyStream(final String flag, final AVStreamType streamType) { 94 | return flag != null ? streamType != null ? flag + ":" + streamType.getName() : flag : null; 95 | } 96 | 97 | } 98 | -------------------------------------------------------------------------------- /src/main/java/com/github/vbauer/avconv4java/core/AVRootOptions.java: -------------------------------------------------------------------------------- 1 | package com.github.vbauer.avconv4java.core; 2 | 3 | import java.util.Collection; 4 | import java.util.List; 5 | 6 | /** 7 | * Root options. All other options should be use as part of it. 8 | * 9 | * @author Vladislav Bauer 10 | */ 11 | 12 | public class AVRootOptions extends AVOptions { 13 | 14 | public static final String FLAG_INPUT_FILE = "-i"; 15 | 16 | 17 | private final String outputFile; 18 | 19 | 20 | public AVRootOptions(final String inputFile, final String outputFile) { 21 | this.outputFile = outputFile; 22 | inputFile(inputFile); 23 | } 24 | 25 | 26 | public static AVRootOptions create(final String inputFile, final String outputFile) { 27 | return new AVRootOptions(inputFile, outputFile); 28 | } 29 | 30 | 31 | @Override 32 | public AVRootOptions flags(final Collection flags) { 33 | return (AVRootOptions) super.flags(flags); 34 | } 35 | 36 | @Override 37 | public AVRootOptions flags(final Object... flags) { 38 | return (AVRootOptions) super.flags(flags); 39 | } 40 | 41 | @Override 42 | public AVRootOptions builders(final Collection builders) { 43 | return (AVRootOptions) super.builders(builders); 44 | } 45 | 46 | @Override 47 | public AVRootOptions builders(final AVOptions... builders) { 48 | return (AVRootOptions) super.builders(builders); 49 | } 50 | 51 | @Override 52 | public List build() { 53 | final List result = super.build(); 54 | result.add(outputFile); 55 | return result; 56 | } 57 | 58 | 59 | public String getOutputFile() { 60 | return outputFile; 61 | } 62 | 63 | 64 | /** 65 | * An input file name. 66 | * CMD: ‘-i filename (input)’ 67 | */ 68 | private void inputFile(final String filename) { 69 | flags(FLAG_INPUT_FILE, filename); 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /src/main/java/com/github/vbauer/avconv4java/option/AVAudioOptions.java: -------------------------------------------------------------------------------- 1 | package com.github.vbauer.avconv4java.option; 2 | 3 | import com.github.vbauer.avconv4java.core.AVOptions; 4 | import com.github.vbauer.avconv4java.type.AVAudioCodecType; 5 | import com.github.vbauer.avconv4java.type.AVStreamType; 6 | 7 | import java.util.Collection; 8 | 9 | /** 10 | * Audio Options. 11 | * @see Official doc: "5.9 Audio Options" 12 | * 13 | * @author Vladislav Bauer 14 | */ 15 | 16 | public class AVAudioOptions extends AVOptions { 17 | 18 | public static final String FLAG_AUDIO_FRAMES_COUNT = "-aframes"; 19 | public static final String FLAG_SAMPLE_RATE = "-ar"; 20 | public static final String FLAG_AUDIO_QUALITY = "-aq"; 21 | public static final String FLAG_AUDIO_CHANNELS_COUNT = "-ac"; 22 | public static final String FLAG_DISABLE_AUDIO_RECORDING = "-an"; 23 | public static final String FLAG_AUDIO_CODEC = "-acodec"; 24 | public static final String FLAG_AUDIO_BIT_RATE = "-ab"; 25 | public static final String FLAG_SAMPLE_FORMAT = "-sample_fmt"; 26 | public static final String FLAG_FILTER_GRAPH = "-af"; 27 | 28 | 29 | public static AVAudioOptions create() { 30 | return new AVAudioOptions(); 31 | } 32 | 33 | 34 | @Override 35 | public AVAudioOptions flags(final Collection flags) { 36 | return (AVAudioOptions) super.flags(flags); 37 | } 38 | 39 | @Override 40 | public AVAudioOptions flags(final Object... flags) { 41 | return (AVAudioOptions) super.flags(flags); 42 | } 43 | 44 | @Override 45 | public AVAudioOptions builders(final Collection builders) { 46 | return (AVAudioOptions) super.builders(builders); 47 | } 48 | 49 | @Override 50 | public AVAudioOptions builders(final AVOptions... builders) { 51 | return (AVAudioOptions) super.builders(builders); 52 | } 53 | 54 | 55 | /** 56 | * ‘-aq q (output)’ 57 | * Set the audio quality (codec-specific, VBR). This is an alias for -q:a. 58 | */ 59 | public AVAudioOptions audioQuality(final Double quality) { 60 | return flags(FLAG_AUDIO_QUALITY, format("%.4f", quality)); 61 | } 62 | 63 | /** 64 | * ‘-acodec codec (input/output)’ 65 | * Set the audio codec. This is an alias for -codec:a. 66 | */ 67 | public AVAudioOptions audioCodec(final AVAudioCodecType codecType) { 68 | return audioCodec(codecType == null ? null : codecType.getName()); 69 | } 70 | 71 | public AVAudioOptions audioCodec(final String codecTypeName) { 72 | return flags(FLAG_AUDIO_CODEC, codecTypeName); 73 | } 74 | 75 | public AVAudioOptions audioBitRate(final Integer bitRate) { 76 | return flags(FLAG_AUDIO_BIT_RATE, kb(bitRate)); 77 | } 78 | 79 | /** 80 | * ‘-an (output)’ 81 | * Disable audio recording. 82 | */ 83 | public AVAudioOptions disableRecording() { 84 | return flags(FLAG_DISABLE_AUDIO_RECORDING); 85 | } 86 | 87 | /** 88 | * ‘-aframes number (output)’ 89 | * Set the number of audio frames to record. This is an alias for -frames:a. 90 | */ 91 | public AVAudioOptions framesCount(final Long count) { 92 | return flags(FLAG_AUDIO_FRAMES_COUNT, count); 93 | } 94 | 95 | /** 96 | * ‘-ac[:stream_specifier] channels (input/output,per-stream)’ 97 | * Set the number of audio channels. For output streams it is set by default to the number of input audio channels. 98 | * For input streams this option only makes sense for audio grabbing devices and raw demuxers and is mapped to the 99 | * corresponding demuxer options. 100 | */ 101 | public AVAudioOptions audioChannelsCount(final AVStreamType streamType, final Integer count) { 102 | return flags(specifyStream(FLAG_AUDIO_CHANNELS_COUNT, streamType), count); 103 | } 104 | 105 | public AVAudioOptions audioChannelsCount(final Integer count) { 106 | return audioChannelsCount(null, count); 107 | } 108 | 109 | /** 110 | ‘-ar[:stream_specifier] freq (input/output,per-stream)’ 111 | * Set the audio sampling frequency. For output streams it is set by default to the frequency of the corresponding 112 | * input stream. For input streams this option only makes sense for audio grabbing devices and raw demuxers and is 113 | * mapped to the corresponding demuxer options. 114 | */ 115 | public AVAudioOptions sampleRate(final AVStreamType streamType, final Integer sampleRate) { 116 | return flags(specifyStream(FLAG_SAMPLE_RATE, streamType), sampleRate); 117 | } 118 | 119 | public AVAudioOptions sampleRate(final Integer sampleRate) { 120 | return sampleRate(null, sampleRate); 121 | } 122 | 123 | /** 124 | * ‘-sample_fmt[:stream_specifier] sample_fmt (output,per-stream)’ 125 | * Set the audio sample format. Use -sample_fmts to get a list of supported sample formats. 126 | */ 127 | public AVAudioOptions sampleFormat(final AVStreamType streamType, final String format) { 128 | return flags(specifyStream(FLAG_SAMPLE_FORMAT, streamType), format); 129 | } 130 | 131 | public AVAudioOptions sampleFormat(final String format) { 132 | return sampleFormat(null, format); 133 | } 134 | 135 | /** 136 | * ‘-af filter_graph (output)’ 137 | * filter_graph is a description of the filter graph to apply to the input audio. Use the option "-filters" to 138 | * show all the available filters (including also sources and sinks). This is an alias for -filter:a. 139 | */ 140 | public AVAudioOptions filter(final String filter) { 141 | return flags(FLAG_FILTER_GRAPH, filter); 142 | } 143 | 144 | } 145 | -------------------------------------------------------------------------------- /src/main/java/com/github/vbauer/avconv4java/option/AVCodecOptions.java: -------------------------------------------------------------------------------- 1 | package com.github.vbauer.avconv4java.option; 2 | 3 | import com.github.vbauer.avconv4java.core.AVOptions; 4 | import com.github.vbauer.avconv4java.type.AVCodecFlagType; 5 | import com.github.vbauer.avconv4java.type.AVDebugInfoType; 6 | import com.github.vbauer.avconv4java.type.AVMotionEstimationType; 7 | import com.github.vbauer.avconv4java.type.AVStreamType; 8 | import com.github.vbauer.avconv4java.type.AVStrictType; 9 | 10 | import java.util.Collection; 11 | 12 | /** 13 | * Codec Audio/Video Options. 14 | * @see Official doc: "5.4 Codec AVOptions" 15 | * 16 | * @author Vladislav Bauer 17 | */ 18 | 19 | public class AVCodecOptions extends AVOptions { 20 | 21 | public static final String FLAG_BIT_RATE = "-b"; 22 | public static final String FLAG_VIDEO_BIT_RATE_TOLERANCE = "-bt"; 23 | public static final String FLAG_CODEC_FLAGS = "-flags"; 24 | public static final String FLAG_MOTION_ESTIMATION_METHOD = "-me_method"; 25 | public static final String FLAG_GROUP_OF_PICTURES = "-g"; 26 | public static final String FLAG_CUT_OFF_BANDWIDTH = "-cutoff"; 27 | public static final String FLAG_FRAME_SIZE = "-frame_size"; 28 | public static final String FLAG_STRICT = "-strict"; 29 | public static final String FLAG_DEBUG = "-debug"; 30 | public static final String FLAG_PRESET = "-pre"; 31 | 32 | 33 | public static AVCodecOptions create() { 34 | return new AVCodecOptions(); 35 | } 36 | 37 | 38 | @Override 39 | public AVCodecOptions flags(final Collection flags) { 40 | return (AVCodecOptions) super.flags(flags); 41 | } 42 | 43 | @Override 44 | public AVCodecOptions flags(final Object... flags) { 45 | return (AVCodecOptions) super.flags(flags); 46 | } 47 | 48 | @Override 49 | public AVCodecOptions builders(final Collection builders) { 50 | return (AVCodecOptions) super.builders(builders); 51 | } 52 | 53 | @Override 54 | public AVCodecOptions builders(final AVOptions... builders) { 55 | return (AVCodecOptions) super.builders(builders); 56 | } 57 | 58 | 59 | public AVCodecOptions strict(final AVStrictType strictType) { 60 | return strict(strictType == null ? null : strictType.getName()); 61 | } 62 | 63 | public AVCodecOptions strict(final String strictTypeName) { 64 | return flags(FLAG_STRICT, strictTypeName); 65 | } 66 | 67 | /** 68 | * Set bitrate (in kbits/s). 69 | * CMD: ‘-b[:stream_specifier] integer (output,audio,video)’ 70 | */ 71 | public AVCodecOptions bitRate(final AVStreamType streamType, final Integer bitRate) { 72 | return flags(specifyStream(FLAG_BIT_RATE, streamType), kb(bitRate)); 73 | } 74 | 75 | public AVCodecOptions bitRate(final Integer bitRate) { 76 | return bitRate(null, bitRate); 77 | } 78 | 79 | /** 80 | * Set video bitrate tolerance (in kbits/s). In 1-pass mode, bitrate tolerance specifies how far ratecontrol is 81 | * willing to deviate from the target average bitrate value. This is not related to minimum/maximum bitrate. 82 | * Lowering tolerance too much has an adverse effect on quality. 83 | * CMD: ‘-bt[:stream_specifier] integer (output,video)’ 84 | */ 85 | public AVCodecOptions videoBitRateTolerance(final AVStreamType streamType, final Integer bitRate) { 86 | return flags(specifyStream(FLAG_VIDEO_BIT_RATE_TOLERANCE, streamType), kb(bitRate)); 87 | } 88 | 89 | public AVCodecOptions videoBitRateTolerance(final Integer bitRate) { 90 | return videoBitRateTolerance(null, bitRate); 91 | } 92 | 93 | /** 94 | * Set motion estimation method. 95 | * CMD: ‘-me_method[:stream_specifier] integer (output,video)’ 96 | */ 97 | public AVCodecOptions motionEstimationMethod( 98 | final AVStreamType streamType, final AVMotionEstimationType motionEstimationType 99 | ) { 100 | final String motionEstimationTypeName = motionEstimationType == null ? null : motionEstimationType.getName(); 101 | return motionEstimationMethod(streamType, motionEstimationTypeName); 102 | } 103 | 104 | public AVCodecOptions motionEstimationMethod(final AVMotionEstimationType motionEstimationType) { 105 | return motionEstimationMethod(null, motionEstimationType); 106 | } 107 | 108 | public AVCodecOptions motionEstimationMethod(final AVStreamType streamType, final String motionEstimationType) { 109 | return flags(specifyStream(FLAG_MOTION_ESTIMATION_METHOD, streamType), motionEstimationType); 110 | } 111 | 112 | public AVCodecOptions motionEstimationMethod(final String motionEstimationType) { 113 | return motionEstimationMethod(null, motionEstimationType); 114 | } 115 | 116 | /** 117 | * Print specific debug info. 118 | * CMD: ‘-debug[:stream_specifier] flags (input/output,audio,video,subtitles)’ 119 | */ 120 | public AVCodecOptions debug(final AVDebugInfoType debugInfoType) { 121 | return debug(debugInfoType == null ? null : debugInfoType.getName()); 122 | } 123 | 124 | public AVCodecOptions debug(final String debugInfoTypeName) { 125 | return flags(FLAG_DEBUG, debugInfoTypeName); 126 | } 127 | 128 | /** 129 | * Codec flags. 130 | * CMD: ‘-flags[:stream_specifier] flags (input/output,audio,video)’ 131 | */ 132 | public AVCodecOptions codecFlags(final AVStreamType streamType, final AVCodecFlagType flagType) { 133 | return codecFlags(streamType, flagType == null ? null : flagType.getName()); 134 | } 135 | 136 | public AVCodecOptions codecFlags(final AVCodecFlagType flagType) { 137 | return codecFlags(null, flagType); 138 | } 139 | 140 | public AVCodecOptions codecFlags(final AVStreamType streamType, final String flagTypeName) { 141 | return flags(specifyStream(FLAG_CODEC_FLAGS, streamType), flagTypeName); 142 | } 143 | 144 | public AVCodecOptions codecFlags(final String flagTypeName) { 145 | return codecFlags(null, flagTypeName); 146 | } 147 | 148 | /** 149 | * Set the group of picture (GOP) size. 150 | * CMD: ‘-g[:stream_specifier] integer (output,video)’ 151 | */ 152 | public AVCodecOptions groupOfPictures(final AVStreamType streamType, final Integer gopSize) { 153 | return flags(specifyStream(FLAG_GROUP_OF_PICTURES, streamType), gopSize); 154 | } 155 | 156 | public AVCodecOptions groupOfPictures(final Integer gopSize) { 157 | return groupOfPictures(null, gopSize); 158 | } 159 | 160 | /** 161 | * Set cutoff bandwidth. 162 | * CMD: ‘-cutoff[:stream_specifier] integer (output,audio)’ 163 | */ 164 | public AVCodecOptions cutOffBandwidth(final AVStreamType streamType, final Integer bandwidth) { 165 | return flags(specifyStream(FLAG_CUT_OFF_BANDWIDTH, streamType), bandwidth); 166 | } 167 | 168 | public AVCodecOptions cutOffBandwidth(final Integer bandwidth) { 169 | return cutOffBandwidth(null, bandwidth); 170 | } 171 | 172 | public AVCodecOptions frameSize(final AVStreamType streamType, final Integer size) { 173 | return flags(specifyStream(FLAG_FRAME_SIZE, streamType), size); 174 | } 175 | 176 | public AVCodecOptions frameSize(final Integer size) { 177 | return frameSize(null, size); 178 | } 179 | 180 | public AVCodecOptions preset(final AVStreamType streamType, final String fileName) { 181 | return flags(specifyStream(FLAG_PRESET, streamType), fileName); 182 | } 183 | 184 | } 185 | -------------------------------------------------------------------------------- /src/main/java/com/github/vbauer/avconv4java/option/AVFormatOptions.java: -------------------------------------------------------------------------------- 1 | package com.github.vbauer.avconv4java.option; 2 | 3 | import com.github.vbauer.avconv4java.core.AVOptions; 4 | import com.github.vbauer.avconv4java.type.AVErrorDetectionType; 5 | import com.github.vbauer.avconv4java.type.AVFormatDebugInfoType; 6 | import com.github.vbauer.avconv4java.type.AVFormatFlagType; 7 | 8 | import java.util.Collection; 9 | 10 | /** 11 | * Format Audio/Video Options. 12 | * @see Official doc: "5.5 Format AVOptions" 13 | * 14 | * @author Vladislav Bauer 15 | */ 16 | 17 | public class AVFormatOptions extends AVOptions { 18 | 19 | public static final String FLAG_PROBE_SIZE = "-probesize"; 20 | public static final String FLAG_PACKET_SIZE = "-packetsize"; 21 | public static final String FLAG_FORMAT_FLAGS = "-fflags"; 22 | public static final String FLAG_ANALYZE_DURATION = "-analyzeduration"; 23 | public static final String FLAG_DECRYPTION_KEY = "-cryptokey"; 24 | public static final String FLAG_TIMESTAMP_INDEX_SIZE = "-indexmem"; 25 | public static final String FLAG_REAL_TIME_BUFFER_SIZE = "-rtbufsize"; 26 | public static final String FLAG_DEBUG_INFO = "-fdebug"; 27 | public static final String FLAG_MAX_DELAY = "-max_delay"; 28 | public static final String FLAG_FPS_PROBE_SIZE = "-fpsprobesize"; 29 | public static final String FLAG_ERROR_DETECTION = "-err_detect"; 30 | public static final String FLAG_INTERLEAVING_BUFFER_SIZE = "-max_interleave_delta"; 31 | 32 | 33 | public static AVFormatOptions create() { 34 | return new AVFormatOptions(); 35 | } 36 | 37 | 38 | @Override 39 | public AVFormatOptions flags(final Collection flags) { 40 | return (AVFormatOptions) super.flags(flags); 41 | } 42 | 43 | @Override 44 | public AVFormatOptions flags(final Object... flags) { 45 | return (AVFormatOptions) super.flags(flags); 46 | } 47 | 48 | @Override 49 | public AVFormatOptions builders(final Collection builders) { 50 | return (AVFormatOptions) super.builders(builders); 51 | } 52 | 53 | @Override 54 | public AVFormatOptions builders(final AVOptions... builders) { 55 | return (AVFormatOptions) super.builders(builders); 56 | } 57 | 58 | 59 | /** 60 | * Set probing size. 61 | * CMD: ‘-probesize integer (input)’ 62 | */ 63 | public AVFormatOptions probeSize(final Long size) { 64 | return flags(FLAG_PROBE_SIZE, size); 65 | } 66 | 67 | /** 68 | * Set packet size. 69 | * CMD: ‘-packetsize integer (output)’ 70 | */ 71 | public AVFormatOptions packetSize(final Long size) { 72 | return flags(FLAG_PACKET_SIZE, size); 73 | } 74 | 75 | /** 76 | * Set format flags. 77 | * CMD: ‘-fflags flags (input/output)’ 78 | */ 79 | public AVFormatOptions formatFlags(final AVFormatFlagType formatFlagType) { 80 | return formatFlags(formatFlagType == null ? null : formatFlagType.getName()); 81 | } 82 | 83 | public AVFormatOptions formatFlags(final String formatFlagTypeName) { 84 | return flags(FLAG_FORMAT_FLAGS, formatFlagTypeName); 85 | } 86 | 87 | /** 88 | * How many microseconds are analyzed to estimate duration. 89 | * CMD: ‘-analyzeduration integer (input)’ 90 | */ 91 | public AVFormatOptions analyzeDuration(final Long duration) { 92 | return flags(FLAG_ANALYZE_DURATION, duration); 93 | } 94 | 95 | /** 96 | * Set decryption key. 97 | * CMD: ‘-cryptokey hexadecimal string (input)’ 98 | */ 99 | public AVFormatOptions decryptionKey(final String key) { 100 | return flags(FLAG_DECRYPTION_KEY, key); 101 | } 102 | 103 | /** 104 | * Max memory used for timestamp index (per stream). 105 | * CMD: ‘-indexmem integer (input)’ 106 | */ 107 | public AVFormatOptions timestampIndexSize(final Long maxMemory) { 108 | return flags(FLAG_TIMESTAMP_INDEX_SIZE, maxMemory); 109 | } 110 | 111 | /** 112 | * Max memory used for buffering real-time frames. 113 | * CMD: ‘-rtbufsize integer (input)’ 114 | */ 115 | public AVFormatOptions realTimeBufferSize(final Long maxMemory) { 116 | return flags(FLAG_REAL_TIME_BUFFER_SIZE, maxMemory); 117 | } 118 | 119 | /** 120 | * Print specific debug info. 121 | * CMD: ‘-fdebug flags (input/output)’ 122 | */ 123 | public AVFormatOptions debugInfo(final AVFormatDebugInfoType debugInfoType) { 124 | return debugInfo(debugInfoType == null ? null : debugInfoType.getName()); 125 | } 126 | 127 | public AVFormatOptions debugInfo(final String debugInfoTypeName) { 128 | return flags(FLAG_DEBUG_INFO, debugInfoTypeName); 129 | } 130 | 131 | /** 132 | * Maximum muxing or demuxing delay in microseconds. 133 | * CMD: ‘-max_delay integer (input/output)’ 134 | */ 135 | public AVFormatOptions maxDelay(final Long delay) { 136 | return flags(FLAG_MAX_DELAY, delay); 137 | } 138 | 139 | /** 140 | * Number of frames used to probe fps. 141 | * CMD: ‘-fpsprobesize integer (input)’ 142 | */ 143 | public AVFormatOptions fpsProbeSize(final Long size) { 144 | return flags(FLAG_FPS_PROBE_SIZE, size); 145 | } 146 | 147 | /** 148 | * Set error detection flags (deprecated; use err_detect, save via avconv). 149 | * CMD: ‘-f_err_detect flags (input)’ 150 | */ 151 | public AVFormatOptions errorDetection(final AVErrorDetectionType errorDetectionType) { 152 | return errorDetection(errorDetectionType == null ? null : errorDetectionType.getName()); 153 | } 154 | 155 | public AVFormatOptions errorDetection(final String errorDetectionTypeName) { 156 | return flags(FLAG_ERROR_DETECTION, errorDetectionTypeName); 157 | } 158 | 159 | public AVFormatOptions interleavingBufferSize(final Long size) { 160 | return flags(FLAG_INTERLEAVING_BUFFER_SIZE, size); 161 | } 162 | 163 | } 164 | -------------------------------------------------------------------------------- /src/main/java/com/github/vbauer/avconv4java/option/AVGenericOptions.java: -------------------------------------------------------------------------------- 1 | package com.github.vbauer.avconv4java.option; 2 | 3 | import com.github.vbauer.avconv4java.core.AVOptions; 4 | import com.github.vbauer.avconv4java.type.AVLogLevelType; 5 | 6 | import java.util.Collection; 7 | 8 | /** 9 | * Generic options. 10 | * @see Official doc: "5.2 Generic options" 11 | * 12 | * @author Vladislav Bauer 13 | */ 14 | 15 | public class AVGenericOptions extends AVOptions { 16 | 17 | public static final String FLAG_LOG_LEVEL = "-loglevel"; 18 | public static final String FLAG_CPU_FLAGS = "-cpuflags"; 19 | public static final String FLAG_SHOW_LICENSE = "-L"; 20 | 21 | 22 | public static AVGenericOptions create() { 23 | return new AVGenericOptions(); 24 | } 25 | 26 | 27 | @Override 28 | public AVGenericOptions flags(final Collection flags) { 29 | return (AVGenericOptions) super.flags(flags); 30 | } 31 | 32 | @Override 33 | public AVGenericOptions flags(final Object... flags) { 34 | return (AVGenericOptions) super.flags(flags); 35 | } 36 | 37 | @Override 38 | public AVGenericOptions builders(final Collection builders) { 39 | return (AVGenericOptions) super.builders(builders); 40 | } 41 | 42 | @Override 43 | public AVGenericOptions builders(final AVOptions... builders) { 44 | return (AVGenericOptions) super.builders(builders); 45 | } 46 | 47 | 48 | public AVGenericOptions logLevel(final Integer level) { 49 | return logLevel(level == null ? null : String.valueOf(level)); 50 | } 51 | 52 | public AVGenericOptions logLevel(final AVLogLevelType logLevelType) { 53 | return logLevel(logLevelType == null ? null : logLevelType.getName()); 54 | } 55 | 56 | public AVGenericOptions logLevel(final String logLevelName) { 57 | return flags(FLAG_LOG_LEVEL, logLevelName); 58 | } 59 | 60 | public AVGenericOptions cpuFlags(final String mask) { 61 | return flags(FLAG_CPU_FLAGS, mask); 62 | } 63 | 64 | public AVGenericOptions showLicense() { 65 | return flags(FLAG_SHOW_LICENSE); 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/com/github/vbauer/avconv4java/option/AVMainOptions.java: -------------------------------------------------------------------------------- 1 | package com.github.vbauer.avconv4java.option; 2 | 3 | import com.github.vbauer.avconv4java.core.AVOptions; 4 | import com.github.vbauer.avconv4java.type.AVFileFormatType; 5 | import com.github.vbauer.avconv4java.type.AVStreamType; 6 | import com.github.vbauer.avconv4java.type.AVTargetFileType; 7 | 8 | import java.util.Collection; 9 | 10 | /** 11 | * Main options. 12 | * @see Official doc: "5.6 Main options" 13 | * 14 | * @author Vladislav Bauer 15 | */ 16 | 17 | public class AVMainOptions extends AVOptions { 18 | 19 | public static final String FLAG_FILE_FORMAT = "-f"; 20 | public static final String FLAG_OVERWRITE_OUTPUT = "-y"; 21 | public static final String FLAG_IMMEDIATELY_EXIT = "-n"; 22 | public static final String FLAG_DURATION = "-t"; 23 | public static final String FLAG_FILE_SIZE_LIMIT = "-fs"; 24 | public static final String FLAG_SEEK = "-ss"; 25 | public static final String FLAG_INPUT_TIME_OFFSET = "-itsoffset"; 26 | public static final String FLAG_METADATA = "-metadata"; 27 | public static final String FLAG_TARGET = "-target"; 28 | public static final String FLAG_DATA_FRAMES = "-dframes"; 29 | public static final String FLAG_FRAMES_COUNT = "-frames"; 30 | public static final String FLAG_QUALITY_SCALE = "-q"; 31 | public static final String FLAG_FILTER = "-filter"; 32 | public static final String FLAG_FILTER_SCRIPT = "-filter_script"; 33 | public static final String FLAG_PRESET = "-pre"; 34 | public static final String FLAG_ATTACHMENT = "-attach"; 35 | public static final String FLAG_DUMP_ATTACHMENT = "-dump_attachment"; 36 | 37 | public static final String FORMAT_METADATA = "%s=\"%s\""; 38 | 39 | 40 | public static AVMainOptions create() { 41 | return new AVMainOptions(); 42 | } 43 | 44 | 45 | @Override 46 | public AVMainOptions flags(final Collection flags) { 47 | return (AVMainOptions) super.flags(flags); 48 | } 49 | 50 | @Override 51 | public AVMainOptions flags(final Object... flags) { 52 | return (AVMainOptions) super.flags(flags); 53 | } 54 | 55 | @Override 56 | public AVMainOptions builders(final Collection builders) { 57 | return (AVMainOptions) super.builders(builders); 58 | } 59 | 60 | @Override 61 | public AVMainOptions builders(final AVOptions... builders) { 62 | return (AVMainOptions) super.builders(builders); 63 | } 64 | 65 | 66 | /** 67 | * ‘-f fmt (input/output)’ 68 | * Force input or output file format. The format is normally autodetected for input files and guessed from file 69 | * extension for output files, so this option is not needed in most cases. 70 | */ 71 | public AVMainOptions fileFormat(final AVFileFormatType formatType) { 72 | return fileFormat(formatType == null ? null : formatType.getName()); 73 | } 74 | 75 | public AVMainOptions fileFormat(final String formatTypeName) { 76 | return flags(FLAG_FILE_FORMAT, formatTypeName); 77 | } 78 | 79 | /** 80 | * ‘-y (global)’ 81 | * Overwrite output files without asking. 82 | */ 83 | public AVMainOptions overwriteOutput() { 84 | return flags(FLAG_OVERWRITE_OUTPUT); 85 | } 86 | 87 | /** 88 | * ‘-n (global)’ 89 | * Immediately exit when output files already exist. 90 | */ 91 | public AVMainOptions immediatelyExit() { 92 | return flags(FLAG_IMMEDIATELY_EXIT); 93 | } 94 | 95 | /** 96 | * ‘-t duration (output)’ 97 | * Stop writing the output after its duration reaches duration. duration may be a number in seconds, 98 | * or in hh:mm:ss[.xxx] form. 99 | */ 100 | public AVMainOptions duration(final String duration) { 101 | return flags(FLAG_DURATION, duration); 102 | } 103 | 104 | public AVMainOptions duration(final Long duration) { 105 | return flags(FLAG_DURATION, duration); 106 | } 107 | 108 | /** 109 | * ‘-fs limit_size (output)’ 110 | * Set the file size limit. 111 | */ 112 | public AVMainOptions fileSizeLimit(final Long fileSize) { 113 | return flags(FLAG_FILE_SIZE_LIMIT, fileSize); 114 | } 115 | 116 | /** 117 | * ‘-ss position (input/output)’ 118 | * When used as an input option (before -i), seeks in this input file to position. 119 | * Note the in most formats it is not possible to position exactly, so avconv will position to the closest position 120 | * point before position. When transcoding and ‘-accurate_seek’ is enabled (the default), this extra segment 121 | * between the position point and position will be decoded and discarded. When doing stream copy or when 122 | * ‘-noaccurate_seek’ is used, it will be preserved. 123 | * 124 | * When used as an output option (before an output filename), decodes but discards input until the timestamps 125 | * reach position. 126 | * 127 | * position may be either in seconds or in hh:mm:ss[.xxx] form. 128 | */ 129 | public AVMainOptions seek(final String position) { 130 | return flags(FLAG_SEEK, position); 131 | } 132 | 133 | public AVMainOptions seek(final Double position) { 134 | return seek(sec(position)); 135 | } 136 | 137 | /** 138 | * ‘-itsoffset offset (input)’ 139 | * Set the input time offset in seconds. [-]hh:mm:ss[.xxx] syntax is also supported. The offset is added to the 140 | * timestamps of the input files. Specifying a positive offset means that the corresponding streams are delayed by 141 | * offset seconds. 142 | */ 143 | public AVMainOptions inputTimeOffset(final String position) { 144 | return flags(FLAG_INPUT_TIME_OFFSET, position); 145 | } 146 | 147 | public AVMainOptions inputTimeOffset(final Double position) { 148 | return inputTimeOffset(sec(position)); 149 | } 150 | 151 | /** 152 | * ‘-metadata[:metadata_specifier] key=value (output,per-metadata)’ 153 | * Set a metadata key/value pair. 154 | * 155 | * An optional metadata_specifier may be given to set metadata on streams or chapters. See -map_metadata 156 | * documentation for details. This option overrides metadata set with -map_metadata. It is also possible to delete 157 | * metadata by using an empty value. 158 | * 159 | * For example, for setting the title in the output file: 160 | * avconv -i in.avi -metadata title="my title" out.flv 161 | * 162 | * To set the language of the first audio stream: 163 | * avconv -i INPUT -metadata:s:a:0 language=eng OUTPUT 164 | */ 165 | public AVMainOptions metadata(final String key, final Object value) { 166 | return flags(FLAG_METADATA, format(FORMAT_METADATA, key, value)); 167 | } 168 | 169 | /** 170 | * ‘-dframes number (output)’ 171 | * Set the number of data frames to record. This is an alias for -frames:d. 172 | */ 173 | public AVMainOptions dataFrames(final Long dataFrames) { 174 | return flags(FLAG_DATA_FRAMES, dataFrames); 175 | } 176 | 177 | /** 178 | * ‘-target type (output)’ 179 | * Specify target file type (vcd, svcd, dvd, dv, dv50). type may be prefixed with pal-, ntsc- or film- to use the 180 | * corresponding standard. All the format options (bitrate, codecs, buffer sizes) are then set automatically. 181 | * 182 | * You can just type: 183 | * avconv -i myfile.avi -target vcd /tmp/vcd.mpg 184 | * 185 | * Nevertheless you can specify additional options as long as you know they do not conflict with the standard, 186 | * as in: 187 | * avconv -i myfile.avi -target vcd -bf 2 /tmp/vcd.mpg 188 | */ 189 | public AVMainOptions target(final AVTargetFileType targetFileType) { 190 | final String targetFileTypeName = targetFileType == null ? null : targetFileType.getName(); 191 | return target(targetFileTypeName); 192 | } 193 | 194 | public AVMainOptions target(final String targetFileTypeName) { 195 | return flags(FLAG_TARGET, targetFileTypeName); 196 | } 197 | 198 | /** 199 | * ‘-frames[:stream_specifier] framecount (output,per-stream)’ 200 | * Stop writing to the stream after framecount frames. 201 | */ 202 | public AVMainOptions framesCount(final AVStreamType streamType, final Long count) { 203 | return flags(specifyStream(FLAG_FRAMES_COUNT, streamType), count); 204 | } 205 | 206 | public AVMainOptions framesCount(final Long count) { 207 | return flags(null, count); 208 | } 209 | 210 | /** 211 | * ‘-q[:stream_specifier] q (output,per-stream)’ 212 | * ‘-qscale[:stream_specifier] q (output,per-stream)’ 213 | * Use fixed quality scale (VBR). The meaning of q is codec-dependent. 214 | */ 215 | public AVMainOptions qualityScale(final AVStreamType streamType, final Double quality) { 216 | return flags(specifyStream(FLAG_QUALITY_SCALE, streamType), format("%.4f", quality)); 217 | } 218 | 219 | public AVMainOptions qualityScale(final Double quality) { 220 | return qualityScale(null, quality); 221 | } 222 | 223 | /** 224 | * ‘-filter[:stream_specifier] filter_graph (output,per-stream)’ 225 | * filter_graph is a description of the filter graph to apply to the stream. Use -filters to show all the 226 | * available filters (including also sources and sinks). 227 | * 228 | * See also the ‘-filter_complex’ option if you want to create filter graphs with multiple inputs and/or outputs. 229 | */ 230 | public AVMainOptions filter(final AVStreamType streamType, final String filter, final Object... params) { 231 | return flags(specifyStream(FLAG_FILTER, streamType), format(filter, params)); 232 | } 233 | 234 | public AVMainOptions filter(final String filter, final Object... params) { 235 | return filter(null, filter, params); 236 | } 237 | 238 | /** 239 | * ‘-filter_script[:stream_specifier] filename (output,per-stream)’ 240 | * This option is similar to ‘-filter’, the only difference is that its argument is the name of the file from 241 | * which a filtergraph description is to be read. 242 | */ 243 | public AVMainOptions filterScript(final AVStreamType streamType, final String fileName) { 244 | return flags(specifyStream(FLAG_FILTER_SCRIPT, streamType), fileName); 245 | } 246 | 247 | public AVMainOptions filterScript(final String fileName) { 248 | return filterScript(null, fileName); 249 | } 250 | 251 | /** 252 | * ‘-pre[:stream_specifier] preset_name (output,per-stream)’ 253 | * Specify the preset for matching stream(s). 254 | */ 255 | public AVMainOptions preset(final AVStreamType streamType, final String preset) { 256 | return flags(specifyStream(FLAG_PRESET, streamType), preset); 257 | } 258 | 259 | public AVMainOptions preset(final String preset) { 260 | return preset(null, preset); 261 | } 262 | 263 | /** 264 | * ‘-attach filename (output)’ 265 | * Add an attachment to the output file. This is supported by a few formats like Matroska for e.g. fonts used 266 | * in rendering subtitles. Attachments are implemented as a specific type of stream, so this option will add 267 | * a new stream to the file. It is then possible to use per-stream options on this stream in the usual way. 268 | * Attachment streams created with this option will be created after all the other streams 269 | * (i.e. those created with -map or automatic mappings). 270 | * 271 | * Note that for Matroska you also have to set the mimetype metadata tag: 272 | * avconv -i INPUT -attach DejaVuSans.ttf -metadata:s:2 mimetype=application/x-truetype-font out.mkv 273 | * (assuming that the attachment stream will be third in the output file). 274 | */ 275 | public AVMainOptions attachment(final String fileName) { 276 | return flags(FLAG_ATTACHMENT, fileName); 277 | } 278 | 279 | /** 280 | * ‘-dump_attachment[:stream_specifier] filename (input,per-stream)’ 281 | * Extract the matching attachment stream into a file named filename. If filename is empty, then the value of 282 | * the filename metadata tag will be used. 283 | * 284 | * E.g. to extract the first attachment to a file named ’out.ttf’: 285 | * avconv -dump_attachment:t:0 out.ttf INPUT 286 | * 287 | * To extract all attachments to files determined by the filename tag: 288 | * avconv -dump_attachment:t "" INPUT 289 | * 290 | * Technical note – attachments are implemented as codec extradata, so this option can actually be used to 291 | * extract extradata from any stream, not just attachments. 292 | */ 293 | public AVMainOptions dumpAttachment(final AVStreamType streamType, final String fileName) { 294 | return flags(specifyStream(FLAG_DUMP_ATTACHMENT, streamType), fileName); 295 | } 296 | 297 | public AVMainOptions dumpAttachment(final String fileName) { 298 | return dumpAttachment(null, fileName); 299 | } 300 | 301 | } 302 | -------------------------------------------------------------------------------- /src/main/java/com/github/vbauer/avconv4java/option/AVSubtitleOptions.java: -------------------------------------------------------------------------------- 1 | package com.github.vbauer.avconv4java.option; 2 | 3 | import com.github.vbauer.avconv4java.core.AVOptions; 4 | 5 | import java.util.Collection; 6 | 7 | /** 8 | * Subtitle options. 9 | * @see Official doc: "5.11 Subtitle options" 10 | * 11 | * @author Vladislav Bauer 12 | */ 13 | 14 | public class AVSubtitleOptions extends AVOptions { 15 | 16 | public static final String FLAG_SUBTITLE_CODEC = "-scodec"; 17 | public static final String FLAG_DISABLE_SUBTITLE_RECORDING = "-sn"; 18 | 19 | 20 | public static AVSubtitleOptions create() { 21 | return new AVSubtitleOptions(); 22 | } 23 | 24 | 25 | @Override 26 | public AVSubtitleOptions flags(final Collection flags) { 27 | return (AVSubtitleOptions) super.flags(flags); 28 | } 29 | 30 | @Override 31 | public AVSubtitleOptions flags(final Object... flags) { 32 | return (AVSubtitleOptions) super.flags(flags); 33 | } 34 | 35 | @Override 36 | public AVSubtitleOptions builders(final Collection builders) { 37 | return (AVSubtitleOptions) super.builders(builders); 38 | } 39 | 40 | @Override 41 | public AVSubtitleOptions builders(final AVOptions... builders) { 42 | return (AVSubtitleOptions) super.builders(builders); 43 | } 44 | 45 | 46 | /** 47 | * ‘-scodec codec (input/output)’ 48 | * Set the subtitle codec. This is an alias for -codec:s. 49 | */ 50 | public AVSubtitleOptions subtitleCodec(final String codecName) { 51 | return flags(FLAG_SUBTITLE_CODEC, codecName); 52 | } 53 | 54 | /** 55 | * ‘-sn (output)’ 56 | * Disable subtitle recording. 57 | */ 58 | public AVSubtitleOptions disableRecording() { 59 | return flags(FLAG_DISABLE_SUBTITLE_RECORDING); 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/com/github/vbauer/avconv4java/option/AVVideoOptions.java: -------------------------------------------------------------------------------- 1 | package com.github.vbauer.avconv4java.option; 2 | 3 | import com.github.vbauer.avconv4java.core.AVOptions; 4 | import com.github.vbauer.avconv4java.type.AVMovFlagsType; 5 | import com.github.vbauer.avconv4java.type.AVStreamType; 6 | import com.github.vbauer.avconv4java.type.AVVideoCodecType; 7 | import com.github.vbauer.avconv4java.type.AVVideoSizeType; 8 | import com.github.vbauer.avconv4java.util.AVUtils; 9 | 10 | import java.util.Collection; 11 | 12 | /** 13 | * Video Options. 14 | * @see Official doc: "5.7 Video Options" 15 | * 16 | * @author Vladislav Bauer 17 | */ 18 | 19 | public class AVVideoOptions extends AVOptions { 20 | 21 | public static final String FLAG_VIDEO_FRAMES_COUNT = "-vframes"; 22 | public static final String FLAG_FRAME_RATE = "-r"; 23 | public static final String FLAG_RESIZE = "-s"; 24 | public static final String FLAG_ASPECT_RATIO = "-aspect"; 25 | public static final String FLAG_DISABLE_VIDEO_RECORDING = "-vn"; 26 | public static final String FLAG_VIDEO_CODEC = "-vcodec"; 27 | public static final String FLAG_MOV_FLAGS = "-movflags"; 28 | public static final String FLAG_PASS_COUNT = "-pass"; 29 | public static final String FLAG_PASS_LOG_FILE_PREFIX = "-passlogfile"; 30 | public static final String FLAG_FILTER = "-vf"; 31 | 32 | public static final String FILTER_SCALE_BY_WIDTH = "scale=w=%d:h=trunc(ow/a/2)*2"; 33 | public static final String FILTER_SCALE_BY_HEIGHT = "scale=w=trunc(oh/a/2)*2:h=%d"; 34 | 35 | 36 | public static AVVideoOptions create() { 37 | return new AVVideoOptions(); 38 | } 39 | 40 | 41 | @Override 42 | public AVVideoOptions flags(final Collection flags) { 43 | return (AVVideoOptions) super.flags(flags); 44 | } 45 | 46 | @Override 47 | public AVVideoOptions flags(final Object... flags) { 48 | return (AVVideoOptions) super.flags(flags); 49 | } 50 | 51 | @Override 52 | public AVVideoOptions builders(final Collection builders) { 53 | return (AVVideoOptions) super.builders(builders); 54 | } 55 | 56 | @Override 57 | public AVVideoOptions builders(final AVOptions... builders) { 58 | return (AVVideoOptions) super.builders(builders); 59 | } 60 | 61 | 62 | /** 63 | * ‘-vcodec codec (output)’ 64 | * Set the video codec. This is an alias for -codec:v. 65 | */ 66 | public AVVideoOptions videoCodec(final AVVideoCodecType codecType) { 67 | return videoCodec(codecType == null ? null : codecType.getName()); 68 | } 69 | 70 | public AVVideoOptions videoCodec(final String codecTypeName) { 71 | return flags(FLAG_VIDEO_CODEC, codecTypeName); 72 | } 73 | 74 | public AVVideoOptions resize(final AVStreamType streamType, final Integer width, final Integer height) { 75 | final boolean shouldResize = width != null || height != null; 76 | final String w = AVUtils.trimToEmpty(even(width)); 77 | final String h = AVUtils.trimToEmpty(even(height)); 78 | final String size = shouldResize ? String.format("%sx%s", w, h) : null; 79 | return resize(streamType, size); 80 | } 81 | 82 | public AVVideoOptions resize(final AVStreamType streamType, final AVVideoSizeType videoSizeType) { 83 | return flags(specifyStream(FLAG_RESIZE, streamType), videoSizeType == null ? null : videoSizeType.getName()); 84 | } 85 | 86 | public AVVideoOptions resize(final AVStreamType streamType, final String size) { 87 | return flags(specifyStream(FLAG_RESIZE, streamType), size); 88 | } 89 | 90 | /** 91 | * ‘-vf filter_graph (output)’ 92 | * filter_graph is a description of the filter graph to apply to the input video. 93 | * Use the option "-filters" to show all the available filters (including also sources and sinks). 94 | * This is an alias for -filter:v. 95 | */ 96 | public AVVideoOptions filter(final String filter, final Object... params) { 97 | return flags(FLAG_FILTER, format(filter, params)); 98 | } 99 | 100 | public AVVideoOptions proportionalResizeUsingWidth(final Integer width) { 101 | return filter(FILTER_SCALE_BY_WIDTH, even(width)); 102 | } 103 | 104 | public AVVideoOptions proportionalResizeUsingHeight(final Integer height) { 105 | return filter(FILTER_SCALE_BY_HEIGHT, even(height)); 106 | } 107 | 108 | /** 109 | * ‘-r[:stream_specifier] fps (input/output,per-stream)’ 110 | * Set frame rate (Hz value, fraction or abbreviation). 111 | * 112 | * As an input option, ignore any timestamps stored in the file and instead generate timestamps assuming constant 113 | * frame rate fps. 114 | * 115 | * As an output option, duplicate or drop input frames to achieve constant output frame rate fps 116 | * (note that this actually causes the fps filter to be inserted to the end of the corresponding filtergraph). 117 | */ 118 | public AVVideoOptions frameRate(final AVStreamType streamType, final Integer rate) { 119 | return flags(specifyStream(FLAG_FRAME_RATE, streamType), rate); 120 | } 121 | 122 | public AVVideoOptions frameRate(final Integer rate) { 123 | return frameRate(null, rate); 124 | } 125 | 126 | /** 127 | * ‘-movflags frag_keyframe’ 128 | * Start a new fragment at each video keyframe. 129 | */ 130 | public AVVideoOptions movFlags(final AVMovFlagsType movFlagsType) { 131 | return movFlags(movFlagsType == null ? null : movFlagsType.getName()); 132 | } 133 | 134 | public AVVideoOptions movFlags(final String movFlagsTypeName) { 135 | return flags(FLAG_MOV_FLAGS, movFlagsTypeName); 136 | } 137 | 138 | /** 139 | * ‘-vframes number (output)’ 140 | * Set the number of video frames to record. This is an alias for -frames:v. 141 | */ 142 | public AVVideoOptions framesCount(final Long count) { 143 | return flags(FLAG_VIDEO_FRAMES_COUNT, count); 144 | } 145 | 146 | /** 147 | * ‘-aspect[:stream_specifier] aspect (output,per-stream)’ 148 | * Set the video display aspect ratio specified by aspect. 149 | * 150 | * aspect can be a floating point number string, or a string of the form num:den, where num and den are the 151 | * numerator and denominator of the aspect ratio. For example "4:3", "16:9", "1.3333", and "1.7777" are valid 152 | * argument values. 153 | */ 154 | public AVVideoOptions aspectRatio(final AVStreamType streamType, final String ratio) { 155 | return flags(specifyStream(FLAG_ASPECT_RATIO, streamType), ratio); 156 | } 157 | 158 | public AVVideoOptions aspectRatio(final String ratio) { 159 | return aspectRatio(null, ratio); 160 | } 161 | 162 | public AVVideoOptions aspectRatio(final AVStreamType streamType, final Integer width, final Integer height) { 163 | return aspectRatio(streamType, format("%d:%d", width, height)); 164 | } 165 | 166 | public AVVideoOptions aspectRatio(final Integer width, final Integer height) { 167 | return aspectRatio(null, width, height); 168 | } 169 | 170 | public AVVideoOptions aspectRatio(final AVStreamType streamType, final Double ratio) { 171 | return aspectRatio(streamType, format("%.4f", ratio)); 172 | } 173 | 174 | public AVVideoOptions aspectRatio(final Double ratio) { 175 | return aspectRatio(null, ratio); 176 | } 177 | 178 | /** 179 | * ‘-vn (output)’ 180 | * Disable video recording. 181 | */ 182 | public AVVideoOptions disableRecording() { 183 | return flags(FLAG_DISABLE_VIDEO_RECORDING); 184 | } 185 | 186 | /** 187 | * ‘-pass[:stream_specifier] n (output,per-stream)’ 188 | * Select the pass number (1 or 2). It is used to do two-pass video encoding. The statistics of the video are 189 | * recorded in the first pass into a log file (see also the option -passlogfile), and in the second pass that log 190 | * file is used to generate the video at the exact requested bitrate. On pass 1, you may just deactivate audio 191 | * and set output to null, examples for Windows and Unix: 192 | * 193 | * avconv -i foo.mov -c:v libxvid -pass 1 -an -f rawvideo -y NUL 194 | * avconv -i foo.mov -c:v libxvid -pass 1 -an -f rawvideo -y /dev/null 195 | */ 196 | public AVVideoOptions passCount(final AVStreamType streamType, final Integer pass) { 197 | return flags(specifyStream(FLAG_PASS_COUNT, streamType), pass); 198 | } 199 | 200 | public AVVideoOptions passCount(final Integer pass) { 201 | return passCount(null, pass); 202 | } 203 | 204 | public AVVideoOptions onePassEncoding(final AVStreamType streamType) { 205 | return passCount(streamType, 1); 206 | } 207 | 208 | public AVVideoOptions onePassEncoding() { 209 | return onePassEncoding(null); 210 | } 211 | 212 | public AVVideoOptions twoPassEncoding(final AVStreamType streamType) { 213 | return passCount(streamType, 2); 214 | } 215 | 216 | public AVVideoOptions twoPassEncoding() { 217 | return twoPassEncoding(null); 218 | } 219 | 220 | /** 221 | * ‘-passlogfile[:stream_specifier] prefix (output,per-stream)’ 222 | * Set two-pass log file name prefix to prefix, the default file name prefix is “av2pass”. 223 | * The complete file name will be ‘PREFIX-N.log’, where N is a number specific to the output stream. 224 | */ 225 | public AVVideoOptions passLogFilePrefix(final AVStreamType streamType, final String prefix) { 226 | return flags(specifyStream(FLAG_PASS_LOG_FILE_PREFIX, streamType), prefix); 227 | } 228 | 229 | public AVVideoOptions passLogFilePrefix(final String prefix) { 230 | return passLogFilePrefix(null, prefix); 231 | } 232 | 233 | } 234 | -------------------------------------------------------------------------------- /src/main/java/com/github/vbauer/avconv4java/option/advanced/AVAdvancedOptions.java: -------------------------------------------------------------------------------- 1 | package com.github.vbauer.avconv4java.option.advanced; 2 | 3 | import com.github.vbauer.avconv4java.core.AVOptions; 4 | import com.github.vbauer.avconv4java.type.AVVideoSyncType; 5 | 6 | /** 7 | * @see Official doc: "5.12 Advanced options" 8 | * 9 | * @author Vladislav Bauer 10 | */ 11 | 12 | public class AVAdvancedOptions extends AVOptions { 13 | 14 | public static final String FLAG_BENCHMARK = "-benchmark"; 15 | public static final String FLAG_TIME_LIMIT = "-timelimit"; 16 | public static final String FLAG_DUMP = "-dump"; 17 | public static final String FLAG_HEX = "-hex"; 18 | public static final String FLAG_VIDEO_SYNC_METHOD = "-vsync"; 19 | public static final String FLAG_COPY_TIMESTAMPS = "-copyts"; 20 | public static final String FLAG_COPY_TIME_BASE = "-copytb"; 21 | public static final String FLAG_DISCONTINUITY_DELTA_THRESHOLD = "-dts_delta_threshold"; 22 | public static final String FLAG_FILTER_COMPLEX_SCRIPT = "-filter_complex_script"; 23 | public static final String FLAG_SHORTEST = "-shortest"; 24 | public static final String FLAG_MAX_DEMUX_DELAY = "-muxdelay"; 25 | public static final String FLAG_DEMUX_PRELOAD_DELAY = "-muxpreload"; 26 | public static final String FLAG_ACCURATE_SEEK = "-accurate_seek"; 27 | public static final String FLAG_NO_ACCURATE_SEEK = "-noaccurate_seek"; 28 | 29 | 30 | public static AVAdvancedOptions create() { 31 | return new AVAdvancedOptions(); 32 | } 33 | 34 | 35 | @Override 36 | public AVAdvancedOptions flags(final Object... flags) { 37 | return (AVAdvancedOptions) super.flags(flags); 38 | } 39 | 40 | @Override 41 | public AVAdvancedOptions builders(final AVOptions... builders) { 42 | return (AVAdvancedOptions) super.builders(builders); 43 | } 44 | 45 | 46 | /** 47 | * Show benchmarking information at the end of an encode. Shows CPU time used and maximum memory consumption. 48 | * Maximum memory consumption is not supported on all systems, it will usually display as 0 if not supported. 49 | * CMD: ‘-benchmark (global)’ 50 | */ 51 | public AVAdvancedOptions benchmark() { 52 | return flags(FLAG_BENCHMARK); 53 | } 54 | 55 | /** 56 | * Exit after avconv has been running for duration seconds. 57 | * CMD: ‘-timelimit duration (global)’ 58 | */ 59 | public AVAdvancedOptions timeLimit(final Long limit) { 60 | return flags(FLAG_TIME_LIMIT, limit); 61 | } 62 | 63 | /** 64 | * Dump each input packet to stderr. 65 | * CMD: ‘-dump (global)’ 66 | */ 67 | public AVAdvancedOptions dump() { 68 | return flags(FLAG_DUMP); 69 | } 70 | 71 | /** 72 | * ‘-hex (global)’ 73 | * When dumping packets, also dump the payload. 74 | */ 75 | public AVAdvancedOptions hex() { 76 | return flags(FLAG_HEX); 77 | } 78 | 79 | /** 80 | * Video sync method. 81 | * CMD: ‘-vsync parameter’ 82 | */ 83 | public AVAdvancedOptions videoSyncMethod(final AVVideoSyncType videoSyncType) { 84 | return videoSyncMethod(videoSyncType == null ? null : videoSyncType.getName()); 85 | } 86 | 87 | public AVAdvancedOptions videoSyncMethod(final String videoSyncTypeName) { 88 | return flags(FLAG_VIDEO_SYNC_METHOD, videoSyncTypeName); 89 | } 90 | 91 | /** 92 | * Copy timestamps from input to output. 93 | * CMD: ‘-copyts’ 94 | */ 95 | public AVAdvancedOptions copyTimestamps() { 96 | return flags(FLAG_COPY_TIMESTAMPS); 97 | } 98 | 99 | /** 100 | * Copy input stream time base from input to output when stream copying. 101 | * CMD: ‘-copytb’ 102 | */ 103 | public AVAdvancedOptions copyTimeBase() { 104 | return flags(FLAG_COPY_TIME_BASE); 105 | } 106 | 107 | /** 108 | * Timestamp discontinuity delta threshold. 109 | * CMD: ‘-dts_delta_threshold’ 110 | */ 111 | public AVAdvancedOptions discontinuityDeltaThreshold() { 112 | return flags(FLAG_DISCONTINUITY_DELTA_THRESHOLD); 113 | } 114 | 115 | /** 116 | * This option is similar to ‘-filter_complex’, the only difference is that its argument is the name of the file 117 | * from which a complex filtergraph description is to be read. 118 | * CMD: ‘-filter_complex_script filename (global)’ 119 | */ 120 | public AVAdvancedOptions filterComplexScript(final String fileName) { 121 | return flags(FLAG_FILTER_COMPLEX_SCRIPT, fileName); 122 | } 123 | 124 | /** 125 | * Finish encoding when the shortest input stream ends. 126 | * CMD: ‘-shortest (output)’ 127 | */ 128 | public AVAdvancedOptions shortest() { 129 | return flags(FLAG_SHORTEST); 130 | } 131 | 132 | /** 133 | * Set the maximum demux-decode delay. 134 | * CMD: ‘-muxdelay seconds (input)’ 135 | */ 136 | public AVAdvancedOptions maxDemuxDelay(final Long seconds) { 137 | return flags(FLAG_MAX_DEMUX_DELAY, seconds); 138 | } 139 | 140 | /** 141 | * Set the initial demux-decode delay. 142 | * CMD: ‘-muxpreload seconds (input)’ 143 | */ 144 | public AVAdvancedOptions demuxPreLoadDelay(final Long seconds) { 145 | return flags(FLAG_DEMUX_PRELOAD_DELAY, seconds); 146 | } 147 | 148 | /** 149 | * This option enables or disables accurate seeking in input files with the ‘-ss’ option. 150 | * It is enabled by default, so seeking is accurate when transcoding. Use ‘-noaccurate_seek’ to disable it, 151 | * which may be useful e.g. when copying some streams and transcoding the others. 152 | * CMD: ‘-accurate_seek (input)’ 153 | */ 154 | public AVAdvancedOptions accurateSeek(final boolean accurate) { 155 | return flags(accurate ? FLAG_ACCURATE_SEEK : FLAG_NO_ACCURATE_SEEK); 156 | } 157 | 158 | } 159 | -------------------------------------------------------------------------------- /src/main/java/com/github/vbauer/avconv4java/option/advanced/AVAdvancedVideoOptions.java: -------------------------------------------------------------------------------- 1 | package com.github.vbauer.avconv4java.option.advanced; 2 | 3 | import com.github.vbauer.avconv4java.core.AVOptions; 4 | import com.github.vbauer.avconv4java.type.AVHardwareAccelerationType; 5 | import com.github.vbauer.avconv4java.type.AVStreamType; 6 | 7 | /** 8 | * @see Official doc: "5.8 Advanced Video Options" 9 | * 10 | * @author Vladislav Bauer 11 | */ 12 | 13 | public class AVAdvancedVideoOptions extends AVOptions { 14 | 15 | public static final String FLAG_PIXEL_FORMAT = "-pix_fmt"; 16 | public static final String FLAG_SW_SCALER_FLAGS = "-sws_flags"; 17 | public static final String FLAG_DISCARD_THRESHOLD = "-vdt"; 18 | public static final String FLAG_DUMP_VIDEO_ENCODING_STATISTICS = "-vstats"; 19 | public static final String FLAG_DUMP_VIDEO_ENCODING_STATISTICS_FILE = "-vstats_file"; 20 | public static final String FLAG_HARDWARE_ACCELERATION = "-hwaccel"; 21 | 22 | 23 | public static AVAdvancedVideoOptions create() { 24 | return new AVAdvancedVideoOptions(); 25 | } 26 | 27 | 28 | @Override 29 | public AVAdvancedVideoOptions flags(final Object... flags) { 30 | return (AVAdvancedVideoOptions) super.flags(flags); 31 | } 32 | 33 | @Override 34 | public AVAdvancedVideoOptions builders(final AVOptions... builders) { 35 | return (AVAdvancedVideoOptions) super.builders(builders); 36 | } 37 | 38 | 39 | /** 40 | * Set pixel format. Use -pix_fmts to show all the supported pixel formats. 41 | * CMD: ‘-pix_fmt[:stream_specifier] format (input/output,per-stream)’ 42 | */ 43 | public AVAdvancedVideoOptions pixelFormat(final AVStreamType streamType, final String format) { 44 | return flags(specifyStream(FLAG_PIXEL_FORMAT, streamType), format); 45 | } 46 | 47 | public AVAdvancedVideoOptions pixelFormat(final String format) { 48 | return pixelFormat(null, format); 49 | } 50 | 51 | /** 52 | * Set SwScaler flags. 53 | * CMD: ‘-sws_flags flags (input/output)’ 54 | */ 55 | public AVAdvancedVideoOptions swScalerFlags(final String flags) { 56 | return flags(FLAG_SW_SCALER_FLAGS, flags); 57 | } 58 | 59 | /** 60 | * Discard threshold. 61 | * CMD: ‘-vdt n’ 62 | */ 63 | public AVAdvancedVideoOptions discardThreshold(final Integer threshold) { 64 | return flags(FLAG_DISCARD_THRESHOLD, threshold); 65 | } 66 | 67 | /** 68 | * Dump video coding statistics to ‘vstats_HHMMSS.log’. 69 | * CMD: ‘-vstats’ 70 | */ 71 | public AVAdvancedVideoOptions dumpVideoEncodingStatistics() { 72 | return flags(FLAG_DUMP_VIDEO_ENCODING_STATISTICS); 73 | } 74 | 75 | /** 76 | * Dump video coding statistics to file. 77 | * CMD: ‘-vstats_file file’ 78 | */ 79 | public AVAdvancedVideoOptions dumpVideoEncodingStatistics(final String fileName) { 80 | return flags(FLAG_DUMP_VIDEO_ENCODING_STATISTICS_FILE, fileName); 81 | } 82 | 83 | /** 84 | * Use hardware acceleration to decode the matching stream(s). 85 | * 86 | * This option has no effect if the selected hwaccel is not available or not supported by the chosen decoder. 87 | * 88 | * Note that most acceleration methods are intended for playback and will not be faster than software decoding 89 | * on modern CPUs. Additionally, avconv will usually need to copy the decoded frames from the GPU memory into 90 | * the system memory, resulting in further performance loss. This option is thus mainly useful for testing. 91 | * 92 | * CMD: ‘-hwaccel[:stream_specifier] hwaccel (input,per-stream)’ 93 | */ 94 | public AVAdvancedVideoOptions hardwareAcceleration( 95 | final AVStreamType streamType, final AVHardwareAccelerationType accelerationType 96 | ) { 97 | final String hardwareAccelerationTypeName = accelerationType.getName(); 98 | return hardwareAcceleration(streamType, hardwareAccelerationTypeName); 99 | } 100 | 101 | public AVAdvancedVideoOptions hardwareAcceleration(final AVStreamType streamType, final String accelerationType) { 102 | return flags(specifyStream(FLAG_HARDWARE_ACCELERATION, streamType), accelerationType); 103 | } 104 | 105 | } 106 | -------------------------------------------------------------------------------- /src/main/java/com/github/vbauer/avconv4java/type/AVAudioCodecType.java: -------------------------------------------------------------------------------- 1 | package com.github.vbauer.avconv4java.type; 2 | 3 | import com.github.vbauer.avconv4java.util.AVUtils; 4 | 5 | /** 6 | * @author Vladislav Bauer 7 | */ 8 | 9 | public enum AVAudioCodecType implements NamedType { 10 | 11 | VORBIS(Constants.VORBIS), 12 | 13 | /** 14 | * May be used only with -strict experimental. 15 | * Not so stable yet and overall quality is very bad, but bundled with avconv 16 | */ 17 | AAC(Constants.AAC), 18 | 19 | /** 20 | * The best aac encoder so far, but separate lib. 21 | */ 22 | FDK_AAC(Constants.FDK_AAC), 23 | 24 | /** 25 | * Not bad encoder, bundled with daily windows builds. 26 | */ 27 | VISUAL_ON_AAC(Constants.VISUAL_ON_ACC); 28 | 29 | 30 | private final String name; 31 | 32 | 33 | AVAudioCodecType(final String name) { 34 | this.name = name; 35 | } 36 | 37 | 38 | @Override 39 | public String getName() { 40 | return name; 41 | } 42 | 43 | 44 | public static AVAudioCodecType findByName(final String name) { 45 | return AVUtils.findByName(AVAudioCodecType.class, name); 46 | } 47 | 48 | 49 | /** 50 | * @author Vladislav Bauer 51 | */ 52 | 53 | public static final class Constants { 54 | 55 | public static final String VORBIS = "libvorbis"; 56 | public static final String AAC = "aac"; 57 | public static final String FDK_AAC = "libfdk_aac"; 58 | public static final String VISUAL_ON_ACC = "libvo_aacenc"; 59 | 60 | 61 | private Constants() { 62 | throw new UnsupportedOperationException(); 63 | } 64 | 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /src/main/java/com/github/vbauer/avconv4java/type/AVCodecFlagType.java: -------------------------------------------------------------------------------- 1 | package com.github.vbauer.avconv4java.type; 2 | 3 | import com.github.vbauer.avconv4java.util.AVUtils; 4 | 5 | /** 6 | * @author Vladislav Bauer 7 | */ 8 | 9 | public enum AVCodecFlagType implements NamedType { 10 | 11 | /** 12 | * Allow decoders to produce unaligned output. 13 | */ 14 | UNALIGNED(Constants.UNALIGNED), 15 | 16 | /** 17 | * Use four motion vectors per macroblock (MPEG-4). 18 | */ 19 | MV4(Constants.MV4), 20 | 21 | /** 22 | * Use 1/4-pel motion compensation. 23 | */ 24 | QPEL(Constants.QPEL), 25 | 26 | /** 27 | * Use loop filter. 28 | */ 29 | LOOP(Constants.LOOP), 30 | 31 | /** 32 | * Use fixed qscale. 33 | */ 34 | QSCALE(Constants.QSCALE), 35 | 36 | /** 37 | * Use gmc. 38 | */ 39 | GMC(Constants.GMC), 40 | 41 | /** 42 | * Always try a mb with mv="0,0". 43 | */ 44 | MV0(Constants.MV0), 45 | 46 | /** 47 | * Use internal 2-pass ratecontrol in first pass mode. 48 | */ 49 | INPUT_PRESERVED(Constants.INPUT_PRESERVED), 50 | 51 | PASS1(Constants.PASS1), 52 | 53 | /** 54 | * Use internal 2-pass ratecontrol in second pass mode. 55 | */ 56 | PASS2(Constants.PASS2), 57 | 58 | /** 59 | * Only decode/encode grayscale. 60 | */ 61 | GRAY(Constants.GRAY), 62 | 63 | /** 64 | * Do not draw edges. 65 | */ 66 | EMU_EDGE(Constants.EMU_EDGE), 67 | 68 | /** 69 | * Error[?] variables will be set during encoding. 70 | */ 71 | PSNR(Constants.PSNR), 72 | 73 | /** 74 | * Normalize adaptive quantization. 75 | */ 76 | TRUNCATED(Constants.TRUNCATED), 77 | 78 | NAQ(Constants.NAQ), 79 | 80 | /** 81 | * Use interlaced DCT. 82 | */ 83 | ILDCT(Constants.ILDCT), 84 | 85 | /** 86 | * Force low delay. 87 | */ 88 | LOW_DELAY(Constants.LOW_DELAY), 89 | 90 | /** 91 | * Place global headers in extradata instead of every keyframe. 92 | */ 93 | GLOBAL_HEADER(Constants.GLOBAL_HEADER), 94 | 95 | /** 96 | * Use only bitexact functions (except (I)DCT). 97 | */ 98 | BITEXACT(Constants.BITEXACT), 99 | 100 | /** 101 | * H.263 advanced intra coding / MPEG-4 AC prediction. 102 | */ 103 | AIC(Constants.AIC), 104 | 105 | /** 106 | * Interlaced motion estimation. 107 | */ 108 | ILME(Constants.ILME), 109 | 110 | /** 111 | * Closed GOP. 112 | */ 113 | CGOP(Constants.CGOP), 114 | 115 | /** 116 | * Output even potentially corrupted frames. 117 | */ 118 | OUTPUT_CORRUPT(Constants.OUTPUT_CORRUPT); 119 | 120 | 121 | private final String name; 122 | 123 | 124 | AVCodecFlagType(final String name) { 125 | this.name = name; 126 | } 127 | 128 | 129 | @Override 130 | public String getName() { 131 | return name; 132 | } 133 | 134 | 135 | public static AVCodecFlagType findByName(final String name) { 136 | return AVUtils.findByName(AVCodecFlagType.class, name); 137 | } 138 | 139 | 140 | /** 141 | * @author Vladislav Bauer 142 | */ 143 | 144 | public static final class Constants { 145 | 146 | public static final String UNALIGNED = "unaligned"; 147 | public static final String MV4 = "mv4"; 148 | public static final String QPEL = "qpel"; 149 | public static final String LOOP = "loop"; 150 | public static final String QSCALE = "qscale"; 151 | public static final String GMC = "gmc"; 152 | public static final String MV0 = "mv0"; 153 | public static final String INPUT_PRESERVED = "input_preserved"; 154 | public static final String PASS1 = "pass1"; 155 | public static final String PASS2 = "pass2"; 156 | public static final String GRAY = "gray"; 157 | public static final String EMU_EDGE = "emu_edge"; 158 | public static final String PSNR = "psnr"; 159 | public static final String TRUNCATED = "truncated"; 160 | public static final String NAQ = "naq"; 161 | public static final String ILDCT = "ildct"; 162 | public static final String LOW_DELAY = "low_delay"; 163 | public static final String GLOBAL_HEADER = "global_header"; 164 | public static final String BITEXACT = "bitexact"; 165 | public static final String AIC = "aic"; 166 | public static final String ILME = "ilme"; 167 | public static final String CGOP = "cgop"; 168 | public static final String OUTPUT_CORRUPT = "output_corrupt"; 169 | 170 | 171 | private Constants() { 172 | throw new UnsupportedOperationException(); 173 | } 174 | 175 | } 176 | 177 | } 178 | -------------------------------------------------------------------------------- /src/main/java/com/github/vbauer/avconv4java/type/AVDebugInfoType.java: -------------------------------------------------------------------------------- 1 | package com.github.vbauer.avconv4java.type; 2 | 3 | import com.github.vbauer.avconv4java.util.AVUtils; 4 | 5 | /** 6 | * @author Vladislav Bauer 7 | */ 8 | 9 | public enum AVDebugInfoType implements NamedType { 10 | 11 | /** 12 | * Picture info. 13 | */ 14 | PICT(Constants.PICT), 15 | 16 | /* 17 | * Rate control. 18 | */ 19 | RC(Constants.RC), 20 | 21 | /* 22 | * Macroblock (MB) type. 23 | */ 24 | BIT_STREAM(Constants.BIT_STREAM), 25 | 26 | MB_TYPE(Constants.MB_TYPE), 27 | 28 | /** 29 | * Per-block quantization parameter (QP). 30 | */ 31 | QP(Constants.QP), 32 | 33 | /** 34 | * Motion vector. 35 | */ 36 | MV(Constants.MV), 37 | 38 | DCT_COEFF(Constants.DCT_COEFF), 39 | 40 | SKIP(Constants.SKIP), 41 | 42 | START_CODE(Constants.START_CODE), 43 | 44 | PTS(Constants.PTS), 45 | 46 | ER(Constants.ER), 47 | 48 | /** 49 | * Memory management control operations (H.264). 50 | */ 51 | MMCO(Constants.MMCO), 52 | 53 | BUGS(Constants.BUGS), 54 | 55 | /** 56 | * Visualize quantization parameter (QP), lower QP are tinted greener. 57 | */ 58 | VIS_QP(Constants.VIS_QP), 59 | 60 | /** 61 | * Visualize block types. 62 | */ 63 | VIS_MB_TYPE(Constants.VIS_MB_TYPE), 64 | 65 | /** 66 | * Picture buffer allocations. 67 | */ 68 | BUFFERS(Constants.BUFFERS), 69 | 70 | /** 71 | * Threading operations. 72 | */ 73 | THREAD_OPS(Constants.THREAD_OPS); 74 | 75 | 76 | private final String name; 77 | 78 | 79 | AVDebugInfoType(final String name) { 80 | this.name = name; 81 | } 82 | 83 | 84 | @Override 85 | public String getName() { 86 | return name; 87 | } 88 | 89 | 90 | public static AVDebugInfoType findByName(final String name) { 91 | return AVUtils.findByName(AVDebugInfoType.class, name); 92 | } 93 | 94 | 95 | /** 96 | * @author Vladislav Bauer 97 | */ 98 | 99 | public static final class Constants { 100 | 101 | public static final String PICT = "pict"; 102 | public static final String RC = "rc"; 103 | public static final String BIT_STREAM = "bitstream"; 104 | public static final String MB_TYPE = "mb_type"; 105 | public static final String QP = "qp"; 106 | public static final String MV = "mv"; 107 | public static final String DCT_COEFF = "dct_coeff"; 108 | public static final String SKIP = "skip"; 109 | public static final String START_CODE = "startcode"; 110 | public static final String PTS = "pts"; 111 | public static final String ER = "er"; 112 | public static final String MMCO = "mmco"; 113 | public static final String BUGS = "bugs"; 114 | public static final String VIS_QP = "vis_qp"; 115 | public static final String VIS_MB_TYPE = "vis_mb_type"; 116 | public static final String BUFFERS = "buffers"; 117 | public static final String THREAD_OPS = "thread_ops"; 118 | 119 | 120 | private Constants() { 121 | throw new UnsupportedOperationException(); 122 | } 123 | 124 | } 125 | 126 | } 127 | -------------------------------------------------------------------------------- /src/main/java/com/github/vbauer/avconv4java/type/AVErrorDetectionType.java: -------------------------------------------------------------------------------- 1 | package com.github.vbauer.avconv4java.type; 2 | 3 | import com.github.vbauer.avconv4java.util.AVUtils; 4 | 5 | /** 6 | * @author Vladislav Bauer 7 | */ 8 | 9 | public enum AVErrorDetectionType implements NamedType { 10 | 11 | /** 12 | * Verify embedded CRCs. 13 | */ 14 | CRC_CHECK(Constants.CRC_CHECK), 15 | 16 | /** 17 | * Detect bitstream specification deviations. 18 | */ 19 | BIT_STREAM(Constants.BIT_STREAM), 20 | 21 | /** 22 | * Detect improper bitstream length. 23 | */ 24 | BUFFER(Constants.BUFFER), 25 | 26 | /** 27 | * Abort decoding on minor error detection. 28 | */ 29 | EXPLODE(Constants.EXPLODE); 30 | 31 | 32 | private final String name; 33 | 34 | 35 | AVErrorDetectionType(final String name) { 36 | this.name = name; 37 | } 38 | 39 | 40 | @Override 41 | public String getName() { 42 | return name; 43 | } 44 | 45 | 46 | public static AVErrorDetectionType findByName(final String name) { 47 | return AVUtils.findByName(AVErrorDetectionType.class, name); 48 | } 49 | 50 | 51 | /** 52 | * @author Vladislav Bauer 53 | */ 54 | 55 | public static final class Constants { 56 | 57 | public static final String CRC_CHECK = "crccheck"; 58 | public static final String BIT_STREAM = "bitstream"; 59 | public static final String BUFFER = "buffer"; 60 | public static final String EXPLODE = "explode"; 61 | 62 | 63 | private Constants() { 64 | throw new UnsupportedOperationException(); 65 | } 66 | 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/com/github/vbauer/avconv4java/type/AVFileFormatType.java: -------------------------------------------------------------------------------- 1 | package com.github.vbauer.avconv4java.type; 2 | 3 | import com.github.vbauer.avconv4java.util.AVUtils; 4 | 5 | /** 6 | * @author Vladislav Bauer 7 | */ 8 | 9 | public enum AVFileFormatType implements NamedType { 10 | 11 | /** 12 | * Image file muxer. 13 | */ 14 | IMAGE(Constants.IMAGE), 15 | 16 | /** 17 | * CRC (Cyclic Redundancy Check) testing format. 18 | */ 19 | CRC(Constants.CRC), 20 | 21 | /** 22 | * Per-frame CRC (Cyclic Redundancy Check) testing format. 23 | */ 24 | FRAME_CRC(Constants.FRAME_CRC), 25 | 26 | /** 27 | * Apple HTTP Live Streaming muxer that segments MPEG-TS according to the HTTP Live Streaming specification. 28 | */ 29 | HLS(Constants.HLS), 30 | 31 | /** 32 | * MPEG transport stream muxer. 33 | */ 34 | MPEG_TRANSPORT(Constants.MPEG_TRANSPORT), 35 | 36 | /** 37 | * Null muxer. 38 | */ 39 | NULL(Constants.NULL), 40 | 41 | /** 42 | * Matroska container muxer. 43 | */ 44 | MATROSKA(Constants.MATROSKA), 45 | 46 | /** 47 | * Basic stream segmenter. 48 | */ 49 | SEGMENT(Constants.SEGMENT), 50 | 51 | /** 52 | * MP3 container muxer. 53 | */ 54 | MP3(Constants.MP3), 55 | 56 | /** 57 | * Ogg container muxer. 58 | */ 59 | OGG(Constants.OGG); 60 | 61 | 62 | private final String name; 63 | 64 | 65 | AVFileFormatType(final String name) { 66 | this.name = name; 67 | } 68 | 69 | 70 | @Override 71 | public String getName() { 72 | return name; 73 | } 74 | 75 | 76 | public static AVFileFormatType findByName(final String name) { 77 | return AVUtils.findByName(AVFileFormatType.class, name); 78 | } 79 | 80 | 81 | /** 82 | * @author Vladislav Bauer 83 | */ 84 | 85 | public static final class Constants { 86 | 87 | public static final String IMAGE = "image2"; 88 | public static final String CRC = "crc"; 89 | public static final String FRAME_CRC = "framecrc"; 90 | public static final String HLS = "hls"; 91 | public static final String MPEG_TRANSPORT = "mpegts"; 92 | public static final String NULL = "null"; 93 | public static final String MATROSKA = "matroska"; 94 | public static final String SEGMENT = "segment"; 95 | public static final String MP3 = "mp3"; 96 | public static final String OGG = "ogg"; 97 | 98 | 99 | private Constants() { 100 | throw new UnsupportedOperationException(); 101 | } 102 | 103 | } 104 | 105 | } 106 | -------------------------------------------------------------------------------- /src/main/java/com/github/vbauer/avconv4java/type/AVFormatDebugInfoType.java: -------------------------------------------------------------------------------- 1 | package com.github.vbauer.avconv4java.type; 2 | 3 | import com.github.vbauer.avconv4java.util.AVUtils; 4 | 5 | /** 6 | * @author Vladislav Bauer 7 | */ 8 | 9 | public enum AVFormatDebugInfoType implements NamedType { 10 | 11 | TS(Constants.TS); 12 | 13 | 14 | private final String name; 15 | 16 | 17 | AVFormatDebugInfoType(final String name) { 18 | this.name = name; 19 | } 20 | 21 | 22 | @Override 23 | public String getName() { 24 | return name; 25 | } 26 | 27 | 28 | public static AVFormatDebugInfoType findByName(final String name) { 29 | return AVUtils.findByName(AVFormatDebugInfoType.class, name); 30 | } 31 | 32 | 33 | /** 34 | * @author Vladislav Bauer 35 | */ 36 | 37 | public static final class Constants { 38 | 39 | public static final String TS = "ts"; 40 | 41 | 42 | private Constants() { 43 | throw new UnsupportedOperationException(); 44 | } 45 | 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/com/github/vbauer/avconv4java/type/AVFormatFlagType.java: -------------------------------------------------------------------------------- 1 | package com.github.vbauer.avconv4java.type; 2 | 3 | import com.github.vbauer.avconv4java.util.AVUtils; 4 | 5 | /** 6 | * @author Vladislav Bauer 7 | */ 8 | 9 | public enum AVFormatFlagType implements NamedType { 10 | 11 | /** 12 | * Reduce the latency by flushing out packets immediately. 13 | */ 14 | FLUSH_PACKETS(Constants.FLUSH_PACKETS), 15 | 16 | /** 17 | * Ignore index. 18 | */ 19 | IGNORE_INDEX(Constants.IGNORE_INDEX), 20 | 21 | /** 22 | * Generate pts. 23 | */ 24 | GENERATE_PTS(Constants.GENERATE_PTS), 25 | 26 | /** 27 | * Do not fill in missing values that can be exactly calculated. 28 | */ 29 | NO_FILL_IN(Constants.NO_FILL_IN), 30 | 31 | /** 32 | * Disable AVParsers, this needs nofillin too. 33 | */ 34 | NO_PARSE(Constants.NO_PARSE), 35 | 36 | /** 37 | * Ignore dts. 38 | */ 39 | IGNORE_DTS(Constants.IGNORE_DTS), 40 | 41 | /** 42 | * Discard corrupted frames. 43 | */ 44 | DISCARD_CORRUPTED(Constants.DISCARD_CORRUPTED), 45 | 46 | /** 47 | * Reduce the latency introduced by optional buffering. 48 | */ 49 | NO_BUFFER(Constants.NO_BUFFER); 50 | 51 | 52 | private final String name; 53 | 54 | 55 | AVFormatFlagType(final String name) { 56 | this.name = name; 57 | } 58 | 59 | 60 | @Override 61 | public String getName() { 62 | return name; 63 | } 64 | 65 | 66 | public static AVFormatFlagType findByName(final String name) { 67 | return AVUtils.findByName(AVFormatFlagType.class, name); 68 | } 69 | 70 | 71 | /** 72 | * @author Vladislav Bauer 73 | */ 74 | 75 | public static final class Constants { 76 | 77 | public static final String FLUSH_PACKETS = "flush_packets"; 78 | public static final String IGNORE_INDEX = "ignidx"; 79 | public static final String GENERATE_PTS = "genpts"; 80 | public static final String NO_FILL_IN = "nofillin"; 81 | public static final String NO_PARSE = "noparse"; 82 | public static final String IGNORE_DTS = "igndts"; 83 | public static final String DISCARD_CORRUPTED = "discardcorrupt"; 84 | public static final String NO_BUFFER = "nobuffer"; 85 | 86 | 87 | private Constants() { 88 | throw new UnsupportedOperationException(); 89 | } 90 | 91 | } 92 | 93 | } 94 | -------------------------------------------------------------------------------- /src/main/java/com/github/vbauer/avconv4java/type/AVHardwareAccelerationType.java: -------------------------------------------------------------------------------- 1 | package com.github.vbauer.avconv4java.type; 2 | 3 | import com.github.vbauer.avconv4java.util.AVUtils; 4 | 5 | /** 6 | * @author Vladislav Bauer 7 | */ 8 | 9 | public enum AVHardwareAccelerationType implements NamedType { 10 | 11 | /** 12 | * Do not use any hardware acceleration (the default). 13 | */ 14 | NONE(Constants.NONE), 15 | 16 | /** 17 | * Automatically select the hardware acceleration method. 18 | */ 19 | AUTO(Constants.AUTO), 20 | 21 | /** 22 | * Use VDPAU (Video Decode and Presentation API for Unix) hardware acceleration. 23 | */ 24 | VDPAU(Constants.VDPAU); 25 | 26 | 27 | private final String name; 28 | 29 | 30 | AVHardwareAccelerationType(final String name) { 31 | this.name = name; 32 | } 33 | 34 | 35 | @Override 36 | public String getName() { 37 | return name; 38 | } 39 | 40 | 41 | public static AVHardwareAccelerationType findByName(final String name) { 42 | return AVUtils.findByName(AVHardwareAccelerationType.class, name); 43 | } 44 | 45 | 46 | /** 47 | * @author Vladislav Bauer 48 | */ 49 | 50 | public static final class Constants { 51 | 52 | public static final String NONE = "none"; 53 | public static final String AUTO = "auto"; 54 | public static final String VDPAU = "vdpau"; 55 | 56 | 57 | private Constants() { 58 | throw new UnsupportedOperationException(); 59 | } 60 | 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/com/github/vbauer/avconv4java/type/AVLogLevelType.java: -------------------------------------------------------------------------------- 1 | package com.github.vbauer.avconv4java.type; 2 | 3 | import com.github.vbauer.avconv4java.util.AVUtils; 4 | 5 | /** 6 | * @author Vladislav Bauer 7 | */ 8 | 9 | public enum AVLogLevelType implements NamedType { 10 | 11 | QUIET(Constants.QUIET), 12 | 13 | PANIC(Constants.PANIC), 14 | 15 | FATAL(Constants.FATAL), 16 | 17 | ERROR(Constants.ERROR), 18 | 19 | WARNING(Constants.WARNING), 20 | 21 | INFO(Constants.INFO), 22 | 23 | VERBOSE(Constants.VERBOSE), 24 | 25 | DEBUG(Constants.DEBUG); 26 | 27 | 28 | private final String name; 29 | 30 | 31 | AVLogLevelType(final String name) { 32 | this.name = name; 33 | } 34 | 35 | 36 | @Override 37 | public String getName() { 38 | return name; 39 | } 40 | 41 | 42 | public static AVLogLevelType findByName(final String name) { 43 | return AVUtils.findByName(AVLogLevelType.class, name); 44 | } 45 | 46 | 47 | /** 48 | * @author Vladislav Bauer 49 | */ 50 | 51 | public static final class Constants { 52 | 53 | public static final String QUIET = "quiet"; 54 | public static final String PANIC = "panic"; 55 | public static final String FATAL = "fatal"; 56 | public static final String ERROR = "error"; 57 | public static final String WARNING = "warning"; 58 | public static final String INFO = "info"; 59 | public static final String VERBOSE = "verbose"; 60 | public static final String DEBUG = "debug"; 61 | 62 | 63 | private Constants() { 64 | throw new UnsupportedOperationException(); 65 | } 66 | 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/com/github/vbauer/avconv4java/type/AVMotionEstimationType.java: -------------------------------------------------------------------------------- 1 | package com.github.vbauer.avconv4java.type; 2 | 3 | import com.github.vbauer.avconv4java.util.AVUtils; 4 | 5 | /** 6 | * @author Vladislav Bauer 7 | */ 8 | 9 | public enum AVMotionEstimationType implements NamedType { 10 | 11 | /** 12 | * Zero motion estimation (fastest). 13 | */ 14 | ZERO(Constants.ZERO), 15 | 16 | /** 17 | * Full motion estimation (slowest). 18 | */ 19 | FULL(Constants.FULL), 20 | 21 | /** 22 | * EPZS motion estimation (default). 23 | */ 24 | EPZS(Constants.EPZS), 25 | 26 | /** 27 | * Esa motion estimation (alias for full). 28 | */ 29 | ESA(Constants.ESA), 30 | 31 | /** 32 | * Tesa motion estimation. 33 | */ 34 | TESA(Constants.TESA), 35 | 36 | /** 37 | * Diamond motion estimation (alias for EPZS). 38 | */ 39 | DIA(Constants.DIA), 40 | 41 | /** 42 | * Log motion estimation. 43 | */ 44 | LOG(Constants.LOG), 45 | 46 | /** 47 | * Phods motion estimation. 48 | */ 49 | PHODS(Constants.PHODS), 50 | 51 | /** 52 | * X1 motion estimation. 53 | */ 54 | X1(Constants.X1), 55 | 56 | /** 57 | * Hex motion estimation. 58 | */ 59 | HEX(Constants.HEX), 60 | 61 | /** 62 | * Umh motion estimation. 63 | */ 64 | UMH(Constants.UMH); 65 | 66 | 67 | private final String name; 68 | 69 | 70 | AVMotionEstimationType(final String name) { 71 | this.name = name; 72 | } 73 | 74 | 75 | @Override 76 | public String getName() { 77 | return name; 78 | } 79 | 80 | 81 | public static AVMotionEstimationType findByName(final String name) { 82 | return AVUtils.findByName(AVMotionEstimationType.class, name); 83 | } 84 | 85 | 86 | /** 87 | * @author Vladislav Bauer 88 | */ 89 | 90 | public static final class Constants { 91 | 92 | public static final String ZERO = "zero"; 93 | public static final String FULL = "full"; 94 | public static final String EPZS = "epzs"; 95 | public static final String ESA = "esa"; 96 | public static final String TESA = "tesa"; 97 | public static final String DIA = "dia"; 98 | public static final String LOG = "log"; 99 | public static final String PHODS = "phods"; 100 | public static final String X1 = "x1"; 101 | public static final String HEX = "hex"; 102 | public static final String UMH = "umh"; 103 | 104 | 105 | private Constants() { 106 | throw new UnsupportedOperationException(); 107 | } 108 | 109 | } 110 | 111 | } 112 | -------------------------------------------------------------------------------- /src/main/java/com/github/vbauer/avconv4java/type/AVMovFlagsType.java: -------------------------------------------------------------------------------- 1 | package com.github.vbauer.avconv4java.type; 2 | 3 | import com.github.vbauer.avconv4java.util.AVUtils; 4 | 5 | /** 6 | * @author Vladislav Bauer 7 | */ 8 | 9 | public enum AVMovFlagsType implements NamedType { 10 | 11 | /** 12 | * Start a new fragment at each video keyframe. 13 | */ 14 | FRAG_KEY_FRAME(Constants.FRAG_KEY_FRAME), 15 | 16 | /** 17 | * Allow the caller to manually choose when to cut fragments, by calling av_write_frame(ctx, NULL) 18 | * to write a fragment with the packets written so far. (This is only useful with other applications 19 | * integrating libavformat, not from avconv.) 20 | */ 21 | FRAG_CUSTOM(Constants.FRAG_CUSTOM), 22 | 23 | /** 24 | * Write an initial moov atom directly at the start of the file, without describing any samples in it. 25 | * Generally, an mdat/moov pair is written at the start of the file, as a normal MOV/MP4 file, containing only 26 | * a short portion of the file. With this option set, there is no initial mdat atom, and the moov atom only 27 | * describes the tracks but has a zero duration. 28 | * 29 | * Files written with this option set do not work in QuickTime. 30 | * This option is implicitly set when writing ismv (Smooth Streaming) files. 31 | */ 32 | EMPTY_MOOV(Constants.EMPTY_MOOV), 33 | 34 | /** 35 | * Write a separate moof (movie fragment) atom for each track. Normally, packets for all tracks are written 36 | * in a moof atom (which is slightly more efficient), but with this option set, the muxer writes one moof/mdat 37 | * pair for each track, making it easier to separate tracks. 38 | * 39 | * This option is implicitly set when writing ismv (Smooth Streaming) files. 40 | */ 41 | SEPARATE_MOOF(Constants.SEPARATE_MOOF), 42 | 43 | /** 44 | * Run a second pass moving the index (moov atom) to the beginning of the file. 45 | * This operation can take a while, and will not work in various situations such as fragmented output, 46 | * thus it is not enabled by default. 47 | */ 48 | FAST_START(Constants.FAST_START); 49 | 50 | 51 | private final String name; 52 | 53 | 54 | AVMovFlagsType(final String name) { 55 | this.name = name; 56 | } 57 | 58 | 59 | @Override 60 | public String getName() { 61 | return name; 62 | } 63 | 64 | 65 | public static AVMovFlagsType findByName(final String name) { 66 | return AVUtils.findByName(AVMovFlagsType.class, name); 67 | } 68 | 69 | 70 | /** 71 | * @author Vladislav Bauer 72 | */ 73 | 74 | public static final class Constants { 75 | 76 | public static final String FRAG_KEY_FRAME = "frag_keyframe"; 77 | public static final String FRAG_CUSTOM = "frag_custom"; 78 | public static final String EMPTY_MOOV = "empty_moov"; 79 | public static final String SEPARATE_MOOF = "separate_moof"; 80 | public static final String FAST_START = "faststart"; 81 | 82 | 83 | private Constants() { 84 | throw new UnsupportedOperationException(); 85 | } 86 | 87 | } 88 | 89 | } 90 | -------------------------------------------------------------------------------- /src/main/java/com/github/vbauer/avconv4java/type/AVStreamType.java: -------------------------------------------------------------------------------- 1 | package com.github.vbauer.avconv4java.type; 2 | 3 | import com.github.vbauer.avconv4java.util.AVUtils; 4 | 5 | /** 6 | * @author Vladislav Bauer 7 | */ 8 | 9 | public enum AVStreamType implements NamedType { 10 | 11 | AUDIO(Constants.AUDIO), 12 | 13 | VIDEO(Constants.VIDEO), 14 | 15 | SUBTITLE(Constants.SUBTITLE); 16 | 17 | 18 | private final String name; 19 | 20 | 21 | AVStreamType(final String name) { 22 | this.name = name; 23 | } 24 | 25 | 26 | @Override 27 | public String getName() { 28 | return name; 29 | } 30 | 31 | 32 | public static AVStreamType findByName(final String name) { 33 | return AVUtils.findByName(AVStreamType.class, name); 34 | } 35 | 36 | 37 | /** 38 | * @author Vladislav Bauer 39 | */ 40 | 41 | public static final class Constants { 42 | 43 | public static final String AUDIO = "a"; 44 | public static final String VIDEO = "v"; 45 | public static final String SUBTITLE = "s"; 46 | 47 | 48 | private Constants() { 49 | throw new UnsupportedOperationException(); 50 | } 51 | 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/com/github/vbauer/avconv4java/type/AVStrictType.java: -------------------------------------------------------------------------------- 1 | package com.github.vbauer.avconv4java.type; 2 | 3 | import com.github.vbauer.avconv4java.util.AVUtils; 4 | 5 | /** 6 | * Type shows how strictly to follow the standards. 7 | * 8 | * @author Vladislav Bauer 9 | */ 10 | 11 | public enum AVStrictType implements NamedType { 12 | 13 | /** 14 | * Strictly conform to a older more strict version of the spec or reference software. 15 | */ 16 | VERY(Constants.VERY), 17 | 18 | /** 19 | * Strictly conform to all the things in the spec no matter what the consequences. 20 | */ 21 | STRICT(Constants.STRICT), 22 | 23 | /** 24 | * Allow unofficial extensions. 25 | */ 26 | NORMAL(Constants.NORMAL), 27 | 28 | /** 29 | * Allow unofficial extensions. 30 | */ 31 | UNOFFICIAL(Constants.UNOFFICIAL), 32 | 33 | /** 34 | * Allow non-standardized experimental things. 35 | */ 36 | EXPERIMENTAL(Constants.EXPERIMENTAL); 37 | 38 | 39 | private final String name; 40 | 41 | 42 | AVStrictType(final String name) { 43 | this.name = name; 44 | } 45 | 46 | 47 | @Override 48 | public String getName() { 49 | return name; 50 | } 51 | 52 | 53 | public static AVStrictType findByName(final String name) { 54 | return AVUtils.findByName(AVStrictType.class, name); 55 | } 56 | 57 | 58 | /** 59 | * @author Vladislav Bauer 60 | */ 61 | 62 | public static final class Constants { 63 | 64 | public static final String VERY = "very"; 65 | public static final String STRICT = "strict"; 66 | public static final String NORMAL = "normal"; 67 | public static final String UNOFFICIAL = "unofficial"; 68 | public static final String EXPERIMENTAL = "experimental"; 69 | 70 | 71 | private Constants() { 72 | throw new UnsupportedOperationException(); 73 | } 74 | 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /src/main/java/com/github/vbauer/avconv4java/type/AVTargetFileType.java: -------------------------------------------------------------------------------- 1 | package com.github.vbauer.avconv4java.type; 2 | 3 | import com.github.vbauer.avconv4java.util.AVUtils; 4 | 5 | /** 6 | * @author Vladislav Bauer 7 | */ 8 | 9 | public enum AVTargetFileType implements NamedType { 10 | 11 | VCD(Constants.VCD), 12 | 13 | SVCD(Constants.SVCD), 14 | 15 | DVD(Constants.DVD), 16 | 17 | DV(Constants.DV), 18 | 19 | DV50(Constants.DV50); 20 | 21 | 22 | private final String name; 23 | 24 | 25 | AVTargetFileType(final String name) { 26 | this.name = name; 27 | } 28 | 29 | 30 | @Override 31 | public String getName() { 32 | return name; 33 | } 34 | 35 | 36 | public static AVTargetFileType findByName(final String name) { 37 | return AVUtils.findByName(AVTargetFileType.class, name); 38 | } 39 | 40 | 41 | /** 42 | * @author Vladislav Bauer 43 | */ 44 | 45 | public static final class Constants { 46 | 47 | public static final String VCD = "vcd"; 48 | public static final String SVCD = "svcd"; 49 | public static final String DVD = "dvd"; 50 | public static final String DV = "dv"; 51 | public static final String DV50 = "dv50"; 52 | 53 | public static final String PREFIX_PAL = "pal-"; 54 | public static final String PREFIX_NTSC = "ntsc-"; 55 | public static final String PREFIX_FILM = "film-"; 56 | 57 | 58 | private Constants() { 59 | throw new UnsupportedOperationException(); 60 | } 61 | 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/com/github/vbauer/avconv4java/type/AVVideoCodecType.java: -------------------------------------------------------------------------------- 1 | package com.github.vbauer.avconv4java.type; 2 | 3 | import com.github.vbauer.avconv4java.util.AVUtils; 4 | 5 | /** 6 | * @author Vladislav Bauer 7 | */ 8 | 9 | public enum AVVideoCodecType implements NamedType { 10 | 11 | H264(Constants.H264), 12 | 13 | THEORA(Constants.THEORA); 14 | 15 | 16 | private final String name; 17 | 18 | 19 | AVVideoCodecType(final String name) { 20 | this.name = name; 21 | } 22 | 23 | 24 | @Override 25 | public String getName() { 26 | return name; 27 | } 28 | 29 | 30 | public static AVVideoCodecType findByName(final String name) { 31 | return AVUtils.findByName(AVVideoCodecType.class, name); 32 | } 33 | 34 | 35 | /** 36 | * @author Vladislav Bauer 37 | */ 38 | 39 | public static final class Constants { 40 | 41 | public static final String H264 = "libx264"; 42 | public static final String THEORA = "libtheora"; 43 | 44 | 45 | private Constants() { 46 | throw new UnsupportedOperationException(); 47 | } 48 | 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/com/github/vbauer/avconv4java/type/AVVideoSizeType.java: -------------------------------------------------------------------------------- 1 | package com.github.vbauer.avconv4java.type; 2 | 3 | /** 4 | * @author Vladislav Bauer 5 | */ 6 | 7 | public enum AVVideoSizeType implements NamedType { 8 | 9 | SQCIF(Constants.SQCIF, 128, 96), 10 | 11 | QCIF(Constants.QCIF, 176, 144), 12 | 13 | CIF(Constants.CIF, 352, 288), 14 | 15 | CIF4(Constants.CIF4, 704, 576), 16 | 17 | CIF16(Constants.CIF16, 1408, 1152), 18 | 19 | QQVGA(Constants.QQVGA, 160, 120), 20 | 21 | QVGA(Constants.QVGA, 320, 240), 22 | 23 | VGA(Constants.VGA, 640, 480), 24 | 25 | SVGA(Constants.SVGA, 800, 600), 26 | 27 | XGA(Constants.XGA, 1024, 768), 28 | 29 | UXGA(Constants.UXGA, 1600, 1200), 30 | 31 | QXGA(Constants.QXGA, 2048, 1536), 32 | 33 | SXGA(Constants.SXGA, 1280, 1024), 34 | 35 | QSXGA(Constants.QSXGA, 2560, 2048), 36 | 37 | HSXGA(Constants.HSXGA, 5120, 4096), 38 | 39 | WVGA(Constants.WVGA, 852, 480), 40 | 41 | WXGA(Constants.WXGA, 1366, 768), 42 | 43 | WSXGA(Constants.WSXGA, 1600, 1024), 44 | 45 | WUXGA(Constants.WUXGA, 1920, 1200), 46 | 47 | WOXGA(Constants.WOXGA, 2560, 1600), 48 | 49 | WQSXGA(Constants.WQSXGA, 3200, 2048), 50 | 51 | WQUXGA(Constants.WQUXGA, 3840, 2400), 52 | 53 | WHSXGA(Constants.WHSXGA, 6400, 4096), 54 | 55 | WHUXGA(Constants.WHUXGA, 7680, 4800), 56 | 57 | CGA(Constants.CGA, 320, 200), 58 | 59 | EGA(Constants.EGA, 640, 350), 60 | 61 | HD480(Constants.HD480, 852, 480), 62 | 63 | HD720(Constants.HD720, 1280, 720), 64 | 65 | HD1080(Constants.HD1080, 1920, 1080); 66 | 67 | 68 | private final String name; 69 | private final int width; 70 | private final int height; 71 | 72 | 73 | AVVideoSizeType(final String name, final int width, final int height) { 74 | this.name = name; 75 | this.width = width; 76 | this.height = height; 77 | } 78 | 79 | 80 | @Override 81 | public String getName() { 82 | return name; 83 | } 84 | 85 | public int getWidth() { 86 | return width; 87 | } 88 | 89 | public int getHeight() { 90 | return height; 91 | } 92 | 93 | 94 | public static AVVideoSizeType findByName(final String name) { 95 | for (final AVVideoSizeType type : values()) { 96 | if (type.getName().equalsIgnoreCase(name)) { 97 | return type; 98 | } 99 | } 100 | return null; 101 | } 102 | 103 | 104 | /** 105 | * @author Vladislav Bauer 106 | */ 107 | 108 | public static final class Constants { 109 | 110 | public static final String SQCIF = "sqcif"; 111 | public static final String QCIF = "qcif"; 112 | public static final String CIF = "cif"; 113 | public static final String CIF4 = "4cif"; 114 | public static final String CIF16 = "16cif"; 115 | public static final String QQVGA = "qqvga"; 116 | public static final String QVGA = "qvga"; 117 | public static final String VGA = "vga"; 118 | public static final String SVGA = "svga"; 119 | public static final String XGA = "xga"; 120 | public static final String UXGA = "uxga"; 121 | public static final String QXGA = "qxga"; 122 | public static final String SXGA = "sxga"; 123 | public static final String QSXGA = "qsxga"; 124 | public static final String HSXGA = "hsxga"; 125 | public static final String WVGA = "wvga"; 126 | public static final String WXGA = "wxga"; 127 | public static final String WSXGA = "wsxga"; 128 | public static final String WUXGA = "wuxga"; 129 | public static final String WOXGA = "woxga"; 130 | public static final String WQSXGA = "wqsxga"; 131 | public static final String WQUXGA = "wquxga"; 132 | public static final String WHSXGA = "whsxga"; 133 | public static final String WHUXGA = "whuxga"; 134 | public static final String CGA = "cga"; 135 | public static final String EGA = "ega"; 136 | public static final String HD480 = "hd480"; 137 | public static final String HD720 = "hd720"; 138 | public static final String HD1080 = "hd1080"; 139 | 140 | 141 | private Constants() { 142 | throw new UnsupportedOperationException(); 143 | } 144 | 145 | } 146 | 147 | } 148 | -------------------------------------------------------------------------------- /src/main/java/com/github/vbauer/avconv4java/type/AVVideoSyncType.java: -------------------------------------------------------------------------------- 1 | package com.github.vbauer.avconv4java.type; 2 | 3 | import com.github.vbauer.avconv4java.util.AVUtils; 4 | 5 | /** 6 | * @author Vladislav Bauer 7 | */ 8 | 9 | public enum AVVideoSyncType implements NamedType { 10 | 11 | /** 12 | * Each frame is passed with its timestamp from the demuxer to the muxer. 13 | */ 14 | PASS_THROUGH(Constants.PASS_THROUGH), 15 | 16 | /** 17 | * Frames will be duplicated and dropped to achieve exactly the requested constant framerate. 18 | */ 19 | CRF(Constants.CFR), 20 | 21 | /** 22 | * Frames are passed through with their timestamp or dropped so as to prevent 2 frames from having same timestamp. 23 | */ 24 | VFR(Constants.VFR), 25 | 26 | /** 27 | * Chooses between 1 and 2 depending on muxer capabilities. This is the default method. 28 | */ 29 | AUTO(Constants.AUTO); 30 | 31 | 32 | private final String name; 33 | 34 | 35 | AVVideoSyncType(final String name) { 36 | this.name = name; 37 | } 38 | 39 | 40 | @Override 41 | public String getName() { 42 | return name; 43 | } 44 | 45 | 46 | public static AVVideoSyncType findByName(final String name) { 47 | return AVUtils.findByName(AVVideoSyncType.class, name); 48 | } 49 | 50 | 51 | /** 52 | * @author Vladislav Bauer 53 | */ 54 | 55 | public static final class Constants { 56 | 57 | public static final String PASS_THROUGH = "passthrough"; 58 | public static final String CFR = "cfr"; 59 | public static final String VFR = "vfr"; 60 | public static final String AUTO = "auto"; 61 | 62 | 63 | private Constants() { 64 | throw new UnsupportedOperationException(); 65 | } 66 | 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/com/github/vbauer/avconv4java/type/NamedType.java: -------------------------------------------------------------------------------- 1 | package com.github.vbauer.avconv4java.type; 2 | 3 | /** 4 | * @author Vladislav Bauer 5 | */ 6 | 7 | public interface NamedType { 8 | 9 | String getName(); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/github/vbauer/avconv4java/util/AVUtils.java: -------------------------------------------------------------------------------- 1 | package com.github.vbauer.avconv4java.util; 2 | 3 | import com.github.vbauer.avconv4java.type.NamedType; 4 | 5 | import java.io.BufferedReader; 6 | import java.io.InputStream; 7 | import java.io.InputStreamReader; 8 | import java.nio.charset.Charset; 9 | import java.util.Arrays; 10 | import java.util.Collection; 11 | import java.util.Map; 12 | import java.util.Objects; 13 | 14 | /** 15 | * Generic utils. 16 | * 17 | * @author Vladislav Bauer 18 | */ 19 | 20 | public final class AVUtils { 21 | 22 | public static final String SYSTEM_PROPERTY_OS_NAME = "os.name"; 23 | public static final String SYSTEM_PROPERTY_LINE_SEPARATOR = "line.separator"; 24 | 25 | public static final String SPACE = " "; 26 | public static final String EMPTY = ""; 27 | 28 | private static final String OS = getSystemProperty(SYSTEM_PROPERTY_OS_NAME).toLowerCase(); 29 | private static final String LINE_SEPARATOR = getSystemProperty(SYSTEM_PROPERTY_LINE_SEPARATOR); 30 | 31 | 32 | private AVUtils() { 33 | throw new UnsupportedOperationException(); 34 | } 35 | 36 | 37 | public static boolean hasNull(final Object... arguments) { 38 | if (!isEmpty(arguments)) { 39 | return !Arrays.stream(arguments).allMatch(Objects::nonNull); 40 | } 41 | return true; 42 | } 43 | 44 | public static boolean isEmpty(final Object... arguments) { 45 | return arguments == null || arguments.length == 0; 46 | } 47 | 48 | public static boolean isEmpty(final Map map) { 49 | return map == null || map.isEmpty(); 50 | } 51 | 52 | public static boolean isEmpty(final Collection list) { 53 | return list == null || list.isEmpty(); 54 | } 55 | 56 | public static boolean isBlank(final Object text) { 57 | return trimToNull(text) == null; 58 | } 59 | 60 | public static String trimToNull(final Object text) { 61 | if (text != null) { 62 | final String trim = text.toString().trim(); 63 | return trim.length() > 0 ? trim : null; 64 | } 65 | return null; 66 | } 67 | 68 | public static String trimToEmpty(final Object text) { 69 | return text != null ? text.toString().trim() : EMPTY; 70 | } 71 | 72 | public static String join(final String... arguments) { 73 | return join(isEmpty((Object[]) arguments) ? null : Arrays.asList(arguments), SPACE); 74 | } 75 | 76 | public static String join(final Iterable arguments) { 77 | return join(arguments, SPACE); 78 | } 79 | 80 | public static String join(final Iterable arguments, final String delimiter) { 81 | final StringBuilder buffer = new StringBuilder(); 82 | if (arguments != null) { 83 | boolean first = true; 84 | for (final String arg : arguments) { 85 | if (arg != null) { 86 | if (first) { 87 | first = false; 88 | } else { 89 | buffer.append(delimiter); 90 | } 91 | buffer.append(arg); 92 | } 93 | } 94 | } 95 | return trimToNull(buffer); 96 | } 97 | 98 | 99 | public static boolean isWindows() { 100 | return OS.contains("win"); 101 | } 102 | 103 | public static boolean isMac() { 104 | return OS.contains("mac"); 105 | } 106 | 107 | public static boolean isUnix() { 108 | return OS.contains("nix") || OS.contains("nux") || OS.contains("aix"); 109 | } 110 | 111 | public static boolean isSolaris() { 112 | return OS.contains("sunos"); 113 | } 114 | 115 | public static String getSystemProperty(final String key) { 116 | final String envProperty = System.getenv(key); 117 | return envProperty == null ? System.getProperty(key) : envProperty; 118 | } 119 | 120 | public static String readFully(final InputStream inputStream) { 121 | final Charset charset = Charset.defaultCharset(); 122 | 123 | try ( 124 | InputStreamReader streamReader = new InputStreamReader(inputStream, charset); 125 | BufferedReader reader = new BufferedReader(streamReader) 126 | ) { 127 | final StringBuilder result = new StringBuilder(); 128 | String line; 129 | 130 | while ((line = reader.readLine()) != null) { 131 | result.append(line); 132 | result.append(LINE_SEPARATOR); 133 | } 134 | return result.toString(); 135 | } catch (final Throwable ex) { 136 | return null; 137 | } 138 | } 139 | 140 | public static T findByName( 141 | final Class enumClass, final String name 142 | ) { 143 | final T[] values = enumClass.getEnumConstants(); 144 | for (final T value : values) { 145 | final String valueName = value.getName(); 146 | if (valueName.equalsIgnoreCase(name)) { 147 | return value; 148 | } 149 | } 150 | return null; 151 | } 152 | 153 | } 154 | -------------------------------------------------------------------------------- /src/main/java/com/github/vbauer/avconv4java/util/process/ProcessExecutor.java: -------------------------------------------------------------------------------- 1 | package com.github.vbauer.avconv4java.util.process; 2 | 3 | import com.github.vbauer.avconv4java.util.AVUtils; 4 | 5 | import java.util.List; 6 | import java.util.concurrent.*; 7 | import java.util.logging.Level; 8 | import java.util.logging.Logger; 9 | 10 | /** 11 | * Process executor allows to run new OS application in separate process. 12 | * 13 | * @author Vladislav Bauer 14 | */ 15 | 16 | public final class ProcessExecutor { 17 | 18 | private static final Logger LOGGER = Logger.getLogger(ProcessExecutor.class.getSimpleName()); 19 | 20 | 21 | private ProcessExecutor() { 22 | throw new UnsupportedOperationException(); 23 | } 24 | 25 | 26 | public static ProcessInfo execute( 27 | final List arguments, final Long timeout, final boolean debug 28 | ) throws Exception { 29 | final Process process = runProcess(arguments, debug); 30 | final boolean hasTimeout = timeout != null && timeout > 0; 31 | return hasTimeout ? waitWithTimeout(process, timeout) : waitWithoutTimeout(process); 32 | } 33 | 34 | 35 | private static ProcessInfo waitWithoutTimeout(final Process process) throws Exception { 36 | try { 37 | final int statusCode = process.waitFor(); 38 | final String output = AVUtils.readFully(process.getInputStream()); 39 | final String errorOutput = AVUtils.readFully(process.getErrorStream()); 40 | return ProcessInfo.create(statusCode, output, errorOutput); 41 | } finally { 42 | process.destroy(); 43 | } 44 | } 45 | 46 | private static ProcessInfo waitWithTimeout(final Process process, final long timeout) throws Exception { 47 | final ExecutorService executor = Executors.newSingleThreadExecutor(); 48 | try { 49 | final Future future = executor.submit(() -> waitWithoutTimeout(process)); 50 | return future.get(timeout, TimeUnit.MILLISECONDS); 51 | } catch (final TimeoutException ex) { 52 | return ProcessInfo.error(ex.getMessage()); 53 | } finally { 54 | shutdownExecutor(executor); 55 | } 56 | } 57 | 58 | private static void shutdownExecutor(final ExecutorService executor) { 59 | try { 60 | executor.shutdownNow(); 61 | LOGGER.fine("Command was killed by timeout."); 62 | } catch (final Exception ex) { 63 | if (LOGGER.isLoggable(Level.SEVERE)) { 64 | LOGGER.severe("Can't shutdown executor's watchdog service: " + ex.getMessage()); 65 | } 66 | } 67 | } 68 | 69 | private static Process runProcess(final List arguments, final boolean debug) throws Exception { 70 | final ProcessBuilder builder = new ProcessBuilder(arguments); 71 | if (debug) { 72 | LOGGER.info(AVUtils.join(arguments)); 73 | builder.inheritIO(); 74 | } 75 | return builder.start(); 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /src/main/java/com/github/vbauer/avconv4java/util/process/ProcessInfo.java: -------------------------------------------------------------------------------- 1 | package com.github.vbauer.avconv4java.util.process; 2 | 3 | import com.github.vbauer.avconv4java.util.AVUtils; 4 | 5 | /** 6 | * Process info that was returned as result. 7 | * 8 | * @author Vladislav Bauer 9 | */ 10 | 11 | public class ProcessInfo { 12 | 13 | public static final int EXIT_CODE_ERROR = 1; 14 | public static final int EXIT_CODE_SUCCESS = 0; 15 | 16 | 17 | private int statusCode; 18 | private String output; 19 | private String errorOutput; 20 | 21 | 22 | public static ProcessInfo error(final String errorOutput) { 23 | return create(EXIT_CODE_ERROR, null, errorOutput); 24 | } 25 | 26 | public static ProcessInfo create(final int statusCode, final String output, final String errorOutput) { 27 | return new ProcessInfo() 28 | .setStatusCode(statusCode) 29 | .setOutput(output) 30 | .setErrorOutput(errorOutput); 31 | } 32 | 33 | 34 | public int getStatusCode() { 35 | return statusCode; 36 | } 37 | 38 | public ProcessInfo setStatusCode(final int statusCode) { 39 | this.statusCode = statusCode; 40 | return this; 41 | } 42 | 43 | public String getOutput() { 44 | return output; 45 | } 46 | 47 | public ProcessInfo setOutput(final String output) { 48 | this.output = output; 49 | return this; 50 | } 51 | 52 | public String getErrorOutput() { 53 | return errorOutput; 54 | } 55 | 56 | public ProcessInfo setErrorOutput(final String errorOutput) { 57 | this.errorOutput = errorOutput; 58 | return this; 59 | } 60 | 61 | public boolean isSuccess() { 62 | return getStatusCode() == EXIT_CODE_SUCCESS && AVUtils.isBlank(getErrorOutput()); 63 | } 64 | 65 | public boolean isError() { 66 | return !isSuccess(); 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /src/test/kotlin/com/github/vbauer/avconv4java/common/TestUtils.kt: -------------------------------------------------------------------------------- 1 | package com.github.vbauer.avconv4java.common 2 | 3 | import com.pushtorefresh.private_constructor_checker.PrivateConstructorChecker 4 | 5 | /** 6 | * @author Vladislav Bauer 7 | */ 8 | 9 | class TestUtils private constructor() { 10 | 11 | companion object { 12 | fun checkUtilClassConstructor(utilsClass: Class<*>) { 13 | PrivateConstructorChecker.forClass(utilsClass) 14 | .expectedTypeOfException(UnsupportedOperationException::class.java) 15 | .check() 16 | } 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/test/kotlin/com/github/vbauer/avconv4java/core/AVCommandTest.kt: -------------------------------------------------------------------------------- 1 | package com.github.vbauer.avconv4java.core 2 | 3 | import org.hamcrest.MatcherAssert.assertThat 4 | import org.hamcrest.Matchers.* 5 | import org.testng.Assert.fail 6 | import org.testng.annotations.Test 7 | 8 | /** 9 | * @author Vladislav Bauer 10 | */ 11 | 12 | class AVCommandTest { 13 | 14 | @Test 15 | fun testGlobalMethods() { 16 | assertThat(AVCommand.getDefaultToolPath(), notNullValue()) 17 | assertThat(AVCommand.setGlobalToolPath(null), nullValue()) 18 | assertThat(AVCommand.getGlobalToolPath(), nullValue()) 19 | } 20 | 21 | @Test 22 | fun testGettersAndSetters() { 23 | val command = createCommand() 24 | 25 | assertThat(command.isDebug, equalTo(false)) 26 | assertThat(command.timeout, equalTo(1L)) 27 | assertThat(command.toolPath, nullValue()) 28 | } 29 | 30 | @Test 31 | fun testCalculateToolPath() { 32 | val command = createCommand() 33 | 34 | AVCommand.setGlobalToolPath(null) 35 | assertThat(command.calculateToolPath(), nullValue()) 36 | } 37 | 38 | @Test(expectedExceptions = [NullPointerException::class]) 39 | fun test() { 40 | AVCommand.setGlobalToolPath(null) 41 | 42 | val command = createCommand() 43 | fail(command.run(AVOptions.create()).toString()) 44 | } 45 | 46 | 47 | /* 48 | * Internal API. 49 | */ 50 | 51 | private fun createCommand(): AVCommand { 52 | return AVCommand() 53 | .setDebug(false) 54 | .setTimeout(1L) 55 | .setToolPath(null) 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /src/test/kotlin/com/github/vbauer/avconv4java/core/AVOptionsTest.kt: -------------------------------------------------------------------------------- 1 | package com.github.vbauer.avconv4java.core 2 | 3 | import com.github.vbauer.avconv4java.option.* 4 | import com.github.vbauer.avconv4java.type.AVAudioCodecType 5 | import com.github.vbauer.avconv4java.type.AVLogLevelType 6 | import com.github.vbauer.avconv4java.type.AVMovFlagsType 7 | import com.github.vbauer.avconv4java.type.AVVideoCodecType 8 | import com.github.vbauer.avconv4java.util.AVUtils 9 | import org.hamcrest.MatcherAssert.assertThat 10 | import org.hamcrest.Matchers.equalTo 11 | import org.hamcrest.Matchers.notNullValue 12 | import org.testng.Assert.fail 13 | import org.testng.annotations.Test 14 | 15 | /** 16 | * @author Vladislav Bauer 17 | */ 18 | 19 | class AVOptionsTest { 20 | 21 | @Test 22 | fun testCreate() { 23 | assertThat(AVOptions.create(), notNullValue()) 24 | } 25 | 26 | @Test(expectedExceptions = [IllegalArgumentException::class]) 27 | fun testBuilders() { 28 | fail(AVOptions.create().builders(AVRootOptions.create("", "")).build().toString()) 29 | } 30 | 31 | @Test 32 | fun testCombineOptions() { 33 | val options = createOptions() 34 | assertThat(options.toString(), equalTo(java.lang.String.format(OPTION_FLAGS, AVUtils.SPACE))) 35 | 36 | val genericOptions = createGenericOptions() 37 | assertThat(genericOptions.toString(), equalTo(GENERIC_FLAGS)) 38 | 39 | val mainOptions = createMainOptions() 40 | assertThat(mainOptions.toString(), equalTo(MAIN_FLAGS)) 41 | 42 | val videoOptions = createVideoOptions() 43 | assertThat(videoOptions.toString(), equalTo(VIDEO_FLAGS)) 44 | 45 | val audioOptions = createAudioOptions() 46 | assertThat(audioOptions.toString(), equalTo(AUDIO_FLAGS)) 47 | 48 | val codecOptions = createCodecOptions() 49 | assertThat(codecOptions.toString(), equalTo(CODEC_FLAGS)) 50 | 51 | val combinedOptions = options.builders( 52 | genericOptions, mainOptions, videoOptions, audioOptions, codecOptions 53 | ) 54 | assertThat(combinedOptions.toString(), equalTo(COMBINED_FLAGS)) 55 | } 56 | 57 | 58 | /* 59 | * Internal API. 60 | */ 61 | 62 | private fun createOptions(): AVRootOptions { 63 | return AVRootOptions.create(INPUT_FILE, OUTPUT_FILE) 64 | } 65 | 66 | private fun createGenericOptions(): AVGenericOptions { 67 | return AVGenericOptions.create() 68 | .logLevel(AVLogLevelType.INFO) 69 | } 70 | 71 | private fun createCodecOptions(): AVCodecOptions { 72 | return AVCodecOptions.create() 73 | .bitRate(1000) 74 | } 75 | 76 | private fun createAudioOptions(): AVAudioOptions { 77 | return AVAudioOptions.create() 78 | .audioCodec(AVAudioCodecType.VISUAL_ON_AAC) 79 | .audioBitRate(128) 80 | .audioChannelsCount(2) 81 | .sampleRate(11025) 82 | } 83 | 84 | private fun createVideoOptions(): AVVideoOptions { 85 | return AVVideoOptions.create() 86 | .proportionalResizeUsingWidth(800) 87 | .videoCodec(AVVideoCodecType.H264) 88 | .movFlags(AVMovFlagsType.FAST_START) 89 | } 90 | 91 | private fun createMainOptions(): AVMainOptions { 92 | return AVMainOptions.create() 93 | .overwriteOutput() 94 | } 95 | 96 | companion object { 97 | private const val INPUT_FILE = "input.avi" 98 | private const val OUTPUT_FILE = "output.mp4" 99 | 100 | private const val OPTION_FLAGS = "-i $INPUT_FILE%s$OUTPUT_FILE" 101 | private const val GENERIC_FLAGS = "-loglevel info" 102 | private const val MAIN_FLAGS = "-y" 103 | private const val VIDEO_FLAGS = "-vf scale=w=800:h=trunc(ow/a/2)*2 -vcodec libx264 -movflags faststart" 104 | private const val AUDIO_FLAGS = "-acodec libvo_aacenc -ab 128k -ac 2 -ar 11025" 105 | private const val CODEC_FLAGS = "-b 1000k" 106 | 107 | private val COMBINED_FLAGS = java.lang.String.format(OPTION_FLAGS, 108 | AVUtils.SPACE + AVUtils.join(GENERIC_FLAGS, MAIN_FLAGS, VIDEO_FLAGS, AUDIO_FLAGS, CODEC_FLAGS) + AVUtils.SPACE 109 | ) 110 | } 111 | 112 | } 113 | -------------------------------------------------------------------------------- /src/test/kotlin/com/github/vbauer/avconv4java/core/AVRootOptionsTest.kt: -------------------------------------------------------------------------------- 1 | package com.github.vbauer.avconv4java.core 2 | 3 | import org.hamcrest.MatcherAssert.assertThat 4 | import org.hamcrest.Matchers.* 5 | import org.testng.annotations.Test 6 | import org.testng.collections.Lists 7 | 8 | /** 9 | * @author Vladislav Bauer 10 | */ 11 | 12 | class AVRootOptionsTest { 13 | 14 | @Test 15 | fun testSmokeAVRootOptions() { 16 | val rootOptions = AVRootOptions.create(INPUT_FILE, OUTPUT_FILE) 17 | .builders(Lists.newArrayList()) 18 | .builders() 19 | .flags(Lists.newArrayList()) 20 | .flags() 21 | 22 | assertThat(rootOptions.outputFile, equalTo(OUTPUT_FILE)) 23 | 24 | val options = rootOptions.build() 25 | assertThat(options, not(emptyIterable())) 26 | } 27 | 28 | companion object { 29 | private const val INPUT_FILE = "inputFile" 30 | private const val OUTPUT_FILE = "outputFile" 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/test/kotlin/com/github/vbauer/avconv4java/option/AVAudioOptionsTest.kt: -------------------------------------------------------------------------------- 1 | package com.github.vbauer.avconv4java.option 2 | 3 | import com.github.vbauer.avconv4java.type.AVAudioCodecType 4 | import com.github.vbauer.avconv4java.type.AVStreamType 5 | import org.hamcrest.MatcherAssert.assertThat 6 | import org.hamcrest.Matchers.emptyIterable 7 | import org.hamcrest.Matchers.not 8 | import org.testng.annotations.Test 9 | import org.testng.collections.Lists 10 | 11 | /** 12 | * @author Vladislav Bauer 13 | */ 14 | 15 | class AVAudioOptionsTest { 16 | 17 | @Test 18 | fun testSmokeAVAudioOptions() { 19 | val options = AVAudioOptions.create() 20 | .audioBitRate(1) 21 | .audioChannelsCount(AVStreamType.AUDIO, 1) 22 | .audioChannelsCount(1) 23 | .audioCodec(AVAudioCodecType.AAC) 24 | .audioCodec(AVAudioCodecType.AAC.getName()) 25 | .audioQuality(1.0) 26 | .disableRecording() 27 | .filter("filter") 28 | .flags("flag") 29 | .framesCount(1L) 30 | .sampleFormat(AVStreamType.AUDIO, "format") 31 | .sampleFormat("format") 32 | .sampleRate(AVStreamType.AUDIO, 1) 33 | .sampleRate(1) 34 | .builders(Lists.newArrayList()) 35 | .builders() 36 | .flags(Lists.newArrayList()) 37 | .flags() 38 | .build() 39 | 40 | assertThat(options, not(emptyIterable())) 41 | } 42 | 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/test/kotlin/com/github/vbauer/avconv4java/option/AVCodecOptionsTest.kt: -------------------------------------------------------------------------------- 1 | package com.github.vbauer.avconv4java.option 2 | 3 | import com.github.vbauer.avconv4java.type.* 4 | import org.hamcrest.MatcherAssert.assertThat 5 | import org.hamcrest.Matchers.emptyIterable 6 | import org.hamcrest.Matchers.not 7 | import org.testng.annotations.Test 8 | import org.testng.collections.Lists 9 | 10 | /** 11 | * @author Vladislav Bauer 12 | */ 13 | 14 | class AVCodecOptionsTest { 15 | 16 | @Test 17 | fun testSmokeAVCodecOptions() { 18 | val options = AVCodecOptions.create() 19 | .bitRate(AVStreamType.AUDIO, 1) 20 | .bitRate(1) 21 | .codecFlags(AVStreamType.AUDIO, AVCodecFlagType.AIC) 22 | .codecFlags(AVCodecFlagType.AIC) 23 | .codecFlags(AVStreamType.AUDIO, AVCodecFlagType.AIC.getName()) 24 | .codecFlags(AVCodecFlagType.AIC.getName()) 25 | .cutOffBandwidth(AVStreamType.AUDIO, 1) 26 | .cutOffBandwidth(1) 27 | .debug(AVDebugInfoType.MB_TYPE) 28 | .debug(AVDebugInfoType.MB_TYPE.getName()) 29 | .frameSize(AVStreamType.AUDIO, 1) 30 | .frameSize(1) 31 | .groupOfPictures(AVStreamType.AUDIO, 1) 32 | .groupOfPictures(1) 33 | .motionEstimationMethod(AVMotionEstimationType.DIA) 34 | .motionEstimationMethod(AVMotionEstimationType.DIA.getName()) 35 | .motionEstimationMethod(AVStreamType.AUDIO, AVMotionEstimationType.DIA) 36 | .motionEstimationMethod(AVStreamType.AUDIO, AVMotionEstimationType.DIA.getName()) 37 | .preset(AVStreamType.AUDIO, "fileName") 38 | .strict(AVStrictType.STRICT) 39 | .strict(AVStrictType.STRICT.getName()) 40 | .videoBitRateTolerance(AVStreamType.AUDIO, 1) 41 | .videoBitRateTolerance(1) 42 | .builders(Lists.newArrayList()) 43 | .builders() 44 | .flags(Lists.newArrayList()) 45 | .flags() 46 | .build() 47 | 48 | assertThat(options, not(emptyIterable())) 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/test/kotlin/com/github/vbauer/avconv4java/option/AVFormatOptionsTest.kt: -------------------------------------------------------------------------------- 1 | package com.github.vbauer.avconv4java.option 2 | 3 | import com.github.vbauer.avconv4java.type.AVErrorDetectionType 4 | import com.github.vbauer.avconv4java.type.AVFormatDebugInfoType 5 | import com.github.vbauer.avconv4java.type.AVFormatFlagType 6 | import org.hamcrest.MatcherAssert.assertThat 7 | import org.hamcrest.Matchers.emptyIterable 8 | import org.hamcrest.Matchers.not 9 | import org.testng.annotations.Test 10 | import org.testng.collections.Lists 11 | 12 | /** 13 | * @author Vladislav Bauer 14 | */ 15 | 16 | class AVFormatOptionsTest { 17 | 18 | @Test 19 | fun testSmokeAVFormatOptions() { 20 | val options = AVFormatOptions.create() 21 | .analyzeDuration(1L) 22 | .debugInfo(AVFormatDebugInfoType.TS) 23 | .debugInfo(AVFormatDebugInfoType.TS.getName()) 24 | .decryptionKey("key") 25 | .errorDetection(AVErrorDetectionType.BIT_STREAM) 26 | .errorDetection(AVErrorDetectionType.BIT_STREAM.getName()) 27 | .formatFlags(AVFormatFlagType.DISCARD_CORRUPTED) 28 | .formatFlags(AVFormatFlagType.DISCARD_CORRUPTED.getName()) 29 | .fpsProbeSize(1L) 30 | .interleavingBufferSize(1L) 31 | .maxDelay(1L) 32 | .packetSize(1L) 33 | .probeSize(1L) 34 | .realTimeBufferSize(1L) 35 | .timestampIndexSize(1L) 36 | .builders(Lists.newArrayList()) 37 | .builders() 38 | .flags(Lists.newArrayList()) 39 | .flags() 40 | .build() 41 | 42 | assertThat(options, not(emptyIterable())) 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/test/kotlin/com/github/vbauer/avconv4java/option/AVGenericOptionsTest.kt: -------------------------------------------------------------------------------- 1 | package com.github.vbauer.avconv4java.option 2 | 3 | import com.github.vbauer.avconv4java.type.AVLogLevelType 4 | import org.hamcrest.MatcherAssert.assertThat 5 | import org.hamcrest.Matchers.emptyIterable 6 | import org.hamcrest.Matchers.not 7 | import org.testng.annotations.Test 8 | import org.testng.collections.Lists 9 | 10 | /** 11 | * @author Vladislav Bauer 12 | */ 13 | 14 | class AVGenericOptionsTest { 15 | 16 | @Test 17 | fun testSmokeAVGenericOptions() { 18 | val options = AVGenericOptions.create() 19 | .cpuFlags("mask") 20 | .logLevel(1) 21 | .logLevel(AVLogLevelType.DEBUG) 22 | .logLevel(AVLogLevelType.DEBUG.getName()) 23 | .showLicense() 24 | .builders(Lists.newArrayList()) 25 | .builders() 26 | .flags(Lists.newArrayList()) 27 | .flags() 28 | .build() 29 | 30 | assertThat(options, not(emptyIterable())) 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/test/kotlin/com/github/vbauer/avconv4java/option/AVMainOptionsTest.kt: -------------------------------------------------------------------------------- 1 | package com.github.vbauer.avconv4java.option 2 | 3 | import com.github.vbauer.avconv4java.type.AVFileFormatType 4 | import com.github.vbauer.avconv4java.type.AVStreamType 5 | import com.github.vbauer.avconv4java.type.AVTargetFileType 6 | import org.hamcrest.MatcherAssert.assertThat 7 | import org.hamcrest.Matchers.emptyIterable 8 | import org.hamcrest.Matchers.not 9 | import org.testng.annotations.Test 10 | import org.testng.collections.Lists 11 | 12 | /** 13 | * @author Vladislav Bauer 14 | */ 15 | 16 | class AVMainOptionsTest { 17 | 18 | @Test 19 | fun testSmokeAVMainOptions() { 20 | val options = AVMainOptions.create() 21 | .attachment("fileName") 22 | .dataFrames(1L) 23 | .dumpAttachment(AVStreamType.AUDIO, "fileName") 24 | .dumpAttachment("fileName") 25 | .duration(1L) 26 | .duration("duration") 27 | .fileFormat(AVFileFormatType.CRC) 28 | .fileFormat(AVFileFormatType.CRC.getName()) 29 | .fileSizeLimit(1L) 30 | .filter(AVStreamType.AUDIO, "filter") 31 | .filter("filter") 32 | .filterScript(AVStreamType.AUDIO, "fileName") 33 | .filterScript("fileName") 34 | .framesCount(AVStreamType.AUDIO, 1L) 35 | .framesCount(1L) 36 | .immediatelyExit() 37 | .inputTimeOffset(1.0) 38 | .inputTimeOffset("position") 39 | .metadata("key", "value") 40 | .overwriteOutput() 41 | .preset(AVStreamType.AUDIO, "preset") 42 | .preset("preset") 43 | .qualityScale(AVStreamType.AUDIO, 1.0) 44 | .qualityScale(1.0) 45 | .seek(1.0) 46 | .seek("position") 47 | .target(AVTargetFileType.DV) 48 | .target(AVTargetFileType.DV.getName()) 49 | .builders(Lists.newArrayList()) 50 | .builders() 51 | .flags(Lists.newArrayList()) 52 | .flags() 53 | .build() 54 | 55 | assertThat(options, not(emptyIterable())) 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /src/test/kotlin/com/github/vbauer/avconv4java/option/AVSubtitleOptionsTest.kt: -------------------------------------------------------------------------------- 1 | package com.github.vbauer.avconv4java.option 2 | 3 | import org.hamcrest.MatcherAssert.assertThat 4 | import org.hamcrest.Matchers.emptyIterable 5 | import org.hamcrest.Matchers.not 6 | import org.testng.annotations.Test 7 | import org.testng.collections.Lists 8 | 9 | /** 10 | * @author Vladislav Bauer 11 | */ 12 | 13 | class AVSubtitleOptionsTest { 14 | 15 | @Test 16 | fun testSmokeAVSubtitleOptions() { 17 | val options = AVSubtitleOptions.create() 18 | .disableRecording() 19 | .subtitleCodec("codecName") 20 | .builders(Lists.newArrayList()) 21 | .builders() 22 | .flags(Lists.newArrayList()) 23 | .flags() 24 | .build() 25 | 26 | assertThat(options, not(emptyIterable())) 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/test/kotlin/com/github/vbauer/avconv4java/option/AVVideoOptionsTest.kt: -------------------------------------------------------------------------------- 1 | package com.github.vbauer.avconv4java.option 2 | 3 | import com.github.vbauer.avconv4java.type.AVMovFlagsType 4 | import com.github.vbauer.avconv4java.type.AVStreamType 5 | import com.github.vbauer.avconv4java.type.AVVideoCodecType 6 | import com.github.vbauer.avconv4java.type.AVVideoSizeType 7 | import org.hamcrest.MatcherAssert.assertThat 8 | import org.hamcrest.Matchers.emptyIterable 9 | import org.hamcrest.Matchers.not 10 | import org.testng.annotations.Test 11 | import org.testng.collections.Lists 12 | 13 | /** 14 | * @author Vladislav Bauer 15 | */ 16 | 17 | class AVVideoOptionsTest { 18 | 19 | @Test 20 | fun testSmokeAVVideoOptions() { 21 | val options = AVVideoOptions.create() 22 | .aspectRatio(AVStreamType.VIDEO, "ration") 23 | .aspectRatio(AVStreamType.VIDEO, 1, 1) 24 | .aspectRatio(AVStreamType.VIDEO, 1.0) 25 | .aspectRatio("ratio") 26 | .aspectRatio(1, 1) 27 | .aspectRatio(1.0) 28 | .disableRecording() 29 | .filter("filter") 30 | .frameRate(AVStreamType.AUDIO, 1) 31 | .frameRate(1) 32 | .movFlags(AVMovFlagsType.EMPTY_MOOV) 33 | .movFlags(AVMovFlagsType.EMPTY_MOOV.getName()) 34 | .framesCount(1L) 35 | .onePassEncoding() 36 | .onePassEncoding(AVStreamType.AUDIO) 37 | .passCount(AVStreamType.AUDIO, 1) 38 | .passCount(1) 39 | .passLogFilePrefix(AVStreamType.AUDIO, "prefix") 40 | .passLogFilePrefix("prefix") 41 | .proportionalResizeUsingHeight(1) 42 | .proportionalResizeUsingWidth(1) 43 | .resize(AVStreamType.VIDEO, 1, 1) 44 | .resize(AVStreamType.VIDEO, AVVideoSizeType.CGA) 45 | .resize(AVStreamType.VIDEO, AVVideoSizeType.CGA.getName()) 46 | .twoPassEncoding() 47 | .twoPassEncoding(AVStreamType.AUDIO) 48 | .videoCodec(AVVideoCodecType.H264) 49 | .videoCodec(AVVideoCodecType.H264.getName()) 50 | .builders(Lists.newArrayList()) 51 | .builders() 52 | .flags(Lists.newArrayList()) 53 | .flags() 54 | .build() 55 | 56 | assertThat(options, not(emptyIterable())) 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /src/test/kotlin/com/github/vbauer/avconv4java/option/advanced/AVAdvancedOptionsTest.kt: -------------------------------------------------------------------------------- 1 | package com.github.vbauer.avconv4java.option.advanced 2 | 3 | import com.github.vbauer.avconv4java.type.AVVideoSyncType 4 | import org.hamcrest.MatcherAssert.assertThat 5 | import org.hamcrest.Matchers.emptyIterable 6 | import org.hamcrest.Matchers.not 7 | import org.testng.annotations.Test 8 | import org.testng.collections.Lists 9 | 10 | /** 11 | * @author Vladislav Bauer 12 | */ 13 | 14 | class AVAdvancedOptionsTest { 15 | 16 | @Test 17 | fun testSmokeAVAdvancedOptions() { 18 | val options = AVAdvancedOptions.create() 19 | .accurateSeek(true) 20 | .benchmark() 21 | .copyTimeBase() 22 | .copyTimestamps() 23 | .demuxPreLoadDelay(1L) 24 | .discontinuityDeltaThreshold() 25 | .dump() 26 | .filterComplexScript("fileName") 27 | .hex() 28 | .maxDemuxDelay(1L) 29 | .shortest() 30 | .timeLimit(1L) 31 | .videoSyncMethod(AVVideoSyncType.AUTO) 32 | .videoSyncMethod(AVVideoSyncType.AUTO.getName()) 33 | .builders(Lists.newArrayList()) 34 | .builders() 35 | .flags(Lists.newArrayList()) 36 | .flags() 37 | .build() 38 | 39 | assertThat(options, not(emptyIterable())) 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/test/kotlin/com/github/vbauer/avconv4java/option/advanced/AVAdvancedVideoOptionsTest.kt: -------------------------------------------------------------------------------- 1 | package com.github.vbauer.avconv4java.option.advanced 2 | 3 | import com.github.vbauer.avconv4java.type.AVHardwareAccelerationType 4 | import com.github.vbauer.avconv4java.type.AVStreamType 5 | import org.hamcrest.MatcherAssert.assertThat 6 | import org.hamcrest.Matchers.emptyIterable 7 | import org.hamcrest.Matchers.not 8 | import org.testng.annotations.Test 9 | import org.testng.collections.Lists 10 | 11 | /** 12 | * @author Vladislav Bauer 13 | */ 14 | 15 | class AVAdvancedVideoOptionsTest { 16 | 17 | @Test 18 | fun testSmokeAVAdvancedVideoOptions() { 19 | val options = AVAdvancedVideoOptions.create() 20 | .discardThreshold(1) 21 | .dumpVideoEncodingStatistics() 22 | .dumpVideoEncodingStatistics("fileName") 23 | .hardwareAcceleration(AVStreamType.AUDIO, AVHardwareAccelerationType.AUTO) 24 | .hardwareAcceleration(AVStreamType.AUDIO, AVHardwareAccelerationType.AUTO.getName()) 25 | .pixelFormat(AVStreamType.AUDIO, "format") 26 | .pixelFormat("format") 27 | .swScalerFlags("flags") 28 | .builders(Lists.newArrayList()) 29 | .builders() 30 | .flags(Lists.newArrayList()) 31 | .flags() 32 | .build() 33 | 34 | assertThat(options, not(emptyIterable())) 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/test/kotlin/com/github/vbauer/avconv4java/type/ModelTest.kt: -------------------------------------------------------------------------------- 1 | package com.github.vbauer.avconv4java.type 2 | 3 | import com.github.vbauer.avconv4java.util.AVUtils 4 | import org.hamcrest.MatcherAssert.assertThat 5 | import org.hamcrest.Matchers.* 6 | import org.testng.annotations.Test 7 | import java.lang.reflect.Method 8 | import java.util.* 9 | 10 | /** 11 | * @author Vladislav Bauer 12 | */ 13 | 14 | class ModelTest { 15 | 16 | @Test 17 | fun testModelTypes() { 18 | makeBasicCheck(AVAudioCodecType.Constants.AAC, AVAudioCodecType.AAC) 19 | makeBasicCheck(AVCodecFlagType.Constants.AIC, AVCodecFlagType.AIC) 20 | makeBasicCheck(AVDebugInfoType.Constants.ER, AVDebugInfoType.ER) 21 | makeBasicCheck(AVErrorDetectionType.Constants.BUFFER, AVErrorDetectionType.BUFFER) 22 | makeBasicCheck(AVFileFormatType.Constants.CRC, AVFileFormatType.CRC) 23 | makeBasicCheck(AVFormatDebugInfoType.Constants.TS, AVFormatDebugInfoType.TS) 24 | makeBasicCheck(AVFormatFlagType.Constants.NO_BUFFER, AVFormatFlagType.NO_BUFFER) 25 | makeBasicCheck(AVHardwareAccelerationType.Constants.VDPAU, AVHardwareAccelerationType.VDPAU) 26 | makeBasicCheck(AVLogLevelType.Constants.INFO, AVLogLevelType.INFO) 27 | makeBasicCheck(AVMotionEstimationType.Constants.LOG, AVMotionEstimationType.LOG) 28 | makeBasicCheck(AVMovFlagsType.Constants.FAST_START, AVMovFlagsType.FAST_START) 29 | makeBasicCheck(AVStreamType.Constants.AUDIO, AVStreamType.AUDIO) 30 | makeBasicCheck(AVStrictType.Constants.VERY, AVStrictType.VERY) 31 | makeBasicCheck(AVTargetFileType.Constants.DV, AVTargetFileType.DV) 32 | makeBasicCheck(AVVideoCodecType.Constants.H264, AVVideoCodecType.H264) 33 | makeBasicCheck(AVVideoSyncType.Constants.CFR, AVVideoSyncType.CRF) 34 | makeBasicCheck(AVVideoSizeType.Constants.VGA, AVVideoSizeType.VGA) 35 | 36 | for (type in AVVideoSizeType.values()) { 37 | assertThat(type.width, greaterThan(0)) 38 | assertThat(type.height, greaterThan(0)) 39 | } 40 | } 41 | 42 | @Suppress("UNCHECKED_CAST") 43 | private fun makeBasicCheck(choiceName: String, choice: Any) { 44 | val findByName = findMethod(choice, METHOD_FIND_BY_NAME, String::class.java) 45 | assertThat(findByName.invoke(null, choiceName), equalTo(choice)) 46 | assertThat(findByName.invoke(null, FAKE_VALUE), nullValue()) 47 | assertThat(findByName.invoke(null, AVUtils.EMPTY), nullValue()) 48 | assertThat(findByName.invoke(null, null as String?), nullValue()) 49 | 50 | val valuesMethod = findMethod(choice, METHOD_VALUES) 51 | val values = valuesMethod.invoke(null)!! as Array 52 | 53 | for (value in values) { 54 | val method = findMethod(value, METHOD_GET_NAME) 55 | val name = method.invoke(value) as String 56 | assertThat(AVUtils.isBlank(name), equalTo(false)) 57 | } 58 | } 59 | 60 | private fun findMethod(obj: Any, name: String, vararg paramTypes: Class<*>): Method { 61 | val entryClass = obj.javaClass 62 | return entryClass.getDeclaredMethod(name, *paramTypes) 63 | } 64 | 65 | companion object { 66 | private val FAKE_VALUE = "FAKE_" + UUID.randomUUID().toString() 67 | 68 | private const val METHOD_FIND_BY_NAME = "findByName" 69 | private const val METHOD_VALUES = "values" 70 | private const val METHOD_GET_NAME = "getName" 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /src/test/kotlin/com/github/vbauer/avconv4java/type/TypeTest.kt: -------------------------------------------------------------------------------- 1 | package com.github.vbauer.avconv4java.type 2 | 3 | import com.github.vbauer.avconv4java.common.TestUtils 4 | import org.testng.Assert 5 | import org.testng.annotations.DataProvider 6 | import org.testng.annotations.Factory 7 | import org.testng.annotations.Test 8 | 9 | /** 10 | * @author Vladislav Bauer 11 | */ 12 | 13 | class TypeTest { 14 | 15 | @DataProvider 16 | fun data(): Array>> { 17 | return arrayOf( 18 | arrayOf(AVCodecFlagType.Constants::class.java), 19 | arrayOf(AVDebugInfoType.Constants::class.java), 20 | arrayOf(AVErrorDetectionType.Constants::class.java), 21 | arrayOf(AVAudioCodecType.Constants::class.java), 22 | arrayOf(AVFileFormatType.Constants::class.java), 23 | arrayOf(AVFormatDebugInfoType.Constants::class.java), 24 | arrayOf(AVFormatFlagType.Constants::class.java), 25 | arrayOf(AVHardwareAccelerationType.Constants::class.java), 26 | arrayOf(AVLogLevelType.Constants::class.java), 27 | arrayOf(AVMotionEstimationType.Constants::class.java), 28 | arrayOf(AVMovFlagsType.Constants::class.java), 29 | arrayOf(AVStreamType.Constants::class.java), 30 | arrayOf(AVStrictType.Constants::class.java), 31 | arrayOf(AVTargetFileType.Constants::class.java), 32 | arrayOf(AVVideoCodecType.Constants::class.java), 33 | arrayOf(AVVideoSizeType.Constants::class.java), 34 | arrayOf(AVVideoSyncType.Constants::class.java) 35 | ) 36 | } 37 | 38 | @Factory(dataProvider = "data") 39 | fun createTest(utilClass: Class<*>): Array { 40 | return arrayOf(TypeConstructorTest(utilClass)) 41 | } 42 | 43 | 44 | /** 45 | * @author Vladislav Bauer 46 | */ 47 | class TypeConstructorTest internal constructor(private val utilClass: Class<*>) : Assert() { 48 | 49 | @Test 50 | fun testConstructorContract() { 51 | TestUtils.checkUtilClassConstructor(utilClass) 52 | } 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /src/test/kotlin/com/github/vbauer/avconv4java/util/AVUtilsTest.kt: -------------------------------------------------------------------------------- 1 | package com.github.vbauer.avconv4java.util 2 | 3 | import com.github.vbauer.avconv4java.common.TestUtils 4 | import org.hamcrest.MatcherAssert.assertThat 5 | import org.hamcrest.Matchers.* 6 | import org.testng.annotations.Test 7 | import java.util.* 8 | 9 | /** 10 | * @author Vladislav Bauer 11 | */ 12 | 13 | class AVUtilsTest { 14 | 15 | @Test 16 | fun testConstructorContract() { 17 | TestUtils.checkUtilClassConstructor(AVUtils::class.java) 18 | } 19 | 20 | @Test 21 | fun testIsEmptyCollection() { 22 | assertThat(AVUtils.isEmpty(null as List<*>?), equalTo(true)) 23 | assertThat(AVUtils.isEmpty(Collections.singleton(HELLO)), equalTo(false)) 24 | } 25 | 26 | @Test 27 | fun testIsEmptyMap() { 28 | assertThat(AVUtils.isEmpty(null as Map<*, *>?), equalTo(true)) 29 | assertThat(AVUtils.isEmpty(Collections.singletonMap(HELLO, WORLD)), equalTo(false)) 30 | } 31 | 32 | @Test 33 | fun testIsEmptyArray() { 34 | assertThat(AVUtils.isEmpty(), equalTo(true)) 35 | assertThat(AVUtils.isEmpty(arrayOf(HELLO), WORLD), equalTo(false)) 36 | } 37 | 38 | @Test 39 | fun testTrimToNull() { 40 | assertThat(AVUtils.trimToNull(null), nullValue()) 41 | assertThat(AVUtils.trimToNull(AVUtils.EMPTY), nullValue()) 42 | assertThat(AVUtils.trimToNull(AVUtils.SPACE), nullValue()) 43 | } 44 | 45 | @Test 46 | fun testTrimToEmpty() { 47 | assertThat(AVUtils.trimToEmpty(null), equalTo(AVUtils.EMPTY)) 48 | assertThat(AVUtils.trimToEmpty(AVUtils.EMPTY), equalTo(AVUtils.EMPTY)) 49 | assertThat(AVUtils.trimToEmpty(AVUtils.SPACE), equalTo(AVUtils.EMPTY)) 50 | } 51 | 52 | @Test 53 | fun testIsBlank() { 54 | assertThat(AVUtils.isBlank(null), equalTo(true)) 55 | assertThat(AVUtils.isBlank(AVUtils.EMPTY), equalTo(true)) 56 | assertThat(AVUtils.isBlank(AVUtils.SPACE), equalTo(true)) 57 | assertThat(AVUtils.isBlank(" a "), equalTo(false)) 58 | assertThat(AVUtils.isBlank("a"), equalTo(false)) 59 | } 60 | 61 | @Test 62 | fun testHasNull() { 63 | assertThat(AVUtils.hasNull(1, null), equalTo(true)) 64 | assertThat(AVUtils.hasNull(null as Any?), equalTo(true)) 65 | assertThat(AVUtils.hasNull(null, null), equalTo(true)) 66 | assertThat(AVUtils.hasNull(HELLO, null), equalTo(true)) 67 | assertThat(AVUtils.hasNull(HELLO, WORLD), equalTo(false)) 68 | } 69 | 70 | @Test 71 | fun testJoinCollection() { 72 | val data = Arrays.asList(HELLO, WORLD) 73 | 74 | assertThat(AVUtils.SPACE, equalTo(SPACE)) 75 | 76 | assertThat(AVUtils.join(data), equalTo(AVUtils.join(data, AVUtils.SPACE))) 77 | assertThat(AVUtils.join(data), equalTo(HELLO_WORLD)) 78 | assertThat(AVUtils.join(data), equalTo(HELLO_WORLD)) 79 | 80 | assertThat(AVUtils.join(Arrays.asList(null, null)), nullValue()) 81 | assertThat(AVUtils.join(null as Iterable?), nullValue()) 82 | } 83 | 84 | @Test 85 | fun testJoinArray() { 86 | assertThat(AVUtils.join(null as String?), nullValue()) 87 | assertThat(AVUtils.join(null as Collection?), nullValue()) 88 | assertThat(AVUtils.join(HELLO, WORLD), equalTo(HELLO_WORLD)) 89 | } 90 | 91 | @Test 92 | fun testOs() { 93 | assertThat( 94 | AVUtils.isUnix() 95 | || AVUtils.isWindows() 96 | || AVUtils.isMac() 97 | || AVUtils.isSolaris(), 98 | equalTo(true) 99 | ) 100 | } 101 | 102 | @Test 103 | fun testGetSystemProperty() { 104 | assertThat(AVUtils.getSystemProperty(AVUtils.SYSTEM_PROPERTY_OS_NAME), notNullValue()) 105 | assertThat(AVUtils.getSystemProperty(AVUtils.SYSTEM_PROPERTY_LINE_SEPARATOR), notNullValue()) 106 | } 107 | 108 | @Test 109 | fun testReadFully() { 110 | val inputStream = ClassLoader.getSystemResourceAsStream(TODO_FILE) 111 | assertThat(inputStream, notNullValue()) 112 | 113 | val data = AVUtils.trimToEmpty(AVUtils.readFully(inputStream)) 114 | assertThat(data.startsWith(TODO_MARKER), equalTo(true)) 115 | assertThat(data.endsWith(TODO_MARKER), equalTo(true)) 116 | 117 | assertThat(AVUtils.readFully(null), nullValue()) 118 | } 119 | 120 | companion object { 121 | private const val WORLD = "World!" 122 | private const val HELLO = "Hello," 123 | private const val SPACE = " " 124 | private const val HELLO_WORLD = HELLO + SPACE + WORLD 125 | 126 | private const val TODO_MARKER = "[TO-DO]" 127 | private const val TODO_FILE = "TODO.txt" 128 | } 129 | 130 | } 131 | -------------------------------------------------------------------------------- /src/test/kotlin/com/github/vbauer/avconv4java/util/ProcessExecutorTest.kt: -------------------------------------------------------------------------------- 1 | package com.github.vbauer.avconv4java.util 2 | 3 | import com.github.vbauer.avconv4java.common.TestUtils 4 | import com.github.vbauer.avconv4java.util.process.ProcessExecutor 5 | import com.github.vbauer.avconv4java.util.process.ProcessInfo 6 | import org.hamcrest.MatcherAssert.assertThat 7 | import org.hamcrest.Matchers.* 8 | import org.testng.SkipException 9 | import org.testng.annotations.Test 10 | import org.testng.collections.Lists 11 | import java.util.concurrent.ExecutorService 12 | 13 | /** 14 | * @author Vladislav Bauer 15 | */ 16 | 17 | class ProcessExecutorTest { 18 | 19 | private val dirListCmd: List 20 | get() { 21 | if (couldHaveBash()) { 22 | return Lists.newArrayList("ls") 23 | } else if (AVUtils.isWindows()) { 24 | return Lists.newArrayList("CMD", "/C", "DIR") 25 | } 26 | throw SkipException(MESSAGE_OS_TYPE) 27 | } 28 | 29 | private val sleepCmd: List 30 | get() { 31 | if (couldHaveBash()) { 32 | return Lists.newArrayList("sleep", "1") 33 | } 34 | throw SkipException(MESSAGE_OS_TYPE) 35 | } 36 | 37 | 38 | @Test 39 | fun testConstructorContract() { 40 | TestUtils.checkUtilClassConstructor(ProcessExecutor::class.java) 41 | } 42 | 43 | @Test 44 | fun testNixCommandWithEnoughTimeout() { 45 | val command = dirListCmd 46 | assertThat(runCommand(command, 30000L, false).isSuccess, equalTo(true)) 47 | assertThat(runCommand(command, 30000L, true).isSuccess, equalTo(true)) 48 | } 49 | 50 | @Test 51 | fun testNixCommandWithNotEnoughTimeout() { 52 | val command = sleepCmd 53 | assertThat(runCommand(command, 1L, false).isError, equalTo(true)) 54 | assertThat(runCommand(command, 1L, true).isError, equalTo(true)) 55 | } 56 | 57 | @Test 58 | fun testNixCommandWithoutTimeout() { 59 | val command = dirListCmd 60 | assertThat(runCommand(command, null, false).isSuccess, equalTo(true)) 61 | assertThat(runCommand(command, null, true).isSuccess, equalTo(true)) 62 | } 63 | 64 | @Test 65 | fun testErrorProcessInfo() { 66 | val info = ProcessInfo.error(MESSAGE_OS_TYPE) 67 | assertThat(info.isError, equalTo(true)) 68 | assertThat(info.isSuccess, equalTo(false)) 69 | assertThat(info.output, nullValue()) 70 | assertThat(info.errorOutput, equalTo(MESSAGE_OS_TYPE)) 71 | } 72 | 73 | @Test 74 | fun testCorrectProcessInfo() { 75 | val info = ProcessInfo.create(ProcessInfo.EXIT_CODE_SUCCESS, MESSAGE_OS_TYPE, null) 76 | assertThat(info.isError, equalTo(false)) 77 | assertThat(info.isSuccess, equalTo(true)) 78 | assertThat(info.errorOutput, nullValue()) 79 | assertThat(info.output, equalTo(MESSAGE_OS_TYPE)) 80 | } 81 | 82 | @Test 83 | fun testShutdownExecutor() { 84 | val method = ProcessExecutor::class.java.getDeclaredMethod("shutdownExecutor", ExecutorService::class.java) 85 | method.isAccessible = true 86 | 87 | val result = method.invoke(null, null) 88 | assertThat(result, nullValue()) 89 | } 90 | 91 | 92 | /* 93 | * Internal API. 94 | */ 95 | 96 | private fun runCommand(command: List, timeout: Long?, debug: Boolean): ProcessInfo { 97 | val processInfo = ProcessExecutor.execute(command, timeout, debug) 98 | val statusCode = processInfo.statusCode 99 | val errorOutput = AVUtils.trimToNull(processInfo.errorOutput) 100 | if (errorOutput != null) { 101 | assertThat(statusCode, not(equalTo(ProcessInfo.EXIT_CODE_SUCCESS))) 102 | } 103 | return processInfo 104 | } 105 | 106 | private fun couldHaveBash(): Boolean { 107 | val mac = AVUtils.isMac() 108 | val solaris = AVUtils.isSolaris() 109 | val unix = AVUtils.isUnix() 110 | 111 | return mac || solaris || unix 112 | } 113 | 114 | companion object { 115 | private const val MESSAGE_OS_TYPE = "Test is only for Solaris, Unix, Windows and Mac" 116 | } 117 | 118 | } 119 | -------------------------------------------------------------------------------- /src/test/resources/TODO.txt: -------------------------------------------------------------------------------- 1 | 2 | [TO-DO] 3 | 4 | 5.8 Advanced Video Options 5 | 6 | ‘-rc_override[:stream_specifier] override (output,per-stream)’ 7 | rate control override for specific intervals 8 | 9 | ‘-top[:stream_specifier] n (output,per-stream)’ 10 | top=1/bottom=0/auto=-1 field first 11 | 12 | ‘-dc precision’ 13 | Intra_dc_precision. 14 | 15 | ‘-vtag fourcc/tag (output)’ 16 | Force video tag/fourcc. This is an alias for -tag:v. 17 | 18 | ‘-qphist (global)’ 19 | Show QP histogram. 20 | 21 | ‘-force_key_frames[:stream_specifier] time[,time...] (output,per-stream)’ 22 | Force key frames at the specified timestamps, more precisely at the first frames after each specified time. This option can be useful to ensure that a seek point is present at a chapter mark or any other designated place in the output file. The timestamps must be specified in ascending order. 23 | 24 | ‘-copyinkf[:stream_specifier] (output,per-stream)’ 25 | When doing stream copy, copy also non-key frames found at the beginning. 26 | 27 | ‘-hwaccel_device[:stream_specifier] hwaccel_device (input,per-stream)’ 28 | Select a device to use for hardware acceleration. 29 | 30 | 31 | 5.12 Advanced options 32 | 33 | ‘-map [-]input_file_id[:stream_specifier][,sync_file_id[:stream_specifier]] | [linklabel] (output)’ 34 | 35 | ‘-map_metadata[:metadata_spec_out] infile[:metadata_spec_in] (output,per-metadata)’ 36 | Set metadata information of the next output file from infile. Note that those are file indices (zero-based), not filenames. Optional metadata_spec_in/out parameters specify, which metadata to copy. A metadata specifier can have the following forms: 37 | 38 | ‘-map_chapters input_file_index (output)’ 39 | Copy chapters from input file with index input_file_index to the next output file. If no chapter mapping is specified, then chapters are copied from the first input file with at least one chapter. Use a negative file index to disable any chapter copying. 40 | 41 | ‘-re (input)’ 42 | Read input at native frame rate. Mainly used to simulate a grab device or live input stream (e.g. when reading from a file). Should not be used with actual grab devices or live input streams (where it can cause packet loss). 43 | 44 | ‘-streamid output-stream-index:new-value (output)’ 45 | Assign a new stream-id value to an output stream. This option should be specified prior to the output filename to which it applies. For the situation where multiple output files exist, a streamid may be reassigned to a different value. 46 | 47 | For example, to set the stream 0 PID to 33 and the stream 1 PID to 36 for an output mpegts file: 48 | 49 | 50 | avconv -i infile -streamid 0:33 -streamid 1:36 out.ts 51 | ‘-bsf[:stream_specifier] bitstream_filters (output,per-stream)’ 52 | Set bitstream filters for matching streams. bistream_filters is a comma-separated list of bitstream filters. Use the -bsfs option to get the list of bitstream filters. 53 | 54 | 55 | avconv -i h264.mp4 -c:v copy -bsf:v h264_mp4toannexb -an out.h264 56 | 57 | avconv -i file.mov -an -vn -bsf:s mov2textsub -c:s copy -f rawvideo sub.txt 58 | ‘-tag[:stream_specifier] codec_tag (output,per-stream)’ 59 | Force a tag/fourcc for matching streams. 60 | 61 | ‘-filter_complex filtergraph (global)’ 62 | Define a complex filter graph, i.e. one with arbitrary number of inputs and/or outputs. For simple graphs – those with one input and one output of the same type – see the ‘-filter’ options. filtergraph is a description of the filter graph, as described in Filtergraph syntax. 63 | 64 | [TO-DO] 65 | --------------------------------------------------------------------------------