[FFmpeg-devel] ffplay: fix order of operations for sdl audio open

Michael Niedermayer michaelni at gmx.at
Sun Oct 2 01:39:59 CEST 2011


On Sun, Oct 02, 2011 at 12:30:41AM +0200, Marton Balint wrote:
> On Sat, 1 Oct 2011, Michael Niedermayer wrote:
> 
> >On Sat, Oct 01, 2011 at 09:41:00PM +0200, Marton Balint wrote:
> >>Hi,
> >>
> >>The patch in the subject (3715e675) seems broken in some ways:
> >>
> >> - The sample rate / channel count sanity check is not against the
> >>   actually used sample rate / channel count.
> >>
> >> - Avctx->request_channels can affect the number of the channels,
> >>   therefore downmixing of 5.1 audio to stereo (default for ffplay)
> >>   currently does not work because of the patch.
> >>
> >>Isn't the aac decoder should be fixed instead of ffplay to return
> >>the proper number of channels after calling avcodec_open2?
> >
> >The aac decoder in this bug has incorrect extradata that lists a wrong
> >channel number, i saw no way it could detect this easily.
> >
> >my reasoning that lead to the commited fix was that av_find_stream_info()
> >figured out the correct channel number by decoding the first frame
> >and the requent_channel value should be passed to it.
> 
> How request_channels should be passed to av_find_stream_info? Via options?

see patch below, feel free to apply to your branch if you think its
usefull
once you confirm its all working ill merge it from there



> 
> >If this is done it should be more reliable than trusting the decoder
> >before it saw the first frame
> >
> >if you want to try or have a better idea:
> >rtsp://media2.lsops.net/live/aljazeer_en_high.sdp
> 
> Perhaps another approach is if we apply my audio patch, which is
> capable of downmixing or multiplying the audio channels as they
> change during decoding, and then set the number of SDL channels to
> 2.

Please see libswresample/swresample.h
its simpler & can handle many more channel layouts, planar audio, ...
also its the codebase on which future work will be done.

one distinctive disadvantage of not using request_channels is though
that decoders can sometimes return 2 channels with less cpu than
returning all and than seperately downmixing


> 
> I set up a github repository, you can find the patches there:
> 
> https://github.com/cus/ffplay.git

great, i will merge it when you say its ready


[...]

From e834139cae7d20687d94a6134e5343a7d6620867 Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <michaelni at gmx.at>
Date: Sun, 2 Oct 2011 01:25:14 +0200
Subject: [PATCH] ffplay: set request_channels to 2

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
---
 ffplay.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/ffplay.c b/ffplay.c
index 46eff5c..e04b69a 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -2379,6 +2379,8 @@ static int read_thread(void *arg)
     if(genpts)
         ic->flags |= AVFMT_FLAG_GENPTS;

+    av_dict_set(&codec_opts, "request_channels", "2", 0);
+
     opts = setup_find_stream_info_opts(ic, codec_opts);
     orig_nb_streams = ic->nb_streams;

--
1.7.4.1


-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Into a blind darkness they enter who follow after the Ignorance,
they as if into a greater darkness enter who devote themselves
to the Knowledge alone. -- Isha Upanishad
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20111002/bed7707a/attachment.asc>


More information about the ffmpeg-devel mailing list