diff --git a/src/main/java/org/bytedeco/javacv/FFmpegFrameGrabber.java b/src/main/java/org/bytedeco/javacv/FFmpegFrameGrabber.java index 034f247a..540b3b37 100644 --- a/src/main/java/org/bytedeco/javacv/FFmpegFrameGrabber.java +++ b/src/main/java/org/bytedeco/javacv/FFmpegFrameGrabber.java @@ -68,6 +68,9 @@ import org.bytedeco.javacpp.Loader; import org.bytedeco.javacpp.Pointer; import org.bytedeco.javacpp.PointerScope; +import org.bytedeco.javacv.FFmpegFrameGrabber.ReadCallback; +import org.bytedeco.javacv.FrameGrabber.ImageMode; +import org.bytedeco.javacv.FrameGrabber.SampleMode; import org.bytedeco.javacpp.PointerPointer; import org.bytedeco.ffmpeg.avcodec.*; @@ -989,6 +992,7 @@ public synchronized void startUnsafe(boolean findStreamInfo) throws Exception { throw new Exception("avformat_open_input() error " + ret + ": Could not open input \"" + filename + "\". (Has setFormat() been called?)"); } } + logRejectedOptions(options, "avformat_open_input"); av_dict_free(options); oc.max_delay(maxDelay); @@ -1072,6 +1076,7 @@ public synchronized void startUnsafe(boolean findStreamInfo) throws Exception { if ((ret = avcodec_open2(video_c, codec, options)) < 0) { throw new Exception("avcodec_open2() error " + ret + ": Could not open video codec."); } + logRejectedOptions(options, "avcodec_open2"); av_dict_free(options); // Hack to correct wrong frame rates that seem to be generated by some codecs @@ -1123,6 +1128,7 @@ public synchronized void startUnsafe(boolean findStreamInfo) throws Exception { if ((ret = avcodec_open2(audio_c, codec, options)) < 0) { throw new Exception("avcodec_open2() error " + ret + ": Could not open audio codec."); } + logRejectedOptions(options, "avcodec_open2"); av_dict_free(options); // Allocate audio samples frame @@ -1138,6 +1144,16 @@ public synchronized void startUnsafe(boolean findStreamInfo) throws Exception { } } + private void logRejectedOptions(final AVDictionary options, final String command) { + if (av_log_get_level() >= AV_LOG_INFO && av_dict_count(options) > 0) { + AVDictionaryEntry e = null; + System.out.println(command + " rejected some options:"); + while ((e = av_dict_iterate(options, e)) != null) { + System.out.println("\tOption: " + e.key().getString() + ", value: " + e.value().getString()); + } + } + } + private void initPictureRGB() { int width = imageWidth > 0 ? imageWidth : video_c.width(); int height = imageHeight > 0 ? imageHeight : video_c.height(); diff --git a/src/main/java/org/bytedeco/javacv/FFmpegFrameRecorder.java b/src/main/java/org/bytedeco/javacv/FFmpegFrameRecorder.java index f6567fbe..220676f1 100644 --- a/src/main/java/org/bytedeco/javacv/FFmpegFrameRecorder.java +++ b/src/main/java/org/bytedeco/javacv/FFmpegFrameRecorder.java @@ -75,7 +75,7 @@ import org.bytedeco.javacpp.PointerScope; import org.bytedeco.javacpp.PointerPointer; import org.bytedeco.javacpp.ShortPointer; - +import org.bytedeco.javacv.FFmpegFrameRecorder.WriteCallback; import org.bytedeco.ffmpeg.avcodec.*; import org.bytedeco.ffmpeg.avdevice.*; import org.bytedeco.ffmpeg.avformat.*; @@ -798,6 +798,7 @@ public synchronized void startUnsafe() throws Exception { av_dict_free(options); throw new Exception("avcodec_open2() error " + ret + ": Could not open video codec."); } + logRejectedOptions(options, "avcodec_open2"); av_dict_free(options); video_outbuf = null; @@ -879,6 +880,7 @@ public synchronized void startUnsafe() throws Exception { av_dict_free(options); throw new Exception("avcodec_open2() error " + ret + ": Could not open audio codec."); } + logRejectedOptions(options, "avcodec_open2"); av_dict_free(options); audio_outbuf_size = 256 * 1024; @@ -962,6 +964,7 @@ public synchronized void startUnsafe() throws Exception { av_dict_free(options); throw new Exception(errorMsg); } + logRejectedOptions(options, "avio_open2"); oc.pb(pb); } @@ -976,6 +979,7 @@ public synchronized void startUnsafe() throws Exception { av_dict_free(options); throw new Exception(errorMsg); } + logRejectedOptions(options, "avformat_write_header"); av_dict_free(options); if (av_log_get_level() >= AV_LOG_INFO) { @@ -1311,6 +1315,16 @@ public synchronized boolean recordSamples(int sampleRate, int audioChannels, Buf } } + private void logRejectedOptions(final AVDictionary options, final String command) { + if (av_log_get_level() >= AV_LOG_INFO && av_dict_count(options) > 0) { + AVDictionaryEntry e = null; + System.out.println(command + " rejected some options:"); + while ((e = av_dict_iterate(options, e)) != null) { + System.out.println("\tOption: " + e.key().getString() + ", value: " + e.value().getString()); + } + } + } + private void writeSamples(int nb_samples) throws Exception { if (samples_out == null || samples_out.length == 0) { return;