Uses `-vpre`. + * + * @param preset the preset + * @return this + */ + public T setVideoPreset(String preset) { + this.video_enabled = true; + this.video_preset = checkNotEmpty(preset, "video preset must not be empty"); + return (T) this; + } + + /** + * Sets the number of b-frames ffmpeg is allowed to use. 0 means: Do not use b-frames at all + * + * @param bFrames number of b-frames + * @return this + */ + public T setBFrames(int bFrames) { + this.bFrames = bFrames; + return (T) this; + } + + /** + * Sets Video Filter + * + *
TODO Build a fluent Filter builder + * + * @param filter The video filter. + * @return this + */ + public T setVideoFilter(String filter) { + this.video_enabled = true; + this.video_filter = checkNotEmpty(filter, "filter must not be empty"); + return (T) this; + } + + /** + * Sets the audio bit depth. + * + * @param bit_depth The sample format, one of the net.bramp.ffmpeg.FFmpeg#AUDIO_DEPTH_* constants. + * @return this + * @see net.bramp.ffmpeg.FFmpeg#AUDIO_DEPTH_U8 + * @see net.bramp.ffmpeg.FFmpeg#AUDIO_DEPTH_S16 + * @see net.bramp.ffmpeg.FFmpeg#AUDIO_DEPTH_S32 + * @see net.bramp.ffmpeg.FFmpeg#AUDIO_DEPTH_FLT + * @see net.bramp.ffmpeg.FFmpeg#AUDIO_DEPTH_DBL + * @deprecated use {@link #setAudioSampleFormat} instead. + */ + @Deprecated + @InlineMe(replacement = "this.setAudioSampleFormat(bit_depth)") + public final T setAudioBitDepth(String bit_depth) { + return setAudioSampleFormat(bit_depth); + } + + /** + * Sets the audio sample format. + * + * @param sample_format The sample format, one of the net.bramp.ffmpeg.FFmpeg#AUDIO_FORMAT_* + * constants. + * @return this + * @see net.bramp.ffmpeg.FFmpeg#AUDIO_FORMAT_U8 + * @see net.bramp.ffmpeg.FFmpeg#AUDIO_FORMAT_S16 + * @see net.bramp.ffmpeg.FFmpeg#AUDIO_FORMAT_S32 + * @see net.bramp.ffmpeg.FFmpeg#AUDIO_FORMAT_FLT + * @see net.bramp.ffmpeg.FFmpeg#AUDIO_FORMAT_DBL + */ + public T setAudioSampleFormat(String sample_format) { + this.audio_enabled = true; + this.audio_sample_format = checkNotEmpty(sample_format, "sample format must not be empty"); + return (T) this; + } + + /** + * Sets the Audio bit rate + * + * @param bit_rate Audio bitrate in bits per second. + * @return this + */ + public T setAudioBitRate(long bit_rate) { + checkArgument(bit_rate > 0, "bit rate must be positive"); + this.audio_enabled = true; + this.audio_bit_rate = bit_rate; + return (T) this; + } + + public T setAudioQuality(double quality) { + checkArgument(quality > 0, "quality must be positive"); + this.audio_enabled = true; + this.audio_quality = quality; + return (T) this; + } + + public T setAudioBitStreamFilter(String filter) { + this.audio_enabled = true; + this.audio_bit_stream_filter = checkNotEmpty(filter, "filter must not be empty"); + return (T) this; + } + + public T setComplexFilter(String filter) { + this.complexFilter = checkNotEmpty(filter, "filter must not be empty"); + + return (T) this; + } + + /** + * Sets Audio Filter + * + *
TODO Build a fluent Filter builder + * + * @param filter The audio filter. + * @return this + */ + public T setAudioFilter(String filter) { + this.audio_enabled = true; + this.audio_filter = checkNotEmpty(filter, "filter must not be empty"); + return (T) this; + } + + /** + * Returns a representation of this Builder that can be safely serialised. + * + *
NOTE: This method is horribly out of date, and its use should be rethought.
+ *
+ * @return A new EncodingOptions capturing this Builder's state
+ */
+ @CheckReturnValue
+ @Override
+ public EncodingOptions buildOptions() {
+ // TODO When/if modelmapper supports @ConstructorProperties, we map this
+ // object, instead of doing new XXX(...)
+ // https://github.com/jhalterman/modelmapper/issues/44
+ return new EncodingOptions(
+ new MainEncodingOptions(format, startOffset, duration),
+ new AudioEncodingOptions(
+ audio_enabled,
+ audio_codec,
+ audio_channels,
+ audio_sample_rate,
+ audio_sample_format,
+ audio_bit_rate,
+ audio_quality),
+ new VideoEncodingOptions(
+ video_enabled,
+ video_codec,
+ video_frame_rate,
+ video_width,
+ video_height,
+ video_bit_rate,
+ video_frames,
+ video_filter,
+ video_preset));
+ }
+
+ @CheckReturnValue
+ @Override
+ protected List Uses `-vpre`.
- *
- * @param preset the preset
- * @return this
- */
- public FFmpegOutputBuilder setVideoPreset(String preset) {
- this.video_enabled = true;
- this.video_preset = checkNotEmpty(preset, "video preset must not be empty");
- return this;
- }
-
- /**
- * Sets Video Filter
- *
- * TODO Build a fluent Filter builder
- *
- * @param filter The video filter.
- * @return this
- */
- public FFmpegOutputBuilder setVideoFilter(String filter) {
- this.video_enabled = true;
- this.video_filter = checkNotEmpty(filter, "filter must not be empty");
- return this;
- }
-
- /**
- * Sets the audio bit depth.
- *
- * @param bit_depth The sample format, one of the net.bramp.ffmpeg.FFmpeg#AUDIO_DEPTH_* constants.
- * @return this
- * @see net.bramp.ffmpeg.FFmpeg#AUDIO_DEPTH_U8
- * @see net.bramp.ffmpeg.FFmpeg#AUDIO_DEPTH_S16
- * @see net.bramp.ffmpeg.FFmpeg#AUDIO_DEPTH_S32
- * @see net.bramp.ffmpeg.FFmpeg#AUDIO_DEPTH_FLT
- * @see net.bramp.ffmpeg.FFmpeg#AUDIO_DEPTH_DBL
- * @deprecated use {@link #setAudioSampleFormat} instead.
- */
- @Deprecated
- public FFmpegOutputBuilder setAudioBitDepth(String bit_depth) {
- return setAudioSampleFormat(bit_depth);
- }
-
- /**
- * Sets the audio sample format.
- *
- * @param sample_format The sample format, one of the net.bramp.ffmpeg.FFmpeg#AUDIO_FORMAT_*
- * constants.
- * @return this
- * @see net.bramp.ffmpeg.FFmpeg#AUDIO_FORMAT_U8
- * @see net.bramp.ffmpeg.FFmpeg#AUDIO_FORMAT_S16
- * @see net.bramp.ffmpeg.FFmpeg#AUDIO_FORMAT_S32
- * @see net.bramp.ffmpeg.FFmpeg#AUDIO_FORMAT_FLT
- * @see net.bramp.ffmpeg.FFmpeg#AUDIO_FORMAT_DBL
- */
- public FFmpegOutputBuilder setAudioSampleFormat(String sample_format) {
- this.audio_enabled = true;
- this.audio_sample_format = checkNotEmpty(sample_format, "sample format must not be empty");
- return this;
- }
-
- /**
- * Sets the Audio bit rate
- *
- * @param bit_rate Audio bitrate in bits per second.
- * @return this
- */
- public FFmpegOutputBuilder setAudioBitRate(long bit_rate) {
- checkArgument(bit_rate > 0, "bit rate must be positive");
- this.audio_enabled = true;
- this.audio_bit_rate = bit_rate;
- return this;
- }
-
- public FFmpegOutputBuilder setAudioQuality(double quality) {
- checkArgument(quality > 0, "quality must be positive");
- this.audio_enabled = true;
- this.audio_quality = quality;
- return this;
- }
-
- public FFmpegOutputBuilder setAudioBitStreamFilter(String filter) {
- this.audio_enabled = true;
- this.audio_bit_stream_filter = checkNotEmpty(filter, "filter must not be empty");
- return this;
- }
-
- /**
- * Sets Audio Filter
- *
- * TODO Build a fluent Filter builder
- *
- * @param filter The audio filter.
- * @return this
- */
- public FFmpegOutputBuilder setAudioFilter(String filter) {
- this.audio_enabled = true;
- this.audio_filter = checkNotEmpty(filter, "filter must not be empty");
- return this;
- }
-
- /**
- * Returns a representation of this Builder that can be safely serialised.
- *
- * NOTE: This method is horribly out of date, and its use should be rethought.
- *
- * @return A new EncodingOptions capturing this Builder's state
- */
- @CheckReturnValue
- @Override
- public EncodingOptions buildOptions() {
- // TODO When/if modelmapper supports @ConstructorProperties, we map this
- // object, instead of doing new XXX(...)
- // https://github.com/jhalterman/modelmapper/issues/44
- return new EncodingOptions(
- new MainEncodingOptions(format, startOffset, duration),
- new AudioEncodingOptions(
- audio_enabled,
- audio_codec,
- audio_channels,
- audio_sample_rate,
- audio_sample_format,
- audio_bit_rate,
- audio_quality),
- new VideoEncodingOptions(
- video_enabled,
- video_codec,
- video_frame_rate,
- video_width,
- video_height,
- video_bit_rate,
- video_frames,
- video_filter,
- video_preset));
- }
-
- @CheckReturnValue
- @Override
- protected List TODO Move this method to somewhere better.
*
- * @param scheme
- * @param address
- * @param port
- * @return
- * @throws URISyntaxException
+ * @param scheme The scheme to use (e.g. "tcp", "udp", "rtp", "http")
+ * @param address The address of the server
+ * @param port The port to connect to
+ * @return A URI representing the address and port
+ * @throws URISyntaxException if the URI is invalid
*/
@CheckReturnValue
static URI createUri(String scheme, InetAddress address, int port) throws URISyntaxException {
diff --git a/src/main/java/net/bramp/ffmpeg/progress/Progress.java b/src/main/java/net/bramp/ffmpeg/progress/Progress.java
index 82e92df5..ca6fc855 100644
--- a/src/main/java/net/bramp/ffmpeg/progress/Progress.java
+++ b/src/main/java/net/bramp/ffmpeg/progress/Progress.java
@@ -1,20 +1,18 @@
package net.bramp.ffmpeg.progress;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static net.bramp.ffmpeg.FFmpegUtils.fromTimecode;
+
import com.google.common.base.MoreObjects;
+import java.util.Objects;
+import javax.annotation.CheckReturnValue;
import net.bramp.ffmpeg.FFmpegUtils;
import org.apache.commons.lang3.math.Fraction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import javax.annotation.CheckReturnValue;
-import java.util.Objects;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static net.bramp.ffmpeg.FFmpegUtils.fromTimecode;
-
// TODO Change to be immutable
public class Progress {
-
static final Logger LOG = LoggerFactory.getLogger(Progress.class);
public enum Status {
@@ -62,8 +60,8 @@ public static Status of(String status) {
/** Output file size (in bytes) */
public long total_size = 0;
- /** Output time (in nanoseconds) */
// TODO Change this to a java.time.Duration
+ /** Output time (in nanoseconds) */
public long out_time_ns = 0;
public long dup_frames = 0;
@@ -158,6 +156,9 @@ protected boolean parseLine(String line) {
// out_time_ns = Long.parseLong(value) * 1000;
return false;
+ case "out_time_us":
+ return false;
+
case "out_time":
out_time_ns = fromTimecode(value);
return false;
@@ -206,7 +207,8 @@ public boolean isEnd() {
@Override
public boolean equals(Object o) {
if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
+ if (!(o instanceof Progress)) return false;
+
Progress progress1 = (Progress) o;
return frame == progress1.frame
&& bitrate == progress1.bitrate
@@ -239,4 +241,40 @@ public String toString() {
.add("status", status)
.toString();
}
+
+ public long getFrame() {
+ return frame;
+ }
+
+ public Fraction getFps() {
+ return fps;
+ }
+
+ public long getBitrate() {
+ return bitrate;
+ }
+
+ public long getTotalSize() {
+ return total_size;
+ }
+
+ public long getOutTimeNs() {
+ return out_time_ns;
+ }
+
+ public long getDupFrames() {
+ return dup_frames;
+ }
+
+ public long getDropFrames() {
+ return drop_frames;
+ }
+
+ public float getSpeed() {
+ return speed;
+ }
+
+ public Status getStatus() {
+ return status;
+ }
}
diff --git a/src/main/java/net/bramp/ffmpeg/progress/StreamProgressParser.java b/src/main/java/net/bramp/ffmpeg/progress/StreamProgressParser.java
index 18e691c9..d5e90043 100644
--- a/src/main/java/net/bramp/ffmpeg/progress/StreamProgressParser.java
+++ b/src/main/java/net/bramp/ffmpeg/progress/StreamProgressParser.java
@@ -1,15 +1,14 @@
package net.bramp.ffmpeg.progress;
-import com.google.common.base.Charsets;
+import static com.google.common.base.Preconditions.checkNotNull;
+import com.google.common.base.Charsets;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
-import static com.google.common.base.Preconditions.checkNotNull;
-
public class StreamProgressParser {
final ProgressListener listener;
diff --git a/src/main/java/net/bramp/ffmpeg/progress/TcpProgressParserRunnable.java b/src/main/java/net/bramp/ffmpeg/progress/TcpProgressParserRunnable.java
index 33a34875..50a7feeb 100644
--- a/src/main/java/net/bramp/ffmpeg/progress/TcpProgressParserRunnable.java
+++ b/src/main/java/net/bramp/ffmpeg/progress/TcpProgressParserRunnable.java
@@ -1,5 +1,7 @@
package net.bramp.ffmpeg.progress;
+import static com.google.common.base.Preconditions.checkNotNull;
+
import java.io.IOException;
import java.io.InputStream;
import java.net.ServerSocket;
@@ -7,8 +9,6 @@
import java.net.SocketException;
import java.util.concurrent.CountDownLatch;
-import static com.google.common.base.Preconditions.checkNotNull;
-
class TcpProgressParserRunnable implements Runnable {
final StreamProgressParser parser;
diff --git a/src/main/java/net/bramp/ffmpeg/progress/UdpProgressParser.java b/src/main/java/net/bramp/ffmpeg/progress/UdpProgressParser.java
index 4c4014b6..70b01aed 100644
--- a/src/main/java/net/bramp/ffmpeg/progress/UdpProgressParser.java
+++ b/src/main/java/net/bramp/ffmpeg/progress/UdpProgressParser.java
@@ -1,5 +1,7 @@
package net.bramp.ffmpeg.progress;
+import static com.google.common.base.Preconditions.checkNotNull;
+
import java.io.IOException;
import java.net.DatagramSocket;
import java.net.InetAddress;
@@ -8,8 +10,6 @@
import java.net.URISyntaxException;
import java.util.concurrent.CountDownLatch;
-import static com.google.common.base.Preconditions.checkNotNull;
-
public class UdpProgressParser extends AbstractSocketProgressParser {
final DatagramSocket socket;
diff --git a/src/main/java/net/bramp/ffmpeg/progress/UdpProgressParserRunnable.java b/src/main/java/net/bramp/ffmpeg/progress/UdpProgressParserRunnable.java
index d2a5b3e2..002860fd 100644
--- a/src/main/java/net/bramp/ffmpeg/progress/UdpProgressParserRunnable.java
+++ b/src/main/java/net/bramp/ffmpeg/progress/UdpProgressParserRunnable.java
@@ -1,5 +1,7 @@
package net.bramp.ffmpeg.progress;
+import static com.google.common.base.Preconditions.checkNotNull;
+
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.net.DatagramPacket;
@@ -7,8 +9,6 @@
import java.net.SocketException;
import java.util.concurrent.CountDownLatch;
-import static com.google.common.base.Preconditions.checkNotNull;
-
class UdpProgressParserRunnable implements Runnable {
static final int MAX_PACKET_SIZE = 1500;
diff --git a/src/main/java/net/bramp/ffmpeg/shared/CodecType.java b/src/main/java/net/bramp/ffmpeg/shared/CodecType.java
new file mode 100644
index 00000000..7ccbd01e
--- /dev/null
+++ b/src/main/java/net/bramp/ffmpeg/shared/CodecType.java
@@ -0,0 +1,9 @@
+package net.bramp.ffmpeg.shared;
+
+public enum CodecType {
+ VIDEO,
+ AUDIO,
+ SUBTITLE,
+ DATA,
+ ATTACHMENT
+}
diff --git a/src/test/java/net/bramp/commons/lang3/math/gson/FractionAdapterTest.java b/src/test/java/net/bramp/commons/lang3/math/gson/FractionAdapterTest.java
index 39700d12..49851c99 100644
--- a/src/test/java/net/bramp/commons/lang3/math/gson/FractionAdapterTest.java
+++ b/src/test/java/net/bramp/commons/lang3/math/gson/FractionAdapterTest.java
@@ -1,17 +1,16 @@
package net.bramp.commons.lang3.math.gson;
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.MatcherAssert.assertThat;
+
import com.google.common.collect.ImmutableList;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
+import java.util.List;
import org.apache.commons.lang3.math.Fraction;
import org.junit.BeforeClass;
import org.junit.Test;
-import java.util.List;
-
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.junit.Assert.assertThat;
-
public class FractionAdapterTest {
static Gson gson;
@@ -26,7 +25,7 @@ private static class TestData {
final String s;
final Fraction f;
- public TestData(String s, Fraction f) {
+ TestData(String s, Fraction f) {
this.s = s;
this.f = f;
}
diff --git a/src/test/java/net/bramp/ffmpeg/ExamplesTest.java b/src/test/java/net/bramp/ffmpeg/ExamplesTest.java
index 64ac4634..e84779f4 100644
--- a/src/test/java/net/bramp/ffmpeg/ExamplesTest.java
+++ b/src/test/java/net/bramp/ffmpeg/ExamplesTest.java
@@ -1,6 +1,14 @@
package net.bramp.ffmpeg;
+import static net.bramp.ffmpeg.FFmpegTest.argThatHasItem;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.when;
+
import com.google.common.base.Joiner;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
import net.bramp.ffmpeg.builder.FFmpegBuilder;
import net.bramp.ffmpeg.builder.FFmpegOutputBuilder;
import net.bramp.ffmpeg.lang.NewProcessAnswer;
@@ -11,13 +19,6 @@
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
-import java.io.IOException;
-import java.util.ArrayList;
-
-import static net.bramp.ffmpeg.FFmpegTest.argThatHasItem;
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.when;
-
/**
* Ensures the examples in the Examples on github continue to work.
* https://github.com/bramp/ffmpeg-cli-wrapper/wiki/Random-Examples
@@ -44,9 +45,10 @@ public void testExample1() throws IOException {
new FFmpegBuilder()
.addExtraArgs("-rtbufsize", "1500M")
.addExtraArgs("-re")
- .setFormat("dshow")
.setInput(
"video=\"Microsoft Camera Rear\":audio=\"Microphone Array (Realtek High Definition Audio(SST))\"")
+ .setFormat("dshow")
+ .done()
.addOutput("rtmp://a.rtmp.youtube.com/live2/1234-5678")
.setFormat("flv")
.addExtraArgs("-bufsize", "4000k")
@@ -67,7 +69,7 @@ public void testExample1() throws IOException {
String expected =
"ffmpeg\\win64\\bin\\ffmpeg.exe -y -v error"
- + " -f dshow -rtbufsize 1500M -re"
+ + " -rtbufsize 1500M -re -f dshow"
+ " -i video=\"Microsoft Camera Rear\":audio=\"Microphone Array (Realtek High Definition Audio(SST))\""
+ " -f flv"
+ " -vcodec libx264 -pix_fmt yuv420p -s 426x240 -r 30/1 -b:v 2000000"
@@ -85,6 +87,7 @@ public void testExample2() throws IOException {
FFmpegBuilder builder =
new FFmpegBuilder()
.setInput("input.mkv")
+ .done()
.addOutput("output.ogv")
.setVideoCodec("libtheora")
.addExtraArgs("-qscale:v", "7")
@@ -110,6 +113,7 @@ public void testExample3() throws IOException {
FFmpegBuilder builder =
new FFmpegBuilder()
.setInput("sample.avi")
+ .done()
.addOutput("thumbnail.png")
.setFrames(1)
.setVideoFilter("select='gte(n\\,10)',scale=200:-1")
@@ -131,6 +135,7 @@ public void testExample4() throws IOException {
FFmpegBuilder builder =
new FFmpegBuilder()
.setInput("rtsp://192.168.1.1:1234/")
+ .done()
.addOutput("img%03d.jpg")
.setFormat("image2")
.done();
@@ -151,7 +156,8 @@ public void testExample5() throws IOException {
FFmpeg ffmpeg = new FFmpeg("/path/to/ffmpeg", func);
FFprobe ffprobe = new FFprobe("/path/to/ffprobe", func);
- FFmpegBuilder builder = new FFmpegBuilder().setInput("input").addOutput("output.mp4").done();
+ FFmpegBuilder builder =
+ new FFmpegBuilder().setInput("input").done().addOutput("output.mp4").done();
FFmpegExecutor executor = new FFmpegExecutor(ffmpeg, ffprobe);
@@ -165,6 +171,7 @@ public void testExample6() throws IOException {
FFmpegBuilder builder =
new FFmpegBuilder()
.addInput("image%03d.png")
+ .done()
.addOutput("output.mp4")
.setVideoFrameRate(FFmpeg.FPS_24)
.done();
@@ -180,11 +187,13 @@ public void testExample7() throws IOException {
FFmpegBuilder builder =
new FFmpegBuilder()
.addInput("original.mp4")
+ .done()
.addInput("spot.mp4")
+ .done()
+ .addOutput("with-video.mp4")
.setComplexFilter(
"[1:v]scale=368:207,setpts=PTS-STARTPTS+5/TB [ov]; "
+ "[0:v][ov] overlay=x=(main_w-overlay_w)/2:y=(main_h-overlay_h)/2:enable='between(t,5,15)' [v]")
- .addOutput("with-video.mp4")
.addExtraArgs("-map", "[v]")
.addExtraArgs("-map", "0:a")
.setVideoCodec("libx264")
@@ -198,9 +207,9 @@ public void testExample7() throws IOException {
"ffmpeg -y -v error"
+ " -i original.mp4"
+ " -i spot.mp4"
- + " -filter_complex [1:v]scale=368:207,setpts=PTS-STARTPTS+5/TB [ov]; [0:v][ov] overlay=x=(main_w-overlay_w)/2:y=(main_h-overlay_h)/2:enable='between(t,5,15)' [v]"
+ " -preset ultrafast"
+ " -crf 20"
+ + " -filter_complex [1:v]scale=368:207,setpts=PTS-STARTPTS+5/TB [ov]; [0:v][ov] overlay=x=(main_w-overlay_w)/2:y=(main_h-overlay_h)/2:enable='between(t,5,15)' [v]"
+ " -vcodec libx264"
+ " -acodec copy"
+ " -map [v]"
@@ -218,6 +227,7 @@ public void testExample8() throws IOException {
FFmpegBuilder builder =
new FFmpegBuilder()
.addInput("original.mp4")
+ .done()
.setVideoFilter("select='gte(n\\,10)',scale=200:-1")
.addOutput("hevc-video.mp4")
.addExtraArgs("-tag:v", "hvc1")
@@ -243,6 +253,7 @@ public void testExample9() throws IOException {
new FFmpegBuilder()
.setVerbosity(FFmpegBuilder.Verbosity.DEBUG)
.setInput("input.mp3")
+ .done()
.overrideOutputFiles(true) // Override the output if it exists
.addOutput("left.mp3")
.addExtraArgs("-map_channel", "0.0.0")
@@ -264,16 +275,20 @@ public void testExample9() throws IOException {
// A test with videos added in a loop.
@Test
public void testExample10() throws IOException {
- String expected = "ffmpeg -y -v error"
- + " -f webm_dash_manifest"
- + " -i audio.webm"
- + " -i video_1.webm"
- + " -i video_2.webm"
- + " -i video_3.webm"
- + " -vcodec copy -acodec copy"
- + " -map 0 -map 1 -map 2 -map 3"
- + " -adaptation_sets \"id=0,streams=0 id=1,streams=1,2,3\""
- + " output.mpd";
+ String expected =
+ "ffmpeg -y -v error"
+ + " -f webm_dash_manifest"
+ + " -i audio.webm"
+ + " -f webm_dash_manifest"
+ + " -i video_1.webm"
+ + " -f webm_dash_manifest"
+ + " -i video_2.webm"
+ + " -f webm_dash_manifest"
+ + " -i video_3.webm"
+ + " -vcodec copy -acodec copy"
+ + " -map 0 -map 1 -map 2 -map 3"
+ + " -adaptation_sets \"id=0,streams=0 id=1,streams=1,2,3\""
+ + " output.mpd";
ArrayList-filter_threads nb_threads (global)
*
- *
*
*
- *
* -muxdelay seconds (input)
* -guess_layout_max channels (input,per-stream)
*
*
- *
*
*
* @param -atag fourcc/tag (output)
*
* -bsf[:stream_specifier] bitstream_filters (output,per-stream)
*
+ * you can get a list of available codecs through use {@link net.bramp.ffmpeg.FFmpeg#codecs()}.
+ *
+ * @see net.bramp.ffmpeg.FFmpeg#codecs()
+ * @author van1164
+ */
+public class AudioCodec {
+
+ /** 4GV (Fourth Generation Vocoder) */
+ public static final String GV = "4gv";
+
+ /** 8SVX exponential */
+ public static final String SVX_EXP = "8svx_exp";
+
+ /** 8SVX fibonacci */
+ public static final String SVX_FIB = "8svx_fib";
+
+ /** AAC (Advanced Audio Coding) (decoders: aac aac_fixed) (encoders: aac aac_mf) */
+ public static final String AAC = "aac";
+
+ /** AAC LATM (Advanced Audio Coding LATM syntax) */
+ public static final String AAC_LATM = "aac_latm";
+
+ /** ATSC A/52A (AC-3) (decoders: ac3 ac3_fixed) (encoders: ac3 ac3_fixed ac3_mf) */
+ public static final String AC3 = "ac3";
+
+ /** AC-4 */
+ public static final String AC4 = "ac4";
+
+ /** Sipro ACELP.KELVIN */
+ public static final String ACELP_KELVIN = "acelp.kelvin";
+
+ /** ADPCM 4X Movie */
+ public static final String ADPCM_4XM = "adpcm_4xm";
+
+ /** SEGA CRI ADX ADPCM */
+ public static final String ADPCM_ADX = "adpcm_adx";
+
+ /** ADPCM Nintendo Gamecube AFC */
+ public static final String ADPCM_AFC = "adpcm_afc";
+
+ /** ADPCM AmuseGraphics Movie AGM */
+ public static final String ADPCM_AGM = "adpcm_agm";
+
+ /** ADPCM Yamaha AICA */
+ public static final String ADPCM_AICA = "adpcm_aica";
+
+ /** ADPCM Argonaut Games */
+ public static final String ADPCM_ARGO = "adpcm_argo";
+
+ /** ADPCM Creative Technology */
+ public static final String ADPCM_CT = "adpcm_ct";
+
+ /** ADPCM Nintendo Gamecube DTK */
+ public static final String ADPCM_DTK = "adpcm_dtk";
+
+ /** ADPCM Electronic Arts */
+ public static final String ADPCM_EA = "adpcm_ea";
+
+ /** ADPCM Electronic Arts Maxis CDROM XA */
+ public static final String ADPCM_EA_MAXIS_XA = "adpcm_ea_maxis_xa";
+
+ /** ADPCM Electronic Arts R1 */
+ public static final String ADPCM_EA_R1 = "adpcm_ea_r1";
+
+ /** ADPCM Electronic Arts R2 */
+ public static final String ADPCM_EA_R2 = "adpcm_ea_r2";
+
+ /** ADPCM Electronic Arts R3 */
+ public static final String ADPCM_EA_R3 = "adpcm_ea_r3";
+
+ /** ADPCM Electronic Arts XAS */
+ public static final String ADPCM_EA_XAS = "adpcm_ea_xas";
+
+ /** G.722 ADPCM (decoders: g722) (encoders: g722) */
+ public static final String ADPCM_G722 = "adpcm_g722";
+
+ /** G.726 ADPCM (decoders: g726) (encoders: g726) */
+ public static final String ADPCM_G726 = "adpcm_g726";
+
+ /** G.726 ADPCM little-endian (decoders: g726le) (encoders: g726le) */
+ public static final String ADPCM_G726LE = "adpcm_g726le";
+
+ /** ADPCM IMA Acorn Replay */
+ public static final String ADPCM_IMA_ACORN = "adpcm_ima_acorn";
+
+ /** ADPCM IMA High Voltage Software ALP */
+ public static final String ADPCM_IMA_ALP = "adpcm_ima_alp";
+
+ /** ADPCM IMA AMV */
+ public static final String ADPCM_IMA_AMV = "adpcm_ima_amv";
+
+ /** ADPCM IMA CRYO APC */
+ public static final String ADPCM_IMA_APC = "adpcm_ima_apc";
+
+ /** ADPCM IMA Ubisoft APM */
+ public static final String ADPCM_IMA_APM = "adpcm_ima_apm";
+
+ /** ADPCM IMA Cunning Developments */
+ public static final String ADPCM_IMA_CUNNING = "adpcm_ima_cunning";
+
+ /** ADPCM IMA Eurocom DAT4 */
+ public static final String ADPCM_IMA_DAT4 = "adpcm_ima_dat4";
+
+ /** ADPCM IMA Duck DK3 */
+ public static final String ADPCM_IMA_DK3 = "adpcm_ima_dk3";
+
+ /** ADPCM IMA Duck DK4 */
+ public static final String ADPCM_IMA_DK4 = "adpcm_ima_dk4";
+
+ /** ADPCM IMA Electronic Arts EACS */
+ public static final String ADPCM_IMA_EA_EACS = "adpcm_ima_ea_eacs";
+
+ /** ADPCM IMA Electronic Arts SEAD */
+ public static final String ADPCM_IMA_EA_SEAD = "adpcm_ima_ea_sead";
+
+ /** ADPCM IMA Funcom ISS */
+ public static final String ADPCM_IMA_ISS = "adpcm_ima_iss";
+
+ /** ADPCM IMA MobiClip MOFLEX */
+ public static final String ADPCM_IMA_MOFLEX = "adpcm_ima_moflex";
+
+ /** ADPCM IMA Capcom's MT Framework */
+ public static final String ADPCM_IMA_MTF = "adpcm_ima_mtf";
+
+ /** ADPCM IMA Dialogic OKI */
+ public static final String ADPCM_IMA_OKI = "adpcm_ima_oki";
+
+ /** ADPCM IMA QuickTime */
+ public static final String ADPCM_IMA_QT = "adpcm_ima_qt";
+
+ /** ADPCM IMA Radical */
+ public static final String ADPCM_IMA_RAD = "adpcm_ima_rad";
+
+ /** ADPCM IMA Loki SDL MJPEG */
+ public static final String ADPCM_IMA_SMJPEG = "adpcm_ima_smjpeg";
+
+ /** ADPCM IMA Simon & Schuster Interactive */
+ public static final String ADPCM_IMA_SSI = "adpcm_ima_ssi";
+
+ /** ADPCM IMA WAV */
+ public static final String ADPCM_IMA_WAV = "adpcm_ima_wav";
+
+ /** ADPCM IMA Westwood */
+ public static final String ADPCM_IMA_WS = "adpcm_ima_ws";
+
+ /** ADPCM Microsoft */
+ public static final String ADPCM_MS = "adpcm_ms";
+
+ /** ADPCM MTAF */
+ public static final String ADPCM_MTAF = "adpcm_mtaf";
+
+ /** ADPCM Playstation */
+ public static final String ADPCM_PSX = "adpcm_psx";
+
+ /** ADPCM Sound Blaster Pro 2-bit */
+ public static final String ADPCM_SBPRO_2 = "adpcm_sbpro_2";
+
+ /** ADPCM Sound Blaster Pro 2.6-bit */
+ public static final String ADPCM_SBPRO_3 = "adpcm_sbpro_3";
+
+ /** ADPCM Sound Blaster Pro 4-bit */
+ public static final String ADPCM_SBPRO_4 = "adpcm_sbpro_4";
+
+ /** ADPCM Shockwave Flash */
+ public static final String ADPCM_SWF = "adpcm_swf";
+
+ /** ADPCM Nintendo THP */
+ public static final String ADPCM_THP = "adpcm_thp";
+
+ /** ADPCM Nintendo THP (Little-Endian) */
+ public static final String ADPCM_THP_LE = "adpcm_thp_le";
+
+ /** LucasArts VIMA audio */
+ public static final String ADPCM_VIMA = "adpcm_vima";
+
+ /** ADPCM CDROM XA */
+ public static final String ADPCM_XA = "adpcm_xa";
+
+ /** ADPCM Konami XMD */
+ public static final String ADPCM_XMD = "adpcm_xmd";
+
+ /** ADPCM Yamaha */
+ public static final String ADPCM_YAMAHA = "adpcm_yamaha";
+
+ /** ADPCM Zork */
+ public static final String ADPCM_ZORK = "adpcm_zork";
+
+ /** ALAC (Apple Lossless Audio Codec) */
+ public static final String ALAC = "alac";
+
+ /**
+ * AMR-NB (Adaptive Multi-Rate NarrowBand) (decoders: amrnb libopencore_amrnb) (encoders:
+ * libopencore_amrnb)
+ */
+ public static final String AMR_NB = "amr_nb";
+
+ /**
+ * AMR-WB (Adaptive Multi-Rate WideBand) (decoders: amrwb libopencore_amrwb) (encoders:
+ * libvo_amrwbenc)
+ */
+ public static final String AMR_WB = "amr_wb";
+
+ /** Null audio codec */
+ public static final String ANULL = "anull";
+
+ /** Marian's A-pac audio */
+ public static final String APAC = "apac";
+
+ /** Monkey's Audio */
+ public static final String APE = "ape";
+
+ /** aptX (Audio Processing Technology for Bluetooth) */
+ public static final String APTX = "aptx";
+
+ /** aptX HD (Audio Processing Technology for Bluetooth) */
+ public static final String APTX_HD = "aptx_hd";
+
+ /** ATRAC1 (Adaptive TRansform Acoustic Coding) */
+ public static final String ATRAC1 = "atrac1";
+
+ /** ATRAC3 (Adaptive TRansform Acoustic Coding 3) */
+ public static final String ATRAC3 = "atrac3";
+
+ /** ATRAC3 AL (Adaptive TRansform Acoustic Coding 3 Advanced Lossless) */
+ public static final String ATRAC3AL = "atrac3al";
+
+ /** ATRAC3+ (Adaptive TRansform Acoustic Coding 3+) (decoders: atrac3plus) */
+ public static final String ATRAC3P = "atrac3p";
+
+ /**
+ * ATRAC3+ AL (Adaptive TRansform Acoustic Coding 3+ Advanced Lossless) (decoders: atrac3plusal)
+ */
+ public static final String ATRAC3PAL = "atrac3pal";
+
+ /** ATRAC9 (Adaptive TRansform Acoustic Coding 9) */
+ public static final String ATRAC9 = "atrac9";
+
+ /** On2 Audio for Video Codec (decoders: on2avc) */
+ public static final String AVC = "avc";
+
+ /** Bink Audio (DCT) */
+ public static final String BINKAUDIO_DCT = "binkaudio_dct";
+
+ /** Bink Audio (RDFT) */
+ public static final String BINKAUDIO_RDFT = "binkaudio_rdft";
+
+ /** Discworld II BMV audio */
+ public static final String BMV_AUDIO = "bmv_audio";
+
+ /** Bonk audio */
+ public static final String BONK = "bonk";
+
+ /** DPCM Cuberoot-Delta-Exact */
+ public static final String CBD2_DPCM = "cbd2_dpcm";
+
+ /** Constrained Energy Lapped Transform (CELT) */
+ public static final String CELT = "celt";
+
+ /** codec2 (very low bitrate speech codec) */
+ public static final String CODEC2 = "codec2";
+
+ /** RFC 3389 Comfort Noise */
+ public static final String COMFORTNOISE = "comfortnoise";
+
+ /** Cook / Cooker / Gecko (RealAudio G2) */
+ public static final String COOK = "cook";
+
+ /** DPCM Xilam DERF */
+ public static final String DERF_DPCM = "derf_dpcm";
+
+ /** DFPWM (Dynamic Filter Pulse Width Modulation) */
+ public static final String DFPWM = "dfpwm";
+
+ /** Dolby E */
+ public static final String DOLBY_E = "dolby_e";
+
+ /** DSD (Direct Stream Digital), least significant bit first */
+ public static final String DSD_LSBF = "dsd_lsbf";
+
+ /** DSD (Direct Stream Digital), least significant bit first, planar */
+ public static final String DSD_LSBF_PLANAR = "dsd_lsbf_planar";
+
+ /** DSD (Direct Stream Digital), most significant bit first */
+ public static final String DSD_MSBF = "dsd_msbf";
+
+ /** DSD (Direct Stream Digital), most significant bit first, planar */
+ public static final String DSD_MSBF_PLANAR = "dsd_msbf_planar";
+
+ /** Delphine Software International CIN audio */
+ public static final String DSICINAUDIO = "dsicinaudio";
+
+ /** Digital Speech Standard - Standard Play mode (DSS SP) */
+ public static final String DSS_SP = "dss_sp";
+
+ /** DST (Direct Stream Transfer) */
+ public static final String DST = "dst";
+
+ /** DCA (DTS Coherent Acoustics) (decoders: dca) (encoders: dca) */
+ public static final String DTS = "dts";
+
+ /** DV audio */
+ public static final String DVAUDIO = "dvaudio";
+
+ /** ATSC A/52B (AC-3, E-AC-3) */
+ public static final String EAC3 = "eac3";
+
+ /** EVRC (Enhanced Variable Rate Codec) */
+ public static final String EVRC = "evrc";
+
+ /** MobiClip FastAudio */
+ public static final String FASTAUDIO = "fastaudio";
+
+ /** FLAC (Free Lossless Audio Codec) */
+ public static final String FLAC = "flac";
+
+ /** FTR Voice */
+ public static final String FTR = "ftr";
+
+ /** G.723.1 */
+ public static final String G723_1 = "g723_1";
+
+ /** G.729 */
+ public static final String G729 = "g729";
+
+ /** DPCM Gremlin */
+ public static final String GREMLIN_DPCM = "gremlin_dpcm";
+
+ /** GSM (decoders: gsm libgsm) (encoders: libgsm) */
+ public static final String GSM = "gsm";
+
+ /** GSM Microsoft variant (decoders: gsm_ms libgsm_ms) (encoders: libgsm_ms) */
+ public static final String GSM_MS = "gsm_ms";
+
+ /** CRI HCA */
+ public static final String HCA = "hca";
+
+ /** HCOM Audio */
+ public static final String HCOM = "hcom";
+
+ /** IAC (Indeo Audio Coder) */
+ public static final String IAC = "iac";
+
+ /** iLBC (Internet Low Bitrate Codec) */
+ public static final String ILBC = "ilbc";
+
+ /** IMC (Intel Music Coder) */
+ public static final String IMC = "imc";
+
+ /** DPCM Interplay */
+ public static final String INTERPLAY_DPCM = "interplay_dpcm";
+
+ /** Interplay ACM */
+ public static final String INTERPLAYACM = "interplayacm";
+
+ /** MACE (Macintosh Audio Compression/Expansion) 3:1 */
+ public static final String MACE3 = "mace3";
+
+ /** MACE (Macintosh Audio Compression/Expansion) 6:1 */
+ public static final String MACE6 = "mace6";
+
+ /** Voxware MetaSound */
+ public static final String METASOUND = "metasound";
+
+ /** Micronas SC-4 Audio */
+ public static final String MISC4 = "misc4";
+
+ /** MLP (Meridian Lossless Packing) */
+ public static final String MLP = "mlp";
+
+ /** MP1 (MPEG audio layer 1) (decoders: mp1 mp1float) */
+ public static final String MP1 = "mp1";
+
+ /** MP2 (MPEG audio layer 2) (decoders: mp2 mp2float) (encoders: mp2 mp2fixed) */
+ public static final String MP2 = "mp2";
+
+ /** MP3 (MPEG audio layer 3) (decoders: mp3float mp3) (encoders: libmp3lame mp3_mf) */
+ public static final String MP3 = "mp3";
+
+ /** ADU (Application Data Unit) MP3 (MPEG audio layer 3) (decoders: mp3adufloat mp3adu) */
+ public static final String MP3ADU = "mp3adu";
+
+ /** MP3onMP4 (decoders: mp3on4float mp3on4) */
+ public static final String MP3ON4 = "mp3on4";
+
+ /** MPEG-4 Audio Lossless Coding (ALS) (decoders: als) */
+ public static final String MP4ALS = "mp4als";
+
+ /** MPEG-H 3D Audio */
+ public static final String MPEGH_3D_AUDIO = "mpegh_3d_audio";
+
+ /** MSN Siren */
+ public static final String MSNSIREN = "msnsiren";
+
+ /** Musepack SV7 (decoders: mpc7) */
+ public static final String MUSEPACK7 = "musepack7";
+
+ /** Musepack SV8 (decoders: mpc8) */
+ public static final String MUSEPACK8 = "musepack8";
+
+ /** Nellymoser Asao */
+ public static final String NELLYMOSER = "nellymoser";
+
+ /** Opus (Opus Interactive Audio Codec) (decoders: opus libopus) (encoders: opus libopus) */
+ public static final String OPUS = "opus";
+
+ /** OSQ (Original Sound Quality) */
+ public static final String OSQ = "osq";
+
+ /** Amazing Studio Packed Animation File Audio */
+ public static final String PAF_AUDIO = "paf_audio";
+
+ /** PCM A-law / G.711 A-law */
+ public static final String PCM_ALAW = "pcm_alaw";
+
+ /** PCM signed 16|20|24-bit big-endian for Blu-ray media */
+ public static final String PCM_BLURAY = "pcm_bluray";
+
+ /** PCM signed 20|24-bit big-endian */
+ public static final String PCM_DVD = "pcm_dvd";
+
+ /** PCM 16.8 floating point little-endian */
+ public static final String PCM_F16LE = "pcm_f16le";
+
+ /** PCM 24.0 floating point little-endian */
+ public static final String PCM_F24LE = "pcm_f24le";
+
+ /** PCM 32-bit floating point big-endian */
+ public static final String PCM_F32BE = "pcm_f32be";
+
+ /** PCM 32-bit floating point little-endian */
+ public static final String PCM_F32LE = "pcm_f32le";
+
+ /** PCM 64-bit floating point big-endian */
+ public static final String PCM_F64BE = "pcm_f64be";
+
+ /** PCM 64-bit floating point little-endian */
+ public static final String PCM_F64LE = "pcm_f64le";
+
+ /** PCM signed 20-bit little-endian planar */
+ public static final String PCM_LXF = "pcm_lxf";
+
+ /** PCM mu-law / G.711 mu-law */
+ public static final String PCM_MULAW = "pcm_mulaw";
+
+ /** PCM signed 16-bit big-endian */
+ public static final String PCM_S16BE = "pcm_s16be";
+
+ /** PCM signed 16-bit big-endian planar */
+ public static final String PCM_S16BE_PLANAR = "pcm_s16be_planar";
+
+ /** PCM signed 16-bit little-endian */
+ public static final String PCM_S16LE = "pcm_s16le";
+
+ /** PCM signed 16-bit little-endian planar */
+ public static final String PCM_S16LE_PLANAR = "pcm_s16le_planar";
+
+ /** PCM signed 24-bit big-endian */
+ public static final String PCM_S24BE = "pcm_s24be";
+
+ /** PCM D-Cinema audio signed 24-bit */
+ public static final String PCM_S24DAUD = "pcm_s24daud";
+
+ /** PCM signed 24-bit little-endian */
+ public static final String PCM_S24LE = "pcm_s24le";
+
+ /** PCM signed 24-bit little-endian planar */
+ public static final String PCM_S24LE_PLANAR = "pcm_s24le_planar";
+
+ /** PCM signed 32-bit big-endian */
+ public static final String PCM_S32BE = "pcm_s32be";
+
+ /** PCM signed 32-bit little-endian */
+ public static final String PCM_S32LE = "pcm_s32le";
+
+ /** PCM signed 32-bit little-endian planar */
+ public static final String PCM_S32LE_PLANAR = "pcm_s32le_planar";
+
+ /** PCM signed 64-bit big-endian */
+ public static final String PCM_S64BE = "pcm_s64be";
+
+ /** PCM signed 64-bit little-endian */
+ public static final String PCM_S64LE = "pcm_s64le";
+
+ /** PCM signed 8-bit */
+ public static final String PCM_S8 = "pcm_s8";
+
+ /** PCM signed 8-bit planar */
+ public static final String PCM_S8_PLANAR = "pcm_s8_planar";
+
+ /** PCM SGA */
+ public static final String PCM_SGA = "pcm_sga";
+
+ /** PCM unsigned 16-bit big-endian */
+ public static final String PCM_U16BE = "pcm_u16be";
+
+ /** PCM unsigned 16-bit little-endian */
+ public static final String PCM_U16LE = "pcm_u16le";
+
+ /** PCM unsigned 24-bit big-endian */
+ public static final String PCM_U24BE = "pcm_u24be";
+
+ /** PCM unsigned 24-bit little-endian */
+ public static final String PCM_U24LE = "pcm_u24le";
+
+ /** PCM unsigned 32-bit big-endian */
+ public static final String PCM_U32BE = "pcm_u32be";
+
+ /** PCM unsigned 32-bit little-endian */
+ public static final String PCM_U32LE = "pcm_u32le";
+
+ /** PCM unsigned 8-bit */
+ public static final String PCM_U8 = "pcm_u8";
+
+ /** PCM Archimedes VIDC */
+ public static final String PCM_VIDC = "pcm_vidc";
+
+ /** QCELP / PureVoice */
+ public static final String QCELP = "qcelp";
+
+ /** QDesign Music Codec 2 */
+ public static final String QDM2 = "qdm2";
+
+ /** QDesign Music */
+ public static final String QDMC = "qdmc";
+
+ /** RealAudio 1.0 (14.4K) (decoders: real_144) (encoders: real_144) */
+ public static final String RA_144 = "ra_144";
+
+ /** RealAudio 2.0 (28.8K) (decoders: real_288) */
+ public static final String RA_288 = "ra_288";
+
+ /** RealAudio Lossless */
+ public static final String RALF = "ralf";
+
+ /** RKA (RK Audio) */
+ public static final String RKA = "rka";
+
+ /** DPCM id RoQ */
+ public static final String ROQ_DPCM = "roq_dpcm";
+
+ /** SMPTE 302M */
+ public static final String S302M = "s302m";
+
+ /** SBC (low-complexity subband codec) */
+ public static final String SBC = "sbc";
+
+ /** DPCM Squareroot-Delta-Exact */
+ public static final String SDX2_DPCM = "sdx2_dpcm";
+
+ /** Shorten */
+ public static final String SHORTEN = "shorten";
+
+ /** RealAudio SIPR / ACELP.NET */
+ public static final String SIPR = "sipr";
+
+ /** Siren */
+ public static final String SIREN = "siren";
+
+ /** Smacker audio (decoders: smackaud) */
+ public static final String SMACKAUDIO = "smackaudio";
+
+ /** SMV (Selectable Mode Vocoder) */
+ public static final String SMV = "smv";
+
+ /** DPCM Sol */
+ public static final String SOL_DPCM = "sol_dpcm";
+
+ /** Sonic */
+ public static final String SONIC = "sonic";
+
+ /** Sonic lossless */
+ public static final String SONICLS = "sonicls";
+
+ /** Speex (decoders: speex libspeex) (encoders: libspeex) */
+ public static final String SPEEX = "speex";
+
+ /** TAK (Tom's lossless Audio Kompressor) */
+ public static final String TAK = "tak";
+
+ /** TrueHD */
+ public static final String TRUEHD = "truehd";
+
+ /** DSP Group TrueSpeech */
+ public static final String TRUESPEECH = "truespeech";
+
+ /** TTA (True Audio) */
+ public static final String TTA = "tta";
+
+ /** VQF TwinVQ */
+ public static final String TWINVQ = "twinvq";
+
+ /** Sierra VMD audio */
+ public static final String VMDAUDIO = "vmdaudio";
+
+ /** Vorbis (decoders: vorbis libvorbis) (encoders: vorbis libvorbis) */
+ public static final String VORBIS = "vorbis";
+
+ /** DPCM Marble WADY */
+ public static final String WADY_DPCM = "wady_dpcm";
+
+ /** Waveform Archiver */
+ public static final String WAVARC = "wavarc";
+
+ /** Wave synthesis pseudo-codec */
+ public static final String WAVESYNTH = "wavesynth";
+
+ /** WavPack */
+ public static final String WAVPACK = "wavpack";
+
+ /** Westwood Audio (SND1) (decoders: ws_snd1) */
+ public static final String WESTWOOD_SND1 = "westwood_snd1";
+
+ /** Windows Media Audio Lossless */
+ public static final String WMALOSSLESS = "wmalossless";
+
+ /** Windows Media Audio 9 Professional */
+ public static final String WMAPRO = "wmapro";
+
+ /** Windows Media Audio 1 */
+ public static final String WMAV1 = "wmav1";
+
+ /** Windows Media Audio 2 */
+ public static final String WMAV2 = "wmav2";
+
+ /** Windows Media Audio Voice */
+ public static final String WMAVOICE = "wmavoice";
+
+ /** DPCM Xan */
+ public static final String XAN_DPCM = "xan_dpcm";
+
+ /** Xbox Media Audio 1 */
+ public static final String XMA1 = "xma1";
+
+ /** Xbox Media Audio 2 */
+ public static final String XMA2 = "xma2";
+}
diff --git a/src/main/java/net/bramp/ffmpeg/builder/FFmpegBuilder.java b/src/main/java/net/bramp/ffmpeg/builder/FFmpegBuilder.java
index faaeb193..89f41fa6 100644
--- a/src/main/java/net/bramp/ffmpeg/builder/FFmpegBuilder.java
+++ b/src/main/java/net/bramp/ffmpeg/builder/FFmpegBuilder.java
@@ -1,22 +1,24 @@
package net.bramp.ffmpeg.builder;
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static net.bramp.ffmpeg.Preconditions.checkNotEmpty;
+
+import com.google.common.base.Ascii;
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableList;
-import net.bramp.ffmpeg.FFmpegUtils;
-import net.bramp.ffmpeg.probe.FFmpegProbeResult;
-
-import javax.annotation.CheckReturnValue;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import java.util.concurrent.TimeUnit;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-import static net.bramp.ffmpeg.Preconditions.checkNotEmpty;
+import javax.annotation.CheckReturnValue;
+import net.bramp.ffmpeg.FFmpegUtils;
+import net.bramp.ffmpeg.probe.FFmpegProbeResult;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Builds a ffmpeg command line
@@ -25,21 +27,12 @@
*/
public class FFmpegBuilder {
- public enum Strict {
- VERY, // strictly conform to a older more strict version of the specifications or reference software
- STRICT, // strictly conform to all the things in the specificiations no matter what consequences
- NORMAL, // normal
- UNOFFICAL, // allow unofficial extensions
- EXPERIMENTAL;
-
- // ffmpeg command line requires these options in lower case
- @Override
- public String toString() {
- return name().toLowerCase();
- }
- }
+ private static final Logger log = LoggerFactory.getLogger(FFmpegBuilder.class);
- /** Log level options: https://ffmpeg.org/ffmpeg.html#Generic-options */
+ /**
+ * Log level options: ffmpeg
+ * documentation
+ */
public enum Verbosity {
QUIET,
PANIC,
@@ -52,7 +45,8 @@ public enum Verbosity {
@Override
public String toString() {
- return name().toLowerCase();
+ // ffmpeg command line requires these options in lower case
+ return Ascii.toLowerCase(name());
}
}
@@ -64,24 +58,33 @@ public String toString() {
Verbosity verbosity = Verbosity.ERROR;
URI progress;
String user_agent;
+ Integer qscale;
+ int threads;
// Input settings
String format;
Long startOffset; // in millis
boolean read_at_native_frame_rate = false;
- final List
+ *
+ *
+ *
+ *
+ * @param filename output file path
+ * @return A new {@link FFmpegHlsOutputBuilder}
+ */
+ public FFmpegHlsOutputBuilder addHlsOutput(String filename) {
+ FFmpegHlsOutputBuilder output = new FFmpegHlsOutputBuilder(this, filename);
+ outputs.add(output);
+ return output;
+ }
+
/**
* Adds an existing FFmpegOutputBuilder. This is similar to calling the other addOuput methods but
* instead allows an existing FFmpegOutputBuilder to be used, and reused.
@@ -273,11 +360,15 @@ public FFmpegOutputBuilder addStdoutOutput() {
@CheckReturnValue
public ListList<String> args = new FFmpegBuilder()
+ * .addHlsOutput("output.m3u8")
+ * .done().build();
+ *
+ *
+ * "file%03d.ts" segment files: file000.ts, file001.ts, file002.ts, etc.
+ *
+ * @param filename hls_segment_file_name to set
+ * @return {@link FFmpegHlsOutputBuilder}
+ */
+ public FFmpegHlsOutputBuilder setHlsSegmentFileName(String filename) {
+ this.hls_segment_filename = checkNotEmpty(filename, "filename must not be empty");
+
+ return this;
+ }
+
+ /**
+ * Segment will be cut on the next key frame after this time has passed on the first m3u8
+ * list.
+ *
+ * @param duration hls_init_time to set
+ * @param units The units the offset is in
+ * @return {@link FFmpegHlsOutputBuilder}
+ */
+ public FFmpegHlsOutputBuilder setHlsInitTime(long duration, TimeUnit units) {
+ checkNotNull(units);
+ this.hls_init_time = units.toMillis(duration);
+
+ return this;
+ }
+
+ /**
+ * Set the maximum number of playlist entries. If set to 0 the list file will contain all
+ * the segments .
+ * Default value is 5
+ *
+ * @param size hls_time to set
+ * @return {@link FFmpegHlsOutputBuilder}
+ */
+ public FFmpegHlsOutputBuilder setHlsListSize(int size) {
+ checkArgument(size >= 0, "Size cannot be less than 0.");
+ this.hls_list_size = size;
+
+ return this;
+ }
+
+ /**
+ * Append baseurl to every entry in the playlist. Useful to generate playlists with
+ * absolute paths.
+ * Note that the playlist sequence number must be unique for each segment and it is not to be
+ * confused with the segment filename sequence number which can be cyclic, for example if the wrap
+ * option is specified.
+ *
+ * @param baseurl hls_base_url to set
+ * @return {@link FFmpegHlsOutputBuilder}
+ */
+ public FFmpegHlsOutputBuilder setHlsBaseUrl(String baseurl) {
+ this.hls_base_url = checkNotEmpty(baseurl, "baseurl must not be empty");
+
+ return this;
+ }
+
+ @Override
+ protected void addFormatArgs(ImmutableList.Builder
+ * you can get a list of available codecs through use {@link net.bramp.ffmpeg.FFmpeg#codecs()}.
+ *
+ * @see net.bramp.ffmpeg.FFmpeg#codecs()
+ * @author van1164
+ */
+public class VideoCodec {
+
+ /** Uncompressed 4:2:2 10-bit */
+ public static final String V = "012v";
+
+ /** 4X Movie */
+ public static final String XM = "4xm";
+
+ /** QuickTime 8BPS video */
+ public static final String BPS = "8bps";
+
+ /** Multicolor charset for Commodore 64 (encoders: a64multi) */
+ public static final String A64_MULTI = "a64_multi";
+
+ /** Multicolor charset for Commodore 64, extended with 5th color (colram) (encoders: a64multi5) */
+ public static final String A64_MULTI5 = "a64_multi5";
+
+ /** Autodesk RLE */
+ public static final String AASC = "aasc";
+
+ /** Amuse Graphics Movie */
+ public static final String AGM = "agm";
+
+ /** Apple Intermediate Codec */
+ public static final String AIC = "aic";
+
+ /** Alias/Wavefront PIX image */
+ public static final String ALIAS_PIX = "alias_pix";
+
+ /** AMV Video */
+ public static final String AMV = "amv";
+
+ /** Deluxe Paint Animation */
+ public static final String ANM = "anm";
+
+ /** ASCII/ANSI art */
+ public static final String ANSI = "ansi";
+
+ /** APNG (Animated Portable Network Graphics) image */
+ public static final String APNG = "apng";
+
+ /** Gryphon's Anim Compressor */
+ public static final String ARBC = "arbc";
+
+ /** Argonaut Games Video */
+ public static final String ARGO = "argo";
+
+ /** ASUS V1 */
+ public static final String ASV1 = "asv1";
+
+ /** ASUS V2 */
+ public static final String ASV2 = "asv2";
+
+ /** Auravision AURA */
+ public static final String AURA = "aura";
+
+ /** Auravision Aura 2 */
+ public static final String AURA2 = "aura2";
+
+ /**
+ * Alliance for Open Media AV1 (decoders: libaom-av1 av1 av1_cuvid av1_qsv) (encoders: libaom-av1
+ * av1_nvenc av1_qsv av1_amf)
+ */
+ public static final String AV1 = "av1";
+
+ /** Avid AVI Codec */
+ public static final String AVRN = "avrn";
+
+ /** Avid 1:1 10-bit RGB Packer */
+ public static final String AVRP = "avrp";
+
+ /** AVS (Audio Video Standard) video */
+ public static final String AVS = "avs";
+
+ /** AVS2-P2/IEEE1857.4 */
+ public static final String AVS2 = "avs2";
+
+ /** AVS3-P2/IEEE1857.10 */
+ public static final String AVS3 = "avs3";
+
+ /** Avid Meridien Uncompressed */
+ public static final String AVUI = "avui";
+
+ /** Uncompressed packed MS 4:4:4:4 */
+ public static final String AYUV = "ayuv";
+
+ /** Bethesda VID video */
+ public static final String BETHSOFTVID = "bethsoftvid";
+
+ /** Brute Force & Ignorance */
+ public static final String BFI = "bfi";
+
+ /** Bink video */
+ public static final String BINKVIDEO = "binkvideo";
+
+ /** Binary text */
+ public static final String BINTEXT = "bintext";
+
+ /** Bitpacked */
+ public static final String BITPACKED = "bitpacked";
+
+ /** BMP (Windows and OS/2 bitmap) */
+ public static final String BMP = "bmp";
+
+ /** Discworld II BMV video */
+ public static final String BMV_VIDEO = "bmv_video";
+
+ /** BRender PIX image */
+ public static final String BRENDER_PIX = "brender_pix";
+
+ /** Interplay C93 */
+ public static final String C93 = "c93";
+
+ /** Chinese AVS (Audio Video Standard) (AVS1-P2, JiZhun profile) */
+ public static final String CAVS = "cavs";
+
+ /** CD Graphics video */
+ public static final String CDGRAPHICS = "cdgraphics";
+
+ /** CDToons video */
+ public static final String CDTOONS = "cdtoons";
+
+ /** Commodore CDXL video */
+ public static final String CDXL = "cdxl";
+
+ /** GoPro CineForm HD */
+ public static final String CFHD = "cfhd";
+
+ /** Cinepak */
+ public static final String CINEPAK = "cinepak";
+
+ /** Iterated Systems ClearVideo */
+ public static final String CLEARVIDEO = "clearvideo";
+
+ /** Cirrus Logic AccuPak */
+ public static final String CLJR = "cljr";
+
+ /** Canopus Lossless Codec */
+ public static final String CLLC = "cllc";
+
+ /** Electronic Arts CMV video (decoders: eacmv) */
+ public static final String CMV = "cmv";
+
+ /** CPiA video format */
+ public static final String CPIA = "cpia";
+
+ /** Cintel RAW */
+ public static final String CRI = "cri";
+
+ /** CamStudio (decoders: camstudio) */
+ public static final String CSCD = "cscd";
+
+ /** Creative YUV (CYUV) */
+ public static final String CYUV = "cyuv";
+
+ /** Daala */
+ public static final String DAALA = "daala";
+
+ /** DirectDraw Surface image decoder */
+ public static final String DDS = "dds";
+
+ /** Chronomaster DFA */
+ public static final String DFA = "dfa";
+
+ /** Dirac (encoders: vc2) */
+ public static final String DIRAC = "dirac";
+
+ /** VC3/DNxHD */
+ public static final String DNXHD = "dnxhd";
+
+ /** DPX (Digital Picture Exchange) image */
+ public static final String DPX = "dpx";
+
+ /** Delphine Software International CIN video */
+ public static final String DSICINVIDEO = "dsicinvideo";
+
+ /** DV (Digital Video) */
+ public static final String DVVIDEO = "dvvideo";
+
+ /** Feeble Files/ScummVM DXA */
+ public static final String DXA = "dxa";
+
+ /** Dxtory */
+ public static final String DXTORY = "dxtory";
+
+ /** Resolume DXV */
+ public static final String DXV = "dxv";
+
+ /** Escape 124 */
+ public static final String ESCAPE124 = "escape124";
+
+ /** Escape 130 */
+ public static final String ESCAPE130 = "escape130";
+
+ /** MPEG-5 EVC (Essential Video Coding) */
+ public static final String EVC = "evc";
+
+ /** OpenEXR image */
+ public static final String EXR = "exr";
+
+ /** FFmpeg video codec #1 */
+ public static final String FFV1 = "ffv1";
+
+ /** Huffyuv FFmpeg variant */
+ public static final String FFVHUFF = "ffvhuff";
+
+ /** Mirillis FIC */
+ public static final String FIC = "fic";
+
+ /** FITS (Flexible Image Transport System) */
+ public static final String FITS = "fits";
+
+ /** Flash Screen Video v1 */
+ public static final String FLASHSV = "flashsv";
+
+ /** Flash Screen Video v2 */
+ public static final String FLASHSV2 = "flashsv2";
+
+ /** Autodesk Animator Flic video */
+ public static final String FLIC = "flic";
+
+ /** FLV / Sorenson Spark / Sorenson H.263 (Flash Video) (decoders: flv) (encoders: flv) */
+ public static final String FLV1 = "flv1";
+
+ /** FM Screen Capture Codec */
+ public static final String FMVC = "fmvc";
+
+ /** Fraps */
+ public static final String FRAPS = "fraps";
+
+ /** Forward Uncompressed */
+ public static final String FRWU = "frwu";
+
+ /** Go2Meeting */
+ public static final String G2M = "g2m";
+
+ /** Gremlin Digital Video */
+ public static final String GDV = "gdv";
+
+ /** GEM Raster image */
+ public static final String GEM = "gem";
+
+ /** CompuServe GIF (Graphics Interchange Format) */
+ public static final String GIF = "gif";
+
+ /** H.261 */
+ public static final String H261 = "h261";
+
+ /** H.263 / H.263-1996, H.263+ / H.263-1998 / H.263 version 2 */
+ public static final String H263 = "h263";
+
+ /** Intel H.263 */
+ public static final String H263I = "h263i";
+
+ /** H.263+ / H.263-1998 / H.263 version 2 */
+ public static final String H263P = "h263p";
+
+ /**
+ * H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (decoders: h264 h264_qsv h264_cuvid) (encoders:
+ * libx264 libx264rgb h264_amf h264_mf h264_nvenc h264_qsv)
+ */
+ public static final String H264 = "h264";
+
+ /** Vidvox Hap */
+ public static final String HAP = "hap";
+
+ /** HDR (Radiance RGBE format) image */
+ public static final String HDR = "hdr";
+
+ /**
+ * H.265 / HEVC (High Efficiency Video Coding) (decoders: hevc hevc_qsv hevc_cuvid) (encoders:
+ * libx265 hevc_amf hevc_mf hevc_nvenc hevc_qsv)
+ */
+ public static final String HEVC = "hevc";
+
+ /** HNM 4 video */
+ public static final String HNM4VIDEO = "hnm4video";
+
+ /** Canopus HQ/HQA */
+ public static final String HQ_HQA = "hq_hqa";
+
+ /** Canopus HQX */
+ public static final String HQX = "hqx";
+
+ /** HuffYUV */
+ public static final String HUFFYUV = "huffyuv";
+
+ /** HuffYUV MT */
+ public static final String HYMT = "hymt";
+
+ /** id Quake II CIN video (decoders: idcinvideo) */
+ public static final String IDCIN = "idcin";
+
+ /** iCEDraw text */
+ public static final String IDF = "idf";
+
+ /** IFF ACBM/ANIM/DEEP/ILBM/PBM/RGB8/RGBN (decoders: iff) */
+ public static final String IFF_ILBM = "iff_ilbm";
+
+ /** Infinity IMM4 */
+ public static final String IMM4 = "imm4";
+
+ /** Infinity IMM5 */
+ public static final String IMM5 = "imm5";
+
+ /** Intel Indeo 2 */
+ public static final String INDEO2 = "indeo2";
+
+ /** Intel Indeo 3 */
+ public static final String INDEO3 = "indeo3";
+
+ /** Intel Indeo Video Interactive 4 */
+ public static final String INDEO4 = "indeo4";
+
+ /** Intel Indeo Video Interactive 5 */
+ public static final String INDEO5 = "indeo5";
+
+ /** Interplay MVE video */
+ public static final String INTERPLAYVIDEO = "interplayvideo";
+
+ /** IPU Video */
+ public static final String IPU = "ipu";
+
+ /** JPEG 2000 (encoders: jpeg2000 libopenjpeg) */
+ public static final String JPEG2000 = "jpeg2000";
+
+ /** JPEG-LS */
+ public static final String JPEGLS = "jpegls";
+
+ /** JPEG XL */
+ public static final String JPEGXL = "jpegxl";
+
+ /** Bitmap Brothers JV video */
+ public static final String JV = "jv";
+
+ /** Kega Game Video */
+ public static final String KGV1 = "kgv1";
+
+ /** Karl Morton's video codec */
+ public static final String KMVC = "kmvc";
+
+ /** Lagarith lossless */
+ public static final String LAGARITH = "lagarith";
+
+ /** Lossless JPEG */
+ public static final String LJPEG = "ljpeg";
+
+ /** LOCO */
+ public static final String LOCO = "loco";
+
+ /** LEAD Screen Capture */
+ public static final String LSCR = "lscr";
+
+ /** Matrox Uncompressed SD */
+ public static final String M101 = "m101";
+
+ /** Electronic Arts Madcow Video (decoders: eamad) */
+ public static final String MAD = "mad";
+
+ /** MagicYUV video */
+ public static final String MAGICYUV = "magicyuv";
+
+ /** Sony PlayStation MDEC (Motion DECoder) */
+ public static final String MDEC = "mdec";
+
+ /** Media 100i */
+ public static final String MEDIA100 = "media100";
+
+ /** Mimic */
+ public static final String MIMIC = "mimic";
+
+ /** Motion JPEG (decoders: mjpeg mjpeg_cuvid mjpeg_qsv) (encoders: mjpeg mjpeg_qsv) */
+ public static final String MJPEG = "mjpeg";
+
+ /** Apple MJPEG-B */
+ public static final String MJPEGB = "mjpegb";
+
+ /** American Laser Games MM Video */
+ public static final String MMVIDEO = "mmvideo";
+
+ /** MobiClip Video */
+ public static final String MOBICLIP = "mobiclip";
+
+ /** Motion Pixels video */
+ public static final String MOTIONPIXELS = "motionpixels";
+
+ /** MPEG-1 video (decoders: mpeg1video mpeg1_cuvid) */
+ public static final String MPEG1VIDEO = "mpeg1video";
+
+ /**
+ * MPEG-2 video (decoders: mpeg2video mpegvideo mpeg2_qsv mpeg2_cuvid) (encoders: mpeg2video
+ * mpeg2_qsv)
+ */
+ public static final String MPEG2VIDEO = "mpeg2video";
+
+ /** MPEG-4 part 2 (decoders: mpeg4 mpeg4_cuvid) (encoders: mpeg4 libxvid) */
+ public static final String MPEG4 = "mpeg4";
+
+ /** MS ATC Screen */
+ public static final String MSA1 = "msa1";
+
+ /** Mandsoft Screen Capture Codec */
+ public static final String MSCC = "mscc";
+
+ /** MPEG-4 part 2 Microsoft variant version 1 */
+ public static final String MSMPEG4V1 = "msmpeg4v1";
+
+ /** MPEG-4 part 2 Microsoft variant version 2 */
+ public static final String MSMPEG4V2 = "msmpeg4v2";
+
+ /** MPEG-4 part 2 Microsoft variant version 3 (decoders: msmpeg4) (encoders: msmpeg4) */
+ public static final String MSMPEG4V3 = "msmpeg4v3";
+
+ /** Microsoft Paint (MSP) version 2 */
+ public static final String MSP2 = "msp2";
+
+ /** Microsoft RLE */
+ public static final String MSRLE = "msrle";
+
+ /** MS Screen 1 */
+ public static final String MSS1 = "mss1";
+
+ /** MS Windows Media Video V9 Screen */
+ public static final String MSS2 = "mss2";
+
+ /** Microsoft Video 1 */
+ public static final String MSVIDEO1 = "msvideo1";
+
+ /** LCL (LossLess Codec Library) MSZH */
+ public static final String MSZH = "mszh";
+
+ /** MS Expression Encoder Screen */
+ public static final String MTS2 = "mts2";
+
+ /** MidiVid 3.0 */
+ public static final String MV30 = "mv30";
+
+ /** Silicon Graphics Motion Video Compressor 1 */
+ public static final String MVC1 = "mvc1";
+
+ /** Silicon Graphics Motion Video Compressor 2 */
+ public static final String MVC2 = "mvc2";
+
+ /** MidiVid VQ */
+ public static final String MVDV = "mvdv";
+
+ /** MidiVid Archive Codec */
+ public static final String MVHA = "mvha";
+
+ /** MatchWare Screen Capture Codec */
+ public static final String MWSC = "mwsc";
+
+ /** Mobotix MxPEG video */
+ public static final String MXPEG = "mxpeg";
+
+ /** NotchLC */
+ public static final String NOTCHLC = "notchlc";
+
+ /** NuppelVideo/RTJPEG */
+ public static final String NUV = "nuv";
+
+ /** Amazing Studio Packed Animation File Video */
+ public static final String PAF_VIDEO = "paf_video";
+
+ /** PAM (Portable AnyMap) image */
+ public static final String PAM = "pam";
+
+ /** PBM (Portable BitMap) image */
+ public static final String PBM = "pbm";
+
+ /** PC Paintbrush PCX image */
+ public static final String PCX = "pcx";
+
+ /** PDV (PlayDate Video) */
+ public static final String PDV = "pdv";
+
+ /** PFM (Portable FloatMap) image */
+ public static final String PFM = "pfm";
+
+ /** PGM (Portable GrayMap) image */
+ public static final String PGM = "pgm";
+
+ /** PGMYUV (Portable GrayMap YUV) image */
+ public static final String PGMYUV = "pgmyuv";
+
+ /** PGX (JPEG2000 Test Format) */
+ public static final String PGX = "pgx";
+
+ /** PHM (Portable HalfFloatMap) image */
+ public static final String PHM = "phm";
+
+ /** Kodak Photo CD */
+ public static final String PHOTOCD = "photocd";
+
+ /** Pictor/PC Paint */
+ public static final String PICTOR = "pictor";
+
+ /** Apple Pixlet */
+ public static final String PIXLET = "pixlet";
+
+ /** PNG (Portable Network Graphics) image */
+ public static final String PNG = "png";
+
+ /** PPM (Portable PixelMap) image */
+ public static final String PPM = "ppm";
+
+ /** Apple ProRes (iCodec Pro) (encoders: prores prores_aw prores_ks) */
+ public static final String PRORES = "prores";
+
+ /** Brooktree ProSumer Video */
+ public static final String PROSUMER = "prosumer";
+
+ /** Photoshop PSD file */
+ public static final String PSD = "psd";
+
+ /** V.Flash PTX image */
+ public static final String PTX = "ptx";
+
+ /** Apple QuickDraw */
+ public static final String QDRAW = "qdraw";
+
+ /** QOI (Quite OK Image) */
+ public static final String QOI = "qoi";
+
+ /** Q-team QPEG */
+ public static final String QPEG = "qpeg";
+
+ /** QuickTime Animation (RLE) video */
+ public static final String QTRLE = "qtrle";
+
+ /** AJA Kona 10-bit RGB Codec */
+ public static final String R10K = "r10k";
+
+ /** Uncompressed RGB 10-bit */
+ public static final String R210 = "r210";
+
+ /** RemotelyAnywhere Screen Capture */
+ public static final String RASC = "rasc";
+
+ /** raw video */
+ public static final String RAWVIDEO = "rawvideo";
+
+ /** RL2 video */
+ public static final String RL2 = "rl2";
+
+ /** id RoQ video (decoders: roqvideo) (encoders: roqvideo) */
+ public static final String ROQ = "roq";
+
+ /** QuickTime video (RPZA) */
+ public static final String RPZA = "rpza";
+
+ /** innoHeim/Rsupport Screen Capture Codec */
+ public static final String RSCC = "rscc";
+
+ /** RTV1 (RivaTuner Video) */
+ public static final String RTV1 = "rtv1";
+
+ /** RealVideo 1.0 */
+ public static final String RV10 = "rv10";
+
+ /** RealVideo 2.0 */
+ public static final String RV20 = "rv20";
+
+ /** RealVideo 3.0 */
+ public static final String RV30 = "rv30";
+
+ /** RealVideo 4.0 */
+ public static final String RV40 = "rv40";
+
+ /** LucasArts SANM/SMUSH video */
+ public static final String SANM = "sanm";
+
+ /** ScreenPressor */
+ public static final String SCPR = "scpr";
+
+ /** Screenpresso */
+ public static final String SCREENPRESSO = "screenpresso";
+
+ /** Digital Pictures SGA Video */
+ public static final String SGA = "sga";
+
+ /** SGI image */
+ public static final String SGI = "sgi";
+
+ /** SGI RLE 8-bit */
+ public static final String SGIRLE = "sgirle";
+
+ /** BitJazz SheerVideo */
+ public static final String SHEERVIDEO = "sheervideo";
+
+ /** Simbiosis Interactive IMX Video */
+ public static final String SIMBIOSIS_IMX = "simbiosis_imx";
+
+ /** Smacker video (decoders: smackvid) */
+ public static final String SMACKVIDEO = "smackvideo";
+
+ /** QuickTime Graphics (SMC) */
+ public static final String SMC = "smc";
+
+ /** Sigmatel Motion Video */
+ public static final String SMVJPEG = "smvjpeg";
+
+ /** Snow */
+ public static final String SNOW = "snow";
+
+ /** Sunplus JPEG (SP5X) */
+ public static final String SP5X = "sp5x";
+
+ /** NewTek SpeedHQ */
+ public static final String SPEEDHQ = "speedhq";
+
+ /** Screen Recorder Gold Codec */
+ public static final String SRGC = "srgc";
+
+ /** Sun Rasterfile image */
+ public static final String SUNRAST = "sunrast";
+
+ /** Scalable Vector Graphics */
+ public static final String SVG = "svg";
+
+ /** Sorenson Vector Quantizer 1 / Sorenson Video 1 / SVQ1 */
+ public static final String SVQ1 = "svq1";
+
+ /** Sorenson Vector Quantizer 3 / Sorenson Video 3 / SVQ3 */
+ public static final String SVQ3 = "svq3";
+
+ /** Truevision Targa image */
+ public static final String TARGA = "targa";
+
+ /** Pinnacle TARGA CineWave YUV16 */
+ public static final String TARGA_Y216 = "targa_y216";
+
+ /** TDSC */
+ public static final String TDSC = "tdsc";
+
+ /** Electronic Arts TGQ video (decoders: eatgq) */
+ public static final String TGQ = "tgq";
+
+ /** Electronic Arts TGV video (decoders: eatgv) */
+ public static final String TGV = "tgv";
+
+ /** Theora (encoders: libtheora) */
+ public static final String THEORA = "theora";
+
+ /** Nintendo Gamecube THP video */
+ public static final String THP = "thp";
+
+ /** Tiertex Limited SEQ video */
+ public static final String TIERTEXSEQVIDEO = "tiertexseqvideo";
+
+ /** TIFF image */
+ public static final String TIFF = "tiff";
+
+ /** 8088flex TMV */
+ public static final String TMV = "tmv";
+
+ /** Electronic Arts TQI video (decoders: eatqi) */
+ public static final String TQI = "tqi";
+
+ /** Duck TrueMotion 1.0 */
+ public static final String TRUEMOTION1 = "truemotion1";
+
+ /** Duck TrueMotion 2.0 */
+ public static final String TRUEMOTION2 = "truemotion2";
+
+ /** Duck TrueMotion 2.0 Real Time */
+ public static final String TRUEMOTION2RT = "truemotion2rt";
+
+ /** TechSmith Screen Capture Codec (decoders: camtasia) */
+ public static final String TSCC = "tscc";
+
+ /** TechSmith Screen Codec 2 */
+ public static final String TSCC2 = "tscc2";
+
+ /** Renderware TXD (TeXture Dictionary) image */
+ public static final String TXD = "txd";
+
+ /** IBM UltiMotion (decoders: ultimotion) */
+ public static final String ULTI = "ulti";
+
+ /** Ut Video */
+ public static final String UTVIDEO = "utvideo";
+
+ /** Uncompressed 4:2:2 10-bit */
+ public static final String V210 = "v210";
+
+ /** Uncompressed 4:2:2 10-bit */
+ public static final String V210X = "v210x";
+
+ /** Uncompressed packed 4:4:4 */
+ public static final String V308 = "v308";
+
+ /** Uncompressed packed QT 4:4:4:4 */
+ public static final String V408 = "v408";
+
+ /** Uncompressed 4:4:4 10-bit */
+ public static final String V410 = "v410";
+
+ /** Beam Software VB */
+ public static final String VB = "vb";
+
+ /** VBLE Lossless Codec */
+ public static final String VBLE = "vble";
+
+ /** Vizrt Binary Image */
+ public static final String VBN = "vbn";
+
+ /** SMPTE VC-1 (decoders: vc1 vc1_qsv vc1_cuvid) */
+ public static final String VC1 = "vc1";
+
+ /** Windows Media Video 9 Image v2 */
+ public static final String VC1IMAGE = "vc1image";
+
+ /** ATI VCR1 */
+ public static final String VCR1 = "vcr1";
+
+ /** Miro VideoXL (decoders: xl) */
+ public static final String VIXL = "vixl";
+
+ /** Sierra VMD video */
+ public static final String VMDVIDEO = "vmdvideo";
+
+ /** vMix Video */
+ public static final String VMIX = "vmix";
+
+ /** VMware Screen Codec / VMware Video */
+ public static final String VMNC = "vmnc";
+
+ /** Null video codec */
+ public static final String VNULL = "vnull";
+
+ /** On2 VP3 */
+ public static final String VP3 = "vp3";
+
+ /** On2 VP4 */
+ public static final String VP4 = "vp4";
+
+ /** On2 VP5 */
+ public static final String VP5 = "vp5";
+
+ /** On2 VP6 */
+ public static final String VP6 = "vp6";
+
+ /** On2 VP6 (Flash version, with alpha channel) */
+ public static final String VP6A = "vp6a";
+
+ /** On2 VP6 (Flash version) */
+ public static final String VP6F = "vp6f";
+
+ /** On2 VP7 */
+ public static final String VP7 = "vp7";
+
+ /** On2 VP8 (decoders: vp8 libvpx vp8_cuvid vp8_qsv) (encoders: libvpx) */
+ public static final String VP8 = "vp8";
+
+ /** Google VP9 (decoders: vp9 libvpx-vp9 vp9_cuvid vp9_qsv) (encoders: libvpx-vp9 vp9_qsv) */
+ public static final String VP9 = "vp9";
+
+ /** ViewQuest VQC */
+ public static final String VQC = "vqc";
+
+ /** H.266 / VVC (Versatile Video Coding) */
+ public static final String VVC = "vvc";
+
+ /** WBMP (Wireless Application Protocol Bitmap) image */
+ public static final String WBMP = "wbmp";
+
+ /** WinCAM Motion Video */
+ public static final String WCMV = "wcmv";
+
+ /** WebP (encoders: libwebp_anim libwebp) */
+ public static final String WEBP = "webp";
+
+ /** Windows Media Video 7 */
+ public static final String WMV1 = "wmv1";
+
+ /** Windows Media Video 8 */
+ public static final String WMV2 = "wmv2";
+
+ /** Windows Media Video 9 */
+ public static final String WMV3 = "wmv3";
+
+ /** Windows Media Video 9 Image */
+ public static final String WMV3IMAGE = "wmv3image";
+
+ /** Winnov WNV1 */
+ public static final String WNV1 = "wnv1";
+
+ /** AVFrame to AVPacket passthrough */
+ public static final String WRAPPED_AVFRAME = "wrapped_avframe";
+
+ /** Westwood Studios VQA (Vector Quantized Animation) video (decoders: vqavideo) */
+ public static final String WS_VQA = "ws_vqa";
+
+ /** Wing Commander III / Xan */
+ public static final String XAN_WC3 = "xan_wc3";
+
+ /** Wing Commander IV / Xxan */
+ public static final String XAN_WC4 = "xan_wc4";
+
+ /** eXtended BINary text */
+ public static final String XBIN = "xbin";
+
+ /** XBM (X BitMap) image */
+ public static final String XBM = "xbm";
+
+ /** X-face image */
+ public static final String XFACE = "xface";
+
+ /** XPM (X PixMap) image */
+ public static final String XPM = "xpm";
+
+ /** XWD (X Window Dump) image */
+ public static final String XWD = "xwd";
+
+ /** Uncompressed YUV 4:1:1 12-bit */
+ public static final String Y41P = "y41p";
+
+ /** YUY2 Lossless Codec */
+ public static final String YLC = "ylc";
+
+ /** Psygnosis YOP Video */
+ public static final String YOP = "yop";
+
+ /** Uncompressed packed 4:2:0 */
+ public static final String YUV4 = "yuv4";
+
+ /** ZeroCodec Lossless Video */
+ public static final String ZEROCODEC = "zerocodec";
+
+ /** LCL (LossLess Codec Library) ZLIB */
+ public static final String ZLIB = "zlib";
+
+ /** Zip Motion Blocks Video */
+ public static final String ZMBV = "zmbv";
+}
diff --git a/src/main/java/net/bramp/ffmpeg/gson/LowercaseEnumTypeAdapterFactory.java b/src/main/java/net/bramp/ffmpeg/gson/LowercaseEnumTypeAdapterFactory.java
index 10d017f2..8ed245c1 100644
--- a/src/main/java/net/bramp/ffmpeg/gson/LowercaseEnumTypeAdapterFactory.java
+++ b/src/main/java/net/bramp/ffmpeg/gson/LowercaseEnumTypeAdapterFactory.java
@@ -1,5 +1,7 @@
package net.bramp.ffmpeg.gson;
+import static com.google.common.base.Preconditions.checkNotNull;
+
import com.google.common.collect.ImmutableMap;
import com.google.errorprone.annotations.Immutable;
import com.google.gson.Gson;
@@ -9,15 +11,12 @@
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonToken;
import com.google.gson.stream.JsonWriter;
-
-import javax.annotation.CheckReturnValue;
-import javax.annotation.Nonnull;
import java.io.IOException;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
-
-import static com.google.common.base.Preconditions.checkNotNull;
+import javax.annotation.CheckReturnValue;
+import javax.annotation.Nonnull;
/**
* Maps Enums to lowercase strings.
@@ -37,7 +36,7 @@ private static class MyTypeAdapter
- *
- *
- * is turned into:
- *
- *
- * public class Set {
- * public boolean a = true;
- * public boolean b = false;
- * public int c = 1;
- * public int d = 0;
- * }
- *
- *
- * {
- * "a": true,
- * "b": false,
- * "c": true,
- * "d": false
- * }
- *
- */
-public class NamedBitsetAdapter> argsCaptor;
- static final Gson gson = FFmpegUtils.getGson();
+ FFprobe ffprobe;
@Before
public void before() throws IOException {
@@ -39,7 +47,7 @@ public void before() throws IOException {
.thenAnswer(new NewProcessAnswer("ffprobe-big_buck_bunny_720p_1mb.mp4"));
when(runFunc.run(argThatHasItem(Samples.always_on_my_mind)))
- .thenAnswer(new NewProcessAnswer("ffprobe-Always On My Mind [Program Only] - Adelén.mp4"));
+ .thenAnswer(new NewProcessAnswer("ffprobe-Always On My Mind [Program Only] - Adelen.mp4"));
when(runFunc.run(argThatHasItem(Samples.start_pts_test)))
.thenAnswer(new NewProcessAnswer("ffprobe-start_pts_test"));
@@ -50,6 +58,24 @@ public void before() throws IOException {
when(runFunc.run(argThatHasItem(Samples.book_with_chapters)))
.thenAnswer(new NewProcessAnswer("book_with_chapters.m4b"));
+ when(runFunc.run(argThatHasItem(Samples.big_buck_bunny_720p_1mb_with_packets)))
+ .thenAnswer(new NewProcessAnswer("ffprobe-big_buck_bunny_720p_1mb_packets.mp4"));
+
+ when(runFunc.run(argThatHasItem(Samples.big_buck_bunny_720p_1mb_with_frames)))
+ .thenAnswer(new NewProcessAnswer("ffprobe-big_buck_bunny_720p_1mb_frames.mp4"));
+
+ when(runFunc.run(argThatHasItem(Samples.big_buck_bunny_720p_1mb_with_packets_and_frames)))
+ .thenAnswer(new NewProcessAnswer("ffprobe-big_buck_bunny_720p_1mb_packets_and_frames.mp4"));
+
+ when(runFunc.run(argThatHasItem(Samples.side_data_list)))
+ .thenAnswer(new NewProcessAnswer("ffprobe-side_data_list"));
+
+ when(runFunc.run(argThatHasItem(Samples.disposition_all_true)))
+ .thenAnswer(new NewProcessAnswer("ffprobe-disposition_all_true"));
+
+ when(runFunc.run(argThatHasItem(Samples.chapters_with_long_id)))
+ .thenAnswer(new NewProcessAnswer("chapters_with_long_id.m4b"));
+
ffprobe = new FFprobe(runFunc);
}
@@ -70,8 +96,8 @@ public void testProbeVideo() throws IOException {
// Only a quick sanity check until we do something better
assertThat(info.getStreams(), hasSize(2));
- assertThat(info.getStreams().get(0).codec_type, is(FFmpegStream.CodecType.VIDEO));
- assertThat(info.getStreams().get(1).codec_type, is(FFmpegStream.CodecType.AUDIO));
+ assertThat(info.getStreams().get(0).codec_type, is(CodecType.VIDEO));
+ assertThat(info.getStreams().get(1).codec_type, is(CodecType.AUDIO));
assertThat(info.getStreams().get(1).channels, is(6));
assertThat(info.getStreams().get(1).sample_rate, is(48_000));
@@ -92,7 +118,7 @@ public void testProbeBookWithChapters() throws IOException {
assertThat(firstChapter.start_time, is("0.000000"));
assertThat(firstChapter.end, is(11951309L));
assertThat(firstChapter.end_time, is("271.004739"));
- assertThat(firstChapter.tags.title, is("01 - Sammy Jay Makes a Fuss"));
+ assertThat(firstChapter.getTags().title, is("01 - Sammy Jay Makes a Fuss"));
FFmpegChapter lastChapter = info.getChapters().get(info.getChapters().size() - 1);
assertThat(lastChapter.time_base, is("1/44100"));
@@ -100,7 +126,226 @@ public void testProbeBookWithChapters() throws IOException {
assertThat(lastChapter.start_time, is("5394.008844"));
assertThat(lastChapter.end, is(248628224L));
assertThat(lastChapter.end_time, is("5637.828209"));
- assertThat(lastChapter.tags.title, is("24 - Chatterer Has His Turn to Laugh"));
+ assertThat(lastChapter.getTags().title, is("24 - Chatterer Has His Turn to Laugh"));
+ }
+
+ @Test
+ public void testProbeWithPackets() throws IOException {
+ FFmpegProbeResult info =
+ ffprobe.probe(
+ ffprobe
+ .builder()
+ .setInput(Samples.big_buck_bunny_720p_1mb_with_packets)
+ .setShowPackets(true)
+ .build());
+ assertThat(info.hasError(), is(false));
+ assertThat(info.getPackets().size(), is(381));
+
+ FFmpegPacket firstPacket = info.getPackets().get(0);
+ assertThat(firstPacket.codec_type, is(CodecType.AUDIO));
+ assertThat(firstPacket.stream_index, is(1));
+ assertThat(firstPacket.pts, is(0L));
+ assertThat(firstPacket.pts_time, is(0.0));
+ assertThat(firstPacket.dts, is(0L));
+ assertThat(firstPacket.dts_time, is(0.0));
+ assertThat(firstPacket.duration, is(1024L));
+ assertThat(firstPacket.duration_time, is(0.021333F));
+ assertThat(firstPacket.size, is("967"));
+ assertThat(firstPacket.pos, is("4261"));
+ assertThat(firstPacket.flags, is("K_"));
+
+ FFmpegPacket secondPacket = info.getPackets().get(1);
+ assertThat(secondPacket.codec_type, is(CodecType.VIDEO));
+ assertThat(secondPacket.stream_index, is(0));
+ assertThat(secondPacket.pts, is(0L));
+ assertThat(secondPacket.pts_time, is(0.0));
+ assertThat(secondPacket.dts, is(0L));
+ assertThat(secondPacket.dts_time, is(0.0));
+ assertThat(secondPacket.duration, is(512L));
+ assertThat(secondPacket.duration_time, is(0.04F));
+ assertThat(secondPacket.size, is("105222"));
+ assertThat(secondPacket.pos, is("5228"));
+ assertThat(secondPacket.flags, is("K_"));
+
+ FFmpegPacket lastPacket = info.getPackets().get(info.getPackets().size() - 1);
+ assertThat(lastPacket.codec_type, is(CodecType.AUDIO));
+ assertThat(lastPacket.stream_index, is(1));
+ assertThat(lastPacket.pts, is(253952L));
+ assertThat(lastPacket.pts_time, is(5.290667));
+ assertThat(lastPacket.dts, is(253952L));
+ assertThat(lastPacket.dts_time, is(5.290667));
+ assertThat(lastPacket.duration, is(1024L));
+ assertThat(lastPacket.duration_time, is(0.021333F));
+ assertThat(lastPacket.size, is("1111"));
+ assertThat(lastPacket.pos, is("1054609"));
+ assertThat(lastPacket.flags, is("K_"));
+ }
+
+ @Test
+ public void testProbeWithFrames() throws IOException {
+ FFmpegProbeResult info =
+ ffprobe.probe(
+ ffprobe
+ .builder()
+ .setInput(Samples.big_buck_bunny_720p_1mb_with_frames)
+ .setShowFrames(true)
+ .build());
+ assertThat(info.hasError(), is(false));
+ assertThat(info.getFrames().size(), is(381));
+
+ FFmpegFrame firstFrame = info.getFrames().get(0);
+ assertThat(firstFrame.stream_index, is(1));
+ assertThat(firstFrame.key_frame, is(1));
+ assertThat(firstFrame.pkt_pts, is(0L));
+ assertThat(firstFrame.pkt_pts_time, is(0.0));
+ assertThat(firstFrame.pkt_dts, is(0L));
+ assertThat(firstFrame.pkt_dts_time, is(0.0));
+ assertThat(firstFrame.best_effort_timestamp, is(0L));
+ assertThat(firstFrame.best_effort_timestamp_time, is(0.0F));
+ assertThat(firstFrame.pkt_duration, is(1024L));
+ assertThat(firstFrame.pkt_duration_time, is(0.021333F));
+ assertThat(firstFrame.pkt_pos, is(4261L));
+ assertThat(firstFrame.pkt_size, is(967L));
+ assertThat(firstFrame.sample_fmt, is("fltp"));
+ assertThat(firstFrame.nb_samples, is(1024));
+ assertThat(firstFrame.channels, is(6));
+ assertThat(firstFrame.channel_layout, is("5.1"));
+
+ FFmpegFrame secondFrame = info.getFrames().get(1);
+ assertThat(secondFrame.media_type, is(CodecType.VIDEO));
+ assertThat(secondFrame.stream_index, is(0));
+ assertThat(secondFrame.key_frame, is(1));
+ assertThat(secondFrame.pkt_pts, is(0L));
+ assertThat(secondFrame.pkt_pts_time, is(0.0));
+ assertThat(secondFrame.pkt_dts, is(0L));
+ assertThat(secondFrame.pkt_dts_time, is(0.0));
+ assertThat(secondFrame.best_effort_timestamp, is(0L));
+ assertThat(secondFrame.best_effort_timestamp_time, is(0.0F));
+ assertThat(secondFrame.pkt_duration, is(512L));
+ assertThat(secondFrame.pkt_duration_time, is(0.04F));
+ assertThat(secondFrame.pkt_pos, is(5228L));
+ assertThat(secondFrame.pkt_size, is(105222L));
+ assertThat(secondFrame.sample_fmt, new IsNull<>());
+ assertThat(secondFrame.nb_samples, is(0));
+ assertThat(secondFrame.channels, is(0));
+ assertThat(secondFrame.channel_layout, new IsNull<>());
+
+ FFmpegFrame lastFrame = info.getFrames().get(info.getFrames().size() - 1);
+ assertLastFrame(lastFrame);
+ }
+
+ @Test
+ public void testProbeWithPacketsAndFrames() throws IOException {
+ FFmpegProbeResult info =
+ ffprobe.probe(
+ ffprobe
+ .builder()
+ .setInput(Samples.big_buck_bunny_720p_1mb_with_packets_and_frames)
+ .setShowPackets(true)
+ .setShowFrames(true)
+ .build());
+ assertThat(info.hasError(), is(false));
+ assertThat(info.getPackets().size(), is(381));
+ assertThat(info.getFrames().size(), is(381));
+
+ FFmpegPacket firstPacket = info.getPackets().get(0);
+ assertThat(firstPacket.codec_type, is(CodecType.AUDIO));
+ assertThat(firstPacket.stream_index, is(1));
+ assertThat(firstPacket.pts, is(0L));
+ assertThat(firstPacket.pts_time, is(0.0));
+ assertThat(firstPacket.dts, is(0L));
+ assertThat(firstPacket.dts_time, is(0.0));
+ assertThat(firstPacket.duration, is(1024L));
+ assertThat(firstPacket.duration_time, is(0.021333F));
+ assertThat(firstPacket.size, is("967"));
+ assertThat(firstPacket.pos, is("4261"));
+ assertThat(firstPacket.flags, is("K_"));
+
+ FFmpegPacket secondPacket = info.getPackets().get(1);
+ assertThat(secondPacket.codec_type, is(CodecType.VIDEO));
+ assertThat(secondPacket.stream_index, is(0));
+ assertThat(secondPacket.pts, is(0L));
+ assertThat(secondPacket.pts_time, is(0.0));
+ assertThat(secondPacket.dts, is(0L));
+ assertThat(secondPacket.dts_time, is(0.0));
+ assertThat(secondPacket.duration, is(512L));
+ assertThat(secondPacket.duration_time, is(0.04F));
+ assertThat(secondPacket.size, is("105222"));
+ assertThat(secondPacket.pos, is("5228"));
+ assertThat(secondPacket.flags, is("K_"));
+
+ FFmpegPacket lastPacket = info.getPackets().get(info.getPackets().size() - 1);
+ assertThat(lastPacket.codec_type, is(CodecType.AUDIO));
+ assertThat(lastPacket.stream_index, is(1));
+ assertThat(lastPacket.pts, is(253952L));
+ assertThat(lastPacket.pts_time, is(5.290667));
+ assertThat(lastPacket.dts, is(253952L));
+ assertThat(lastPacket.dts_time, is(5.290667));
+ assertThat(lastPacket.duration, is(1024L));
+ assertThat(lastPacket.duration_time, is(0.021333F));
+ assertThat(lastPacket.size, is("1111"));
+ assertThat(lastPacket.pos, is("1054609"));
+ assertThat(lastPacket.flags, is("K_"));
+
+ FFmpegFrame firstFrame = info.getFrames().get(0);
+ assertThat(firstFrame.stream_index, is(1));
+ assertThat(firstFrame.key_frame, is(1));
+ assertThat(firstFrame.pkt_pts, is(0L));
+ assertThat(firstFrame.pkt_pts_time, is(0.0));
+ assertThat(firstFrame.pkt_dts, is(0L));
+ assertThat(firstFrame.pkt_dts_time, is(0.0));
+ assertThat(firstFrame.best_effort_timestamp, is(0L));
+ assertThat(firstFrame.best_effort_timestamp_time, is(0.0F));
+ assertThat(firstFrame.pkt_duration, is(1024L));
+ assertThat(firstFrame.pkt_duration_time, is(0.021333F));
+ assertThat(firstFrame.pkt_pos, is(4261L));
+ assertThat(firstFrame.pkt_size, is(967L));
+ assertThat(firstFrame.sample_fmt, is("fltp"));
+ assertThat(firstFrame.nb_samples, is(1024));
+ assertThat(firstFrame.channels, is(6));
+ assertThat(firstFrame.channel_layout, is("5.1"));
+
+ FFmpegFrame secondFrame = info.getFrames().get(1);
+ assertThat(secondFrame.media_type, is(CodecType.VIDEO));
+ assertThat(secondFrame.stream_index, is(0));
+ assertThat(secondFrame.key_frame, is(1));
+ assertThat(secondFrame.pkt_pts, is(0L));
+ assertThat(secondFrame.pkt_pts_time, is(0.0));
+ assertThat(secondFrame.pkt_dts, is(0L));
+ assertThat(secondFrame.pkt_dts_time, is(0.0));
+ assertThat(secondFrame.best_effort_timestamp, is(0L));
+ assertThat(secondFrame.best_effort_timestamp_time, is(0.0F));
+ assertThat(secondFrame.pkt_duration, is(512L));
+ assertThat(secondFrame.pkt_duration_time, is(0.04F));
+ assertThat(secondFrame.pkt_pos, is(5228L));
+ assertThat(secondFrame.pkt_size, is(105222L));
+ assertThat(secondFrame.sample_fmt, new IsNull<>());
+ assertThat(secondFrame.nb_samples, is(0));
+ assertThat(secondFrame.channels, is(0));
+ assertThat(secondFrame.channel_layout, new IsNull<>());
+
+ FFmpegFrame lastFrame = info.getFrames().get(info.getFrames().size() - 1);
+ assertLastFrame(lastFrame);
+ }
+
+ private void assertLastFrame(FFmpegFrame actual) {
+ assertThat(actual.media_type, is(CodecType.AUDIO));
+ assertThat(actual.stream_index, is(1));
+ assertThat(actual.key_frame, is(1));
+ assertThat(actual.pkt_pts, is(253952L));
+ assertThat(actual.pkt_pts_time, is(5.290667));
+ assertThat(actual.pkt_dts, is(253952L));
+ assertThat(actual.pkt_dts_time, is(5.290667));
+ assertThat(actual.best_effort_timestamp, is(253952L));
+ assertThat(actual.best_effort_timestamp_time, is(5.290667F));
+ assertThat(actual.pkt_duration, is(1024L));
+ assertThat(actual.pkt_duration_time, is(0.021333F));
+ assertThat(actual.pkt_pos, is(1054609L));
+ assertThat(actual.pkt_size, is(1111L));
+ assertThat(actual.sample_fmt, is("fltp"));
+ assertThat(actual.nb_samples, is(1024));
+ assertThat(actual.channels, is(6));
+ assertThat(actual.channel_layout, is("5.1"));
}
@Test
@@ -110,8 +355,8 @@ public void testProbeVideo2() throws IOException {
// Only a quick sanity check until we do something better
assertThat(info.getStreams(), hasSize(2));
- assertThat(info.getStreams().get(0).codec_type, is(FFmpegStream.CodecType.VIDEO));
- assertThat(info.getStreams().get(1).codec_type, is(FFmpegStream.CodecType.AUDIO));
+ assertThat(info.getStreams().get(0).codec_type, is(CodecType.VIDEO));
+ assertThat(info.getStreams().get(1).codec_type, is(CodecType.AUDIO));
assertThat(info.getStreams().get(1).channels, is(2));
assertThat(info.getStreams().get(1).sample_rate, is(48_000));
@@ -143,4 +388,425 @@ public void testProbeDivideByZero() throws IOException {
// System.out.println(FFmpegUtils.getGson().toJson(info));
}
+
+ @Test
+ public void shouldThrowOnErrorWithFFmpegProbeResult() {
+ Mockito.doReturn(1).when(mockProcess).exitValue();
+
+ final FFmpegError error = new FFmpegError();
+ final FFmpegProbeResult result = new FFmpegProbeResult();
+ result.error = error;
+ FFmpegException e =
+ assertThrows(FFmpegException.class, () -> ffprobe.throwOnError(mockProcess, result));
+ assertEquals(error, e.getError());
+ }
+
+ @Test
+ public void shouldThrowOnErrorEvenIfProbeResultHasNoError() {
+ Mockito.doReturn(1).when(mockProcess).exitValue();
+
+ final FFmpegProbeResult result = new FFmpegProbeResult();
+ FFmpegException e =
+ assertThrows(FFmpegException.class, () -> ffprobe.throwOnError(mockProcess, result));
+ assertNull(e.getError());
+ }
+
+ @Test
+ public void shouldThrowOnErrorEvenIfProbeResultIsNull() {
+ Mockito.doReturn(1).when(mockProcess).exitValue();
+
+ FFmpegException e =
+ assertThrows(FFmpegException.class, () -> ffprobe.throwOnError(mockProcess, null));
+ assertNull(e.getError());
+ }
+
+ @Test
+ public void testShouldThrowErrorWithoutMock() throws IOException {
+ FFprobe probe = new FFprobe();
+ FFmpegException e = assertThrows(FFmpegException.class, () -> probe.probe("doesnotexist.mp4"));
+
+ assertNotNull(e);
+ assertNotNull(e.getError());
+
+ // Intentionally not comparing the values, as those might change for different ffmpeg versions
+ assertNotNull(e.getError().getString());
+ assertNotEquals(0, e.getError().getCode());
+ }
+
+ @Test
+ public void testProbeSideDataList() throws IOException {
+ FFmpegProbeResult info = ffprobe.probe(Samples.side_data_list);
+
+ // Check edge case with a time larger than an integer
+ assertThat(info.getStreams().get(0).getSideDataList().size(), is(1));
+ assertThat(
+ info.getStreams().get(0).getSideDataList().get(0).side_data_type, is("Display Matrix"));
+ assertThat(
+ info.getStreams().get(0).getSideDataList().get(0).displaymatrix,
+ is(
+ "\n00000000: 0 -65536 0\n00000001: 65536 0 0\n00000002: 0 0 1073741824\n"));
+ assertThat(info.getStreams().get(0).getSideDataList().get(0).rotation, is(90));
+ }
+
+ @Test
+ public void testChaptersWithLongIds() throws IOException {
+ FFmpegProbeResult info = ffprobe.probe(Samples.chapters_with_long_id);
+
+ assertThat(info.getChapters().get(0).id, is(6613449456311024506L));
+ assertThat(info.getChapters().get(1).id, is(-4433436293284298339L));
+ }
+
+ @Test
+ public void testProbeDefaultArguments() throws IOException {
+ ffprobe.probe(Samples.always_on_my_mind);
+
+ verify(runFunc, times(2)).run(argsCaptor.capture());
+
+ List