[Libav-user] Help decoding error messages

jonsmirl at gmail.com jonsmirl at gmail.com
Tue Jun 6 05:22:37 EEST 2017


I'm trying to decode the video coming from a Hi3516 based RTSP
security camera. I've set the probe buffer upto 20MB and it still did
not find the codec parameters.

This is a fixed camera so I can use Onvif to query the parameter and
set them, but what parameters is it looking for?

This appears to be the fatal error:
W/ACodec: cannot describe color format 0x13 = 19 with stride=0 and sliceHeight=0

06-06 10:16:33.726 28720-29792/com.digispeaker.rtsp D/rtsp: Probe
buffer size limit of 20000000 bytes reached
06-06 10:16:33.726 28720-29792/com.digispeaker.rtsp D/rtsp: Stream #0:
not enough frames to estimate rate; consider increasing probesize
06-06 10:16:33.727 28720-29792/com.digispeaker.rtsp D/rtsp: stream 0:
start_time: -102481911520608.625 duration: -102481911520608.625
06-06 10:16:33.727 28720-29792/com.digispeaker.rtsp D/rtsp: format:
start_time: 0.000 duration: -9223372036854.775 bitrate=0 kb/s
06-06 10:16:33.727 28720-29792/com.digispeaker.rtsp D/rtsp: Could not
find codec parameters for stream 0 (Video: h264 (Main), 1 reference
frame, none(progressive)): unspecified size
                                                            Consider
increasing the value for the 'analyzeduration' and 'probesize' options
06-06 10:16:33.728 28720-29792/com.digispeaker.rtsp D/rtsp:
nal_unit_type: 7, nal_ref_idc: 3
06-06 10:16:33.728 28720-29792/com.digispeaker.rtsp D/rtsp:
nal_unit_type: 8, nal_ref_idc: 3
06-06 10:16:33.732 28720-29792/com.digispeaker.rtsp D/rtsp: Found
decoder OMX.allwinner.video.decoder.avc
06-06 10:16:33.743 28720-1438/com.digispeaker.rtsp I/OMXClient: Using
client-side OMX mux.
06-06 10:16:33.753 28720-1438/com.digispeaker.rtsp W/ACodec: cannot
describe color format 0x13 = 19 with stride=0 and sliceHeight=0
06-06 10:16:33.761 28720-1438/com.digispeaker.rtsp E/MemoryHeapBase:
mmap(fd=47, size=0) failed (Invalid argument)
06-06 10:16:33.761 28720-1438/com.digispeaker.rtsp E/ACodec: Failed to
allocate buffers after transitioning to IDLE state (error 0xfffffff4)
06-06 10:16:33.761 28720-1438/com.digispeaker.rtsp E/ACodec:
signalError(omxError 0x80001001, internalError -12)
06-06 10:16:33.761 28720-1436/com.digispeaker.rtsp E/MediaCodec: Codec
reported err 0xfffffff4, actionCode 0, while in state 5
06-06 10:16:33.771 28720-29792/com.digispeaker.rtsp D/rtsp:
android.media.MediaCodec$CodecException: start failed
06-06 10:16:33.771 28720-29792/com.digispeaker.rtsp D/rtsp: Failed to
start codec (status = -542398533) with format {height=0, width=0,
mime=video/avc,
csd-1=java.nio.DirectByteBuffer[position=0,limit=7,capacity=7],
csd-0=java.nio.DirectByteBuffer[position=0,limit=26,capacity=26]}
06-06 10:16:33.771 28720-29792/com.digispeaker.rtsp D/rtsp: MediaCodec
0x7f96a8b180 failed to start
06-06 10:16:35.460 28720-29792/com.digispeaker.rtsp D/rtsp: Could not
open codec.

Video
ID                                       : 256 (0x100)
Menu ID                                  : 1 (0x1)
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : Main at L4.2
Format settings, CABAC                   : Yes
Format settings, ReFrames                : 1 frame
Format settings, GOP                     : M=1, N=50
Codec ID                                 : 27
Duration                                 : 9s 980ms
Bit rate                                 : 7 927 Kbps
Width                                    : 1 920 pixels
Height                                   : 1 080 pixels
Display aspect ratio                     : 16:9
Frame rate                               : 25.000 fps
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.153
Stream size                              : 9.45 MiB (95%)



LOGD("play");
const char *uri = env->GetStringUTFChars(j_uri, 0);
av_register_all();

av_log_set_callback(LogCallback);
av_log_set_level(AV_LOG_DEBUG);

AVFormatContext *ic = avformat_alloc_context();
if (env->GetJavaVM(&vm)) {
    LOGD("Failed to get java vm");
    return 1;
}

av_jni_set_java_vm(vm, ic);

AVDictionary * opts = nullptr;
av_dict_set(&opts, "rtsp_transport", "tcp", 0);
av_dict_set(&opts, "analyzeduration", "20000000", 0);
av_dict_set(&opts, "probesize", "20000000", 0);

// Open video file
if (avformat_open_input(&ic, uri, NULL, &opts) < 0) {
    LOGD("Couldn't open file:%s\n", uri);
    return -1; // Couldn't open file
}
env->ReleaseStringUTFChars(j_uri, uri);

// Retrieve stream information
if (avformat_find_stream_info(ic, NULL) < 0) {
    LOGD("Couldn't find stream information.");
    return -1;
}

// Find the first video stream
int videoStream = -1, i;
for (i = 0; i < ic->nb_streams; i++) {
    if (ic->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO
        && videoStream < 0) {
        videoStream = i;
    }
}
if (videoStream == -1) {
    LOGD("Didn't find a video stream.");
    return -1; // Didn't find a video stream
}

AVCodecContext *avctx;

avctx = avcodec_alloc_context3(NULL);
if (!avctx)
    return AVERROR(ENOMEM);

int ret = avcodec_parameters_to_context(avctx,
ic->streams[videoStream]->codecpar);
if (ret < 0)
    return AVERROR(ret);
av_codec_set_pkt_timebase(avctx, ic->streams[videoStream]->time_base);

// Find the decoder for the video stream
AVCodec *pCodec = avcodec_find_decoder(avctx->codec_id);
if (pCodec == NULL) {
    LOGD("Codec not found.");
    return -1; // Codec not found
}

if (avcodec_open2(avctx, pCodec, NULL) < 0) {
    LOGD("Could not open codec.");
    return -1; // Could not open codec
}

// Obtain native window
process_cb.nativeWindow = ANativeWindow_fromSurface(env, surface);

// Get video width and height
process_cb.videoWidth = avctx->width;
process_cb.videoHeight = avctx->height;

// Set the size of the native window buffer, can be automatically stretched
ANativeWindow_setBuffersGeometry(process_cb.nativeWindow,
process_cb.videoWidth, process_cb.videoHeight,
                                 WINDOW_FORMAT_RGBA_8888);

if (avcodec_open2(avctx, pCodec, NULL) < 0) {
    LOGD("Could not open codec.");
    return -1; // Could not open codec
}

// Allocate video frame
AVFrame *pFrame = av_frame_alloc();

// Used for rendering
process_cb.pFrameRGBA = av_frame_alloc();
if (process_cb.pFrameRGBA == NULL || pFrame == NULL) {
    LOGD("Could not allocate video frame.");
    return -1;
}

-- 
Jon Smirl
jonsmirl at gmail.com


More information about the Libav-user mailing list