[FFmpeg-devel] [PATCH] doc/examples/demux_decode: update ffplay command for audio and video output (PR #20252)
ldm0
code at ffmpeg.org
Sat Aug 16 01:02:36 EEST 2025
PR #20252 opened by ldm0
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20252
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20252.patch
Signed-off-by: ldm0 <liudingming at bytedance.com>
From 0bb2f5f724d75171a7b87529fc1b1034669924ea Mon Sep 17 00:00:00 2001
From: ldm0 <liudingming at bytedance.com>
Date: Sat, 16 Aug 2025 06:01:26 +0800
Subject: [PATCH] doc/examples/demux_decode: update ffplay command for audio
and video output
Signed-off-by: ldm0 <liudingming at bytedance.com>
---
doc/examples/demux_decode.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/doc/examples/demux_decode.c b/doc/examples/demux_decode.c
index 64f5547bc4..e1dd7fa5df 100644
--- a/doc/examples/demux_decode.c
+++ b/doc/examples/demux_decode.c
@@ -336,15 +336,16 @@ int main (int argc, char **argv)
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",
+ "ffplay -f rawvideo -vf format=%s -video_size %dx%d %s\n",
av_get_pix_fmt_name(pix_fmt), width, height,
video_dst_filename);
}
if (audio_stream) {
enum AVSampleFormat sfmt = audio_dec_ctx->sample_fmt;
- int n_channels = audio_dec_ctx->ch_layout.nb_channels;
+ AVChannelLayout *ch_layout = &audio_dec_ctx->ch_layout;
const char *fmt;
+ char buf[64];
if (av_sample_fmt_is_planar(sfmt)) {
const char *packed = av_get_sample_fmt_name(sfmt);
@@ -352,15 +353,18 @@ int main (int argc, char **argv)
"(%s). This example will output the first channel only.\n",
packed ? packed : "?");
sfmt = av_get_packed_sample_fmt(sfmt);
- n_channels = 1;
+ ch_layout = &(AVChannelLayout)AV_CHANNEL_LAYOUT_MONO;
}
if ((ret = get_format_from_sample_fmt(&fmt, sfmt)) < 0)
goto end;
+ if ((ret = av_channel_layout_describe(ch_layout, buf, sizeof(buf))) < 0)
+ goto end;
+
printf("Play the output audio file with the command:\n"
- "ffplay -f %s -ac %d -ar %d %s\n",
- fmt, n_channels, audio_dec_ctx->sample_rate,
+ "ffplay -f %s -ch_layout %s -ar %d %s\n",
+ fmt, buf, audio_dec_ctx->sample_rate,
audio_dst_filename);
}
--
2.49.1
More information about the ffmpeg-devel
mailing list