Skip to content

Commit

Permalink
* Add option property to FFmpegFrameGrabber to let users set suc…
Browse files Browse the repository at this point in the history
…h things as "analyzeduration", "probesize", or "list_devices"
  • Loading branch information
saudet committed Jan 25, 2015
1 parent 8ae5dd9 commit e3c894e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

* Add `option` property to `FFmpegFrameGrabber` to let users set such things as "analyzeduration", "probesize", or "list_devices"
* Fix "AVFrame.format is not set" and "AVFrame.width or height is not set" warning messages ([issue #76](https://github.com/bytedeco/javacv/issues/76))

### December 23, 2014 version 0.10
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/org/bytedeco/javacv/FFmpegFrameGrabber.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import java.io.File;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.util.Map.Entry;
import org.bytedeco.javacpp.BytePointer;
import org.bytedeco.javacpp.DoublePointer;
import org.bytedeco.javacpp.IntPointer;
Expand Down Expand Up @@ -384,6 +385,9 @@ public void startUnsafe() throws Exception {
if (audioChannels > 0) {
av_dict_set(options, "channels", "" + audioChannels, 0);
}
for (Entry<String, String> e : this.options.entrySet()) {
av_dict_set(options, e.getKey(), e.getValue(), 0);
}
if ((ret = avformat_open_input(oc, filename, f, options)) < 0) {
av_dict_set(options, "pixel_format", null, 0);
if ((ret = avformat_open_input(oc, filename, f, options)) < 0) {
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/org/bytedeco/javacv/FrameGrabber.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.Callable;
Expand Down Expand Up @@ -178,6 +179,7 @@ public static enum ImageMode {
protected int numBuffers = 4;
protected double gamma = 0.0;
protected boolean deinterlace = false;
protected HashMap<String, String> options = new HashMap<String, String>();
protected int frameNumber = 0;
protected long timestamp = 0;

Expand Down Expand Up @@ -321,6 +323,13 @@ public void setDeinterlace(boolean deinterlace) {
this.deinterlace = deinterlace;
}

public String getOption(String key) {
return options.get(key);
}
public void setOption(String key, String value) {
options.put(key, value);
}

public int getFrameNumber() {
return frameNumber;
}
Expand Down

0 comments on commit e3c894e

Please sign in to comment.