Open RivsDC opened 6 years ago
If your camera uses MJPEG, it looks like this could be a workaround. Could you give it a try? https://stackoverflow.com/a/23216860/523744
This happens in "simple" frame grabbing as well. No scaling used whatsover. It looks like happening with specific camera models like Axis for instance, there is no chance to modify the pixel format there:
Stream #0:0: Video: h264 (Main), yuvj420p(pc, bt709, progressive), 1024x768 [SAR 1:1 DAR 4:3], 25 fps, 25 tbr, 90k tbn, 180k tbc
MJPEG is simply no option since it is magnitudes more inefficient and the H264 decoding is working really well. The only problem is the repeated warning in the console. It is really jamming. Is it possible to put out this only once or set an environment variable to get rid of these informations at all?
JFYI, I patched the ffmpeg sources to not using the warning level for this and pushed a new libswscale.so into the jar. I also committed to FFMPEG but only god knows if it goes through, whoever is interested should check this:
---
libswscale/utils.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libswscale/utils.c b/libswscale/utils.c
index dcab70..af4aa1 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -1182,7 +1182,7 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter,
c->dstRange |= handle_jpeg(&c->dstFormat);
if(srcFormat!=c->srcFormat || dstFormat!=c->dstFormat)
- av_log(c, AV_LOG_WARNING, "deprecated pixel format used, make sure you did set range correctly\n");
+ av_log(c, AV_LOG_DEBUG, "deprecated pixel format used, make sure you did set range correctly\n");
if (!c->contrast && !c->saturation && !c->dstFormatBpp)
sws_setColorspaceDetails(c, ff_yuv2rgb_coeffs[SWS_CS_DEFAULT], c->srcRange,
--
@thhart According to the material above, we just need to override the pixel format in FFmpegFrameGrabber...
@saudet Which material? You mean like the code below? Not improving:
FFmpegFrameGrabber grabber = new FFmpegFrameGrabber("rtsp://192.168.0.160/axis-media/media.amp") {
public int getPixelFormat() {
int pixFormat = super.getPixelFormat();
switch (pixFormat) {
case AV_PIX_FMT_YUVJ420P :
pixFormat = AV_PIX_FMT_YUV420P;
break;
case AV_PIX_FMT_YUVJ422P :
pixFormat = AV_PIX_FMT_YUV422P;
break;
case AV_PIX_FMT_YUVJ444P :
pixFormat = AV_PIX_FMT_YUV444P;
break;
case AV_PIX_FMT_YUVJ440P :
pixFormat = AV_PIX_FMT_YUV440P;
default:
break;
}
return pixFormat;
}
};
We need to modify that inside FFmpegFrameGrabber...
New user, I believe I'm running into the same thing when trying to do a hello-world copy of an input mp4 to an output mp4.
@salamanders Just ignore the warning message until someone sends a pull request to fix this :)
@saudet could you please tell us how to Make ffmpeg/javacv less verbose in java. So that we can hide the error. I am looking for similar solution. Could you please guide me regarding this.
Call av_log_set_level(AV_LOG_WARNING)
or less:
https://github.com/bytedeco/javacv/blob/master/src/main/java/org/bytedeco/javacv/FFmpegFrameGrabber.java#L580
Just wanted to clarify @saudet 's last comment. It still spams when you set the log level to warning, but when you set it to errors the billion warnings go away! Finally I can read the console output!
av_log_set_level(AV_LOG_ERROR);
@thhart I think I have found a good way, the code is as follows:
avutil.av_log_set_level(MAX_PRIORITY);
Set the priority of the log to the highest level, and then the console will have no warning output.
Is there another solution that doesn't involve setting the log level to ERROR? I want to see warnings in general, and the workaround in the previous comments have the side effect of disabling all warnings.
The console prints the following information all the time,What's the solution?