71     int decoded = pkt.
size;
 
   79             fprintf(stderr, 
"Error decoding video frame (%s)\n", 
av_err2str(ret));
 
   84             printf(
"video_frame%s n:%d coded_n:%d pts:%s\n",
 
   85                    cached ? 
"(cached)" : 
"",
 
  102             fprintf(stderr, 
"Error decoding audio frame (%s)\n", 
av_err2str(ret));
 
  113             printf(
"audio_frame%s n:%d nb_samples:%d pts:%s\n",
 
  114                    cached ? 
"(cached)" : 
"",
 
  149         fprintf(stderr, 
"Could not find %s stream in input file '%s'\n",
 
  154         st = fmt_ctx->
streams[*stream_idx];
 
  160             fprintf(stderr, 
"Failed to find %s codec\n",
 
  169             fprintf(stderr, 
"Failed to open %s codec\n",
 
  182     struct sample_fmt_entry {
 
  184     } sample_fmt_entries[] = {
 
  194         struct sample_fmt_entry *entry = &sample_fmt_entries[i];
 
  195         if (sample_fmt == entry->sample_fmt) {
 
  196             *fmt = 
AV_NE(entry->fmt_be, entry->fmt_le);
 
  202             "sample format %s is not supported as output format\n",
 
  207 int main (
int argc, 
char **argv)
 
  209     int ret = 0, got_frame;
 
  211     if (argc != 4 && argc != 5) {
 
  212         fprintf(stderr, 
"usage: %s [-refcount=<old|new_norefcount|new_refcount>] " 
  213                 "input_file video_output_file audio_output_file\n" 
  214                 "API example program to show how to read frames from an input file.\n" 
  215                 "This program reads frames from a file, decodes them, and writes decoded\n" 
  216                 "video frames to a rawvideo file named video_output_file, and decoded\n" 
  217                 "audio frames to a rawaudio file named audio_output_file.\n\n" 
  218                 "If the -refcount option is specified, the program use the\n" 
  219                 "reference counting frame system which allows keeping a copy of\n" 
  220                 "the data for longer than one decode call. If unset, it's using\n" 
  221                 "the classic old method.\n" 
  226         const char *
mode = argv[1] + strlen(
"-refcount=");
 
  231             fprintf(stderr, 
"unknow mode '%s'\n", mode);
 
  245         fprintf(stderr, 
"Could not open source file %s\n", 
src_filename);
 
  251         fprintf(stderr, 
"Could not find stream information\n");
 
  257         video_dec_ctx = video_stream->
codec;
 
  271             fprintf(stderr, 
"Could not allocate raw video buffer\n");
 
  292         fprintf(stderr, 
"Could not find audio or video stream in the input, aborting\n");
 
  300         frame = avcodec_alloc_frame();
 
  304         fprintf(stderr, 
"Could not allocate frame\n");
 
  328         } 
while (pkt.
size > 0);
 
  339     printf(
"Demuxing succeeded.\n");
 
  342         printf(
"Play the output video file with the command:\n" 
  343                "ffplay -f rawvideo -pix_fmt %s -video_size %dx%d %s\n",
 
  355             printf(
"Warning: the sample format the decoder produced is planar " 
  356                    "(%s). This example will output the first channel only.\n",
 
  357                    packed ? packed : 
"?");
 
  365         printf(
"Play the output audio file with the command:\n" 
  366                "ffplay -f %s -ac %d -ar %d %s\n",
 
  380         avcodec_free_frame(&frame);