对于 h.264 解码器,"invalid NAL unit size" 是什么意思?
What does it mean "invalid NAL unit size" for h.264 decoder?
我想使用 Libav 将 .mkv 文件转换为 .mp4,但是当我尝试解码视频 h.264 流时,我的代码出现故障
Invalid NAL unit size 21274662>141
Error splitting the input into NAL units
The stream seems to contain AVCC extradata with Annex B formatted data which is invalid.
no frame!
Could not send paket for decoding ("error invalid data when processing input")
下面提供了相关的代码部分。
while(!(ret = av_read_frame(ifmt_ctx, &input_packet))&&(ret>=0)){
if ((ret = avcodec_send_packet(avctx, &input_packet)) < 0) {
fprintf(stderr, "Could not send packet for decoding (error '%s')\n",get_error_text(ret));
return ret;
}
ret = avcodec_receive_frame(avctx, iframe);
if (ret == AVERROR(EAGAIN)) {
goto read_another_frame;
/* If the end of the input file is reached, stop decoding. */
} else if (ret == AVERROR_EOF) {
break;
} else if (ret < 0) {
fprintf(stderr, "Could not decode frame (error '%s')\n",get_error_text(ret));
break;
}
// Default case: encode data
else {
}
我主要使用新的 API(发送/接收数据包/帧)并且存在混淆,因为 h.264 似乎需要特殊的实现。我期待着从哪里开始调试的任何想法。
表示ES格式与容器不兼容。读这个:Possible Locations for Sequence/Picture Parameter Set(s) for H.264 Stream
我认为这是因为您没有检查数据包是否来自视频流。换句话说,您的代码将所有流中的所有数据包发送到 h.264 编解码器。
在这种情况下,解决问题的方法是添加一个简单的条件来跳过非视频流数据包:
if (input_packet->stream_index != video_stream->index) continue;
假设 video_stream 是格式上下文流数组中遇到的第一个视频流 ifmt_ctx->streams .
我想使用 Libav 将 .mkv 文件转换为 .mp4,但是当我尝试解码视频 h.264 流时,我的代码出现故障
Invalid NAL unit size 21274662>141
Error splitting the input into NAL units
The stream seems to contain AVCC extradata with Annex B formatted data which is invalid. no frame!
Could not send paket for decoding ("error invalid data when processing input")
下面提供了相关的代码部分。
while(!(ret = av_read_frame(ifmt_ctx, &input_packet))&&(ret>=0)){
if ((ret = avcodec_send_packet(avctx, &input_packet)) < 0) {
fprintf(stderr, "Could not send packet for decoding (error '%s')\n",get_error_text(ret));
return ret;
}
ret = avcodec_receive_frame(avctx, iframe);
if (ret == AVERROR(EAGAIN)) {
goto read_another_frame;
/* If the end of the input file is reached, stop decoding. */
} else if (ret == AVERROR_EOF) {
break;
} else if (ret < 0) {
fprintf(stderr, "Could not decode frame (error '%s')\n",get_error_text(ret));
break;
}
// Default case: encode data
else {
}
我主要使用新的 API(发送/接收数据包/帧)并且存在混淆,因为 h.264 似乎需要特殊的实现。我期待着从哪里开始调试的任何想法。
表示ES格式与容器不兼容。读这个:Possible Locations for Sequence/Picture Parameter Set(s) for H.264 Stream
我认为这是因为您没有检查数据包是否来自视频流。换句话说,您的代码将所有流中的所有数据包发送到 h.264 编解码器。
在这种情况下,解决问题的方法是添加一个简单的条件来跳过非视频流数据包:
if (input_packet->stream_index != video_stream->index) continue;
假设 video_stream 是格式上下文流数组中遇到的第一个视频流 ifmt_ctx->streams .