remove some redundant debugs. Improve some messages

This commit is contained in:
Isaac Connor 2019-08-20 14:09:47 -04:00
parent 4a82ce83a7
commit 01e988ffba
3 changed files with 20 additions and 42 deletions

View File

@ -480,9 +480,9 @@ bool is_audio_context( AVCodecContext *codec_context ) {
int zm_receive_frame(AVCodecContext *context, AVFrame *frame, AVPacket &packet) {
int ret;
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
if ( (ret = avcodec_send_packet(context, &packet)) < 0 ) {
Error( "Unable to send packet %s, continuing",
av_make_error_string(ret).c_str() );
if ( (ret = avcodec_send_packet(context, &packet)) < 0 ) {
Error("Unable to send packet %s, continuing",
av_make_error_string(ret).c_str());
return ret;
}

View File

@ -137,8 +137,6 @@ FfmpegCamera::FfmpegCamera(
Initialise();
}
hwaccel = false;
mFormatContext = NULL;
mVideoStreamId = -1;
mAudioStreamId = -1;
@ -362,16 +360,14 @@ int FfmpegCamera::OpenFfmpeg() {
}
av_dict_free(&opts);
Info("Stream open %s, parsing streams...", mPath.c_str());
#if !LIBAVFORMAT_VERSION_CHECK(53, 6, 0, 6, 0)
ret = av_find_stream_info(mFormatContext);
#else
ret = avformat_find_stream_info(mFormatContext, 0);
#endif
if ( ret < 0 ) {
Error("Unable to find stream info from %s due to: %s", mPath.c_str(),
av_make_error_string(ret).c_str());
Error("Unable to find stream info from %s due to: %s",
mPath.c_str(), av_make_error_string(ret).c_str());
return -1;
}
@ -397,8 +393,10 @@ int FfmpegCamera::OpenFfmpeg() {
}
}
} // end foreach stream
if ( mVideoStreamId == -1 )
Fatal("Unable to locate video stream in %s", mPath.c_str());
if ( mVideoStreamId == -1 ) {
Error("Unable to locate video stream in %s", mPath.c_str());
return -1;
}
Debug(3, "Found video stream at index %d, audio stream at index %d",
mVideoStreamId, mAudioStreamId);
@ -436,7 +434,6 @@ int FfmpegCamera::OpenFfmpeg() {
}
}
Debug(1, "Video Found decoder %s", mVideoCodec->name);
zm_dump_stream_format(mFormatContext, mVideoStreamId, 0, 0);
if ( hwaccel_name != "" ) {
@ -457,7 +454,7 @@ int FfmpegCamera::OpenFfmpeg() {
}
#if LIBAVUTIL_VERSION_CHECK(56, 22, 0, 14, 0)
// Get h_pix_fmt
// Get hw_pix_fmt
for ( int i = 0;; i++ ) {
const AVCodecHWConfig *config = avcodec_get_hw_config(mVideoCodec, i);
if ( !config ) {
@ -483,22 +480,18 @@ int FfmpegCamera::OpenFfmpeg() {
#endif
if ( hw_pix_fmt != AV_PIX_FMT_NONE ) {
Debug(1, "Selected hw_pix_fmt %d %s",
hw_pix_fmt,
av_get_pix_fmt_name(hw_pix_fmt));
hw_pix_fmt, av_get_pix_fmt_name(hw_pix_fmt));
mVideoCodecContext->get_format = get_hw_format;
Debug(1, "Creating hwdevice for %s",
(hwaccel_device != "" ? hwaccel_device.c_str() : ""));
ret = av_hwdevice_ctx_create(&hw_device_ctx, type,
(hwaccel_device != "" ? hwaccel_device.c_str(): NULL), NULL, 0);
if ( ret < 0 ) {
Error("Failed to create specified HW device.");
Error("Failed to create hwaccel device.");
return -1;
}
Debug(1, "Created hwdevice");
Debug(1, "Created hwdevice for %s", hwaccel_device.c_str());
mVideoCodecContext->hw_device_ctx = av_buffer_ref(hw_device_ctx);
hwaccel = true;
hwFrame = zm_av_frame_alloc();
} else {
Debug(1, "Failed to setup hwaccel.");
@ -528,11 +521,7 @@ int FfmpegCamera::OpenFfmpeg() {
}
zm_dump_codec(mVideoCodecContext);
if ( mVideoCodecContext->hwaccel != NULL ) {
Debug(1, "HWACCEL in use");
} else {
Debug(1, "HWACCEL not in use");
}
Debug(1, hwFrame ? "HWACCEL in use" : "HWACCEL not in use");
if ( mAudioStreamId >= 0 ) {
if ( (mAudioCodec = avcodec_find_decoder(
@ -593,21 +582,15 @@ int FfmpegCamera::OpenFfmpeg() {
#if HAVE_LIBSWSCALE
if ( !sws_isSupportedInput(mVideoCodecContext->pix_fmt) ) {
Error("swscale does not support the codec format: %c%c%c%c",
(mVideoCodecContext->pix_fmt)&0xff,
((mVideoCodecContext->pix_fmt >> 8)&0xff),
((mVideoCodecContext->pix_fmt >> 16)&0xff),
((mVideoCodecContext->pix_fmt >> 24)&0xff)
Error("swscale does not support the codec format for input: %s",
av_get_pix_fmt_name(mVideoCodecContext->pix_fmt)
);
return -1;
}
if ( !sws_isSupportedOutput(imagePixFormat) ) {
Error("swscale does not support the target format: %c%c%c%c",
(imagePixFormat)&0xff,
((imagePixFormat>>8)&0xff),
((imagePixFormat>>16)&0xff),
((imagePixFormat>>24)&0xff)
Error("swscale does not support the target format: %s",
av_get_pix_fmt_name(imagePixFormat)
);
return -1;
}
@ -953,7 +936,6 @@ int FfmpegCamera::CaptureAndRecord(
continue;
}
if ( error_count > 0 ) error_count--;
Debug(3, "Decoded video packet at frame %d", frameCount);
zm_dump_video_frame(mRawFrame, "raw frame from decoder");
#if HAVE_LIBAVUTIL_HWCONTEXT_H
#if LIBAVCODEC_VERSION_CHECK(57, 89, 0, 89, 0)
@ -983,8 +965,6 @@ int FfmpegCamera::CaptureAndRecord(
}
#endif
#endif
Debug(4, "Got frame %d", frameCount);
if ( transfer_to_image(image, mFrame, input_frame) < 0 ) {
Error("Failed to transfer from frame to image");
zm_av_packet_unref(&packet);

View File

@ -59,11 +59,9 @@ class FfmpegCamera : public Camera {
_AVPIXELFORMAT imagePixFormat;
AVFrame *input_frame; // Use to point to mRawFrame or hwFrame;
bool hwaccel;
AVFrame *hwFrame;
AVFrame *hwFrame; // Will also be used to indicate if hwaccel is in use
#if HAVE_LIBAVUTIL_HWCONTEXT_H
DecodeContext decode;
AVBufferRef *hw_device_ctx = NULL;
AVBufferRef *hw_device_ctx = NULL;
#endif
// Used to store the incoming packet, it will get copied when queued.