enum {
};
{
*got_frame = 0;
if (ret < 0) {
fprintf(stderr,
"Error decoding video frame (%s)\n",
av_err2str(ret));
}
if (*got_frame) {
printf("video_frame%s n:%d coded_n:%d pts:%s\n",
cached ? "(cached)" : "",
}
if (ret < 0) {
fprintf(stderr,
"Error decoding audio frame (%s)\n",
av_err2str(ret));
}
if (*got_frame) {
printf("audio_frame%s n:%d nb_samples:%d pts:%s\n",
cached ? "(cached)" : "",
}
}
return decoded;
}
{
if (ret < 0) {
fprintf(stderr, "Could not find %s stream in input file '%s'\n",
} else {
st = fmt_ctx->
streams[*stream_idx];
if (!dec) {
fprintf(stderr, "Failed to find %s codec\n",
}
fprintf(stderr, "Failed to open %s codec\n",
}
}
return 0;
}
{
int i;
struct sample_fmt_entry {
} sample_fmt_entries[] = {
};
*fmt = NULL;
struct sample_fmt_entry *entry = &sample_fmt_entries[i];
if (sample_fmt == entry->sample_fmt) {
*fmt =
AV_NE(entry->fmt_be, entry->fmt_le);
return 0;
}
}
fprintf(stderr,
"sample format %s is not supported as output format\n",
return -1;
}
int main (
int argc,
char **argv)
{
int ret = 0, got_frame;
if (argc != 4 && argc != 5) {
fprintf(stderr, "usage: %s [-refcount=<old|new_norefcount|new_refcount>] "
"input_file video_output_file audio_output_file\n"
"API example program to show how to read frames from an input file.\n"
"This program reads frames from a file, decodes them, and writes decoded\n"
"video frames to a rawvideo file named video_output_file, and decoded\n"
"audio frames to a rawaudio file named audio_output_file.\n\n"
"If the -refcount option is specified, the program use the\n"
"reference counting frame system which allows keeping a copy of\n"
"the data for longer than one decode call. If unset, it's using\n"
"the classic old method.\n"
"\n", argv[0]);
exit(1);
}
if (argc == 5) {
const char *
mode = argv[1] + strlen(
"-refcount=");
else {
fprintf(stderr, "unknow mode '%s'\n", mode);
exit(1);
}
argv++;
}
fprintf(stderr,
"Could not open source file %s\n",
src_filename);
exit(1);
}
fprintf(stderr, "Could not find stream information\n");
exit(1);
}
video_dec_ctx = video_stream->
codec;
ret = 1;
}
if (ret < 0) {
fprintf(stderr, "Could not allocate raw video buffer\n");
}
}
ret = 1;
}
}
fprintf(stderr, "Could not find audio or video stream in the input, aborting\n");
ret = 1;
}
frame = avcodec_alloc_frame();
else
if (!frame) {
fprintf(stderr, "Could not allocate frame\n");
}
if (video_stream)
do {
if (ret < 0)
break;
}
do {
} while (got_frame);
printf("Demuxing succeeded.\n");
if (video_stream) {
printf("Play the output video file with the command:\n"
"ffplay -f rawvideo -pix_fmt %s -video_size %dx%d %s\n",
}
printf("Warning: the sample format the decoder produced is planar "
"(%s). This example will output the first channel only.\n",
packed ? packed : "?");
n_channels = 1;
}
printf("Play the output audio file with the command:\n"
"ffplay -f %s -ac %d -ar %d %s\n",
}
avcodec_free_frame(&frame);
else
return ret < 0;
}