summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorwm4 <nfxjfg@googlemail.com>2013-07-18 15:45:37 +0200
committerStefano Sabatini <stefasab@gmail.com>2013-07-19 12:14:54 +0200
commit72f5a6d0672ab02f19865966af28f027b839a222 (patch)
tree522f3bd5130bbf62b081070e3335d9073648c94c /doc
parent9f31c1608c7440e08d47294945752385632294b5 (diff)
examples: demuxing: print ffplay command even if sample format is planar
Adjust the code so that a working ffplay command is printed in the planar audio case.
Diffstat (limited to 'doc')
-rw-r--r--doc/examples/demuxing.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/doc/examples/demuxing.c b/doc/examples/demuxing.c
index acd2d413fa..e459cf003e 100644
--- a/doc/examples/demuxing.c
+++ b/doc/examples/demuxing.c
@@ -302,13 +302,25 @@ int main (int argc, char **argv)
}
if (audio_stream) {
+ enum AVSampleFormat sfmt = audio_dec_ctx->sample_fmt;
+ int n_channels = audio_dec_ctx->channels;
const char *fmt;
- if ((ret = get_format_from_sample_fmt(&fmt, audio_dec_ctx->sample_fmt)) < 0)
+ if (av_sample_fmt_is_planar(sfmt)) {
+ const char *packed = av_get_sample_fmt_name(sfmt);
+ printf("Warning: the sample format the decoder produced is planar "
+ "(%s). This example will output the first channel only.\n",
+ packed ? packed : "?");
+ sfmt = av_get_packed_sample_fmt(sfmt);
+ n_channels = 1;
+ }
+
+ if ((ret = get_format_from_sample_fmt(&fmt, sfmt)) < 0)
goto end;
+
printf("Play the output audio file with the command:\n"
"ffplay -f %s -ac %d -ar %d %s\n",
- fmt, audio_dec_ctx->channels, audio_dec_ctx->sample_rate,
+ fmt, n_channels, audio_dec_ctx->sample_rate,
audio_dst_filename);
}