- if (*got_frame) {
-
- if (frame->width != width || frame->height != height ||
- frame->format != pix_fmt) {
- /* To handle this change, one could call av_image_alloc again and
- * decode the following frames into another rawvideo file. */
- fprintf(stderr, "Error: Width, height and pixel format have to be "
- "constant in a rawvideo file, but the width, height or "
- "pixel format of the input video changed:\n"
- "old: width = %d, height = %d, format = %s\n"
- "new: width = %d, height = %d, format = %s\n",
- width, height, av_get_pix_fmt_name(pix_fmt),
- frame->width, frame->height,
- av_get_pix_fmt_name(frame->format));
- return -1;
- }
-
- printf("video_frame%s n:%d coded_n:%d\n",
- cached ? "(cached)" : "",
- video_frame_count++, frame->coded_picture_number);
-
- /* copy decoded frame to destination buffer:
- * this is required since rawvideo expects non aligned data */
- av_image_copy(video_dst_data, video_dst_linesize,
- (const uint8_t **)(frame->data), frame->linesize,
- pix_fmt, width, height);
-
- /* write to rawvideo file */
- fwrite(video_dst_data[0], 1, video_dst_bufsize, video_dst_file);
- }
- } else if (pkt.stream_index == audio_stream_idx) {
- /* decode audio frame */
- ret = avcodec_decode_audio4(audio_dec_ctx, frame, got_frame, &pkt);
- if (ret < 0) {
- fprintf(stderr, "Error decoding audio frame (%s)\n", av_err2str(ret));