ffmpeg-libav-tutorial
ffmpeg-libav-tutorial copied to clipboard
Getting error when running. (Close to the end of the 0-hello-world)
Followed exactly how you tolled. I'm new to ffmpeg and concepts like these in general. So, the error might be very simple. And then getting this error for some reason.
[h264 @ 0x55c2ee4fd540] Error splitting the input into NAL units.
[h264 @ 0x55c2ee4fd540] Invalid NAL unit size (555390181 > 470).
[h264 @ 0x55c2ee4fd540] Error splitting the input into NAL units.
[h264 @ 0x55c2ee4fd540] Invalid NAL unit size (555390197 > 445).
[h264 @ 0x55c2ee4fd540] Error splitting the input into NAL units.
[h264 @ 0x55c2ee4fd540] Invalid NAL unit size (554341645 > 433).
[h264 @ 0x55c2ee4fd540] Error splitting the input into NAL units.
[h264 @ 0x55c2ee4fd540] Invalid NAL unit size (554341573 > 424).
this is a part of the error. As similar to this line is coming infinitely with different values of before and after >. I ran the code you provided and it just ran fine. Here is my code:
int main(int argc, char *argv[]) {
AVFormatContext *format_context = avformat_alloc_context();
if (avformat_open_input(&format_context, "video.mp4", NULL, NULL)) {
printf("failed to load video\n");
return EXIT_FAILURE;
}
printf("Format : %s\n"
"Duration: %ld\n", format_context->iformat->long_name, format_context->duration);
avformat_find_stream_info(format_context, NULL);
printf("Stream Count: %u\n", format_context->nb_streams);
for (int i = 0; i < format_context->nb_streams; i++) {
AVCodecParameters *local_codec_parameters = format_context->streams[i]->codecpar;
const AVCodec *local_codec = avcodec_find_decoder(local_codec_parameters->codec_id);
if (local_codec_parameters->codec_type == AVMEDIA_TYPE_VIDEO) {
printf("Video Codec: %dx%d\n", local_codec_parameters->width, local_codec_parameters->height);
}
else if (local_codec_parameters->codec_type == AVMEDIA_TYPE_AUDIO) {
printf("Audio Codec: %d channels, sample rate: %d\n", local_codec_parameters->channels, local_codec_parameters->sample_rate);
}
AVCodecContext *codec_context = avcodec_alloc_context3(local_codec);
avcodec_parameters_to_context(codec_context, local_codec_parameters);
avcodec_open2(codec_context, local_codec, NULL);
AVPacket *packet = av_packet_alloc();
AVFrame *frame = av_frame_alloc();
while (av_read_frame(format_context, packet) >= 0) {
avcodec_send_packet(codec_context, packet);
avcodec_receive_frame(codec_context, frame);
}
printf("Frame: %c (%d)\n PTS %ld, DTS %ld, Key_Frame %d [Codec_Picture_Count %d, Display_Picture_Count %d]",
av_get_picture_type_char(frame->pict_type),
codec_context->frame_number,
frame->pts,
frame->pkt_dts,
frame->key_frame,
frame->coded_picture_number,
frame->display_picture_number);
}
return 0;
}
Sorry for not commenting any line. Thanks.
Hey π @MubinMuhammad
Are you compiling/running it locally? or using docker as suggested?
Thanks
Compiling/Running it locally.
Closing