-
Notifications
You must be signed in to change notification settings - Fork 188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(FfmpegOutput): add audio filter support #1039
feat(FfmpegOutput): add audio filter support #1039
Conversation
Hi Stephen, thanks very much for this PR. It all looks good to me, I just notice a couple of complaints from flake8 (which I often find to complain over nothing much, but we seem to be using it...). Would you be able to patch those little things up and then I'd be OK to merge. Thanks again! |
hey @davidplowman sorry for the late follow up here but i finally got around to linting these files - i also added some more context and helpful links to the added example as well does this still look good to merge in? |
407c295
to
12ac8a5
Compare
picamera2/outputs/ffmpegoutput.py
Outdated
@@ -70,7 +71,8 @@ def start(self): | |||
'-thread_queue_size', '1024', # necessary to prevent warnings | |||
'-i', self.audio_device] | |||
audio_codec = ['-b:a', str(self.audio_bitrate), | |||
'-c:a', self.audio_codec] | |||
'-c:a', self.audio_codec, | |||
-'af', self.audio_filter] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before I merge this, just one thing I wanted to understand. We're now setting the audio filter to pan=stereo
by default. Is this a change in behaviour, or was it doing the same thing before? (If it is a change, do you know what you would put to get the previous behaviour?) Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call, I intended this to be a sane default, but looking into it a bit more, if the input or soundcard is configured for mono, this would indeed change it to stereo (the -af
default will reflect the input signal/channel setup if nothing is provided to that argument). Its quite rare that a device nowadays would be mono, but im sure there are use-cases for that.
So I went ahead and removed the default parameter to pan=stereo
so it will have the same behavior as before, while allowing it to be customized if an arg is passed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we've still got the problem where audio_filter
is a required parameter, and causing a test failure. Could we put it back where it was (i.e. just before pts
, just in case anyone out there has hard-coded the order of all those audio parameters) and default it to None
. Then I think the code you've got after that looks good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done 💯
550f614
to
3f09d35
Compare
Signed-off-by: Stephen Grable <stephengrable@gmail.com>
3f09d35
to
372178e
Compare
Thank you very much!! |
tldr; this pr enables support for ffmpeg audio filters so it is easy to configure and customize audio recordings.
I do this by adding a new
audio_filter
parameter to theFfmpegOutput
interface which passes it to the-af
flag for audio configuration.ive also added a simple example where i convert a mono audio input into stereo while recording a 10 second video.
but you can also do cool things like add delay or add echo
Ps. thanks for the awesome library, i love the pdf documentation and in-depth examples, it has helped me a ton.