Hi, In the attached program, we can see that the DTS sequence obtained, while decoding frame or not, differ. Sometimes there is no DTS (NO_OPTS_VALUE) but this doesn't happen if we do not decode the frames.
So, is there a bug in my attached program or does ffmpeg act strangely? Regards, -- Frédéric Jolliton
/* * With http://fjolliton.free.fr/1140096044413.wmv (2.3MB) * * When WITH_DECODE are defined, around the 50th packet: * * 1 18360 * 1 18440 * 1 18520 * 1 18600 * 1 18680 * 1 18760 * 1 18840 * * Without them: * * 1 18360 * 1 18440 * 1 18520 * 1 -9223372036854775808 * 1 18600 * 1 18680 * 1 18760 * * (where 1 is the stream index, followed by the packet DTS) */ #include <stdlib.h> #include <stdio.h> #include <assert.h> #include <libavformat/avformat.h> #define WITH_DECODE void die(char const* msg) { fprintf(stderr, "%s\n", msg); exit(1); } int main( int argc , char* argv[] ) { av_register_all(); avcodec_register_all(); //-------- Open input file -------- AVFormatContext* format ; if (av_open_input_file(&format, argv[1], 0, 0, 0) < 0) die("Unable to open input file"); if (av_find_stream_info(format) < 0) die("Error while looking for stream info"); //-------- Search first video stream -------- int stream_idx=-1; for (int i = 0; i < format->nb_streams; ++i ) { if (format->streams[i]->codec->codec_type == CODEC_TYPE_VIDEO) { stream_idx=i; break; } } if (stream_idx < 0) die("Unable to find a video stream"); //-------- Open the video codec -------- AVStream* stream = format->streams[stream_idx]; AVCodec* codec = avcodec_find_decoder(stream->codec->codec_id); if (!codec) die("Error while searching codec\n"); if (avcodec_open(stream->codec, codec) < 0) die("Error while opening codec\n"); //-------- Read packets, decoding video ones -------- AVFrame* frame = avcodec_alloc_frame(); int count=0; AVPacket packet; while (av_read_frame(format, &packet) >= 0) { if (packet.stream_index==stream_idx) { printf("%d %ld\n", packet.stream_index, (long)packet.dts); #ifdef WITH_DECODE int got_frame=0; int rc=avcodec_decode_video(stream->codec, frame, &got_frame, packet.data, packet.size); if (rc < 0 || rc != packet.size) die("Expected a whole frame\n"); #endif } av_free_packet(&packet); ++count; if (count == 50) break; } av_free(frame); avcodec_close(stream->codec); av_close_input_file(format); return 0; }
_______________________________________________ libav-user mailing list [email protected] https://lists.mplayerhq.hu/mailman/listinfo/libav-user
