How to overlay/downmix two audio files using ffmpeg

stereo + stereo → stereo Normal downmix Use the amix filter: ffmpeg -i input0.mp3 -i input1.mp3 -filter_complex amix=inputs=2:duration=longest output.mp3 Or the amerge filter: ffmpeg -i input0.mp3 -i input1.mp3 -filter_complex amerge=inputs=2 -ac 2 output.mp3 Downmix each input into specific output channel Use the amerge and pan filters: ffmpeg -i input0.mp3 -i input1.mp3 -filter_complex “amerge=inputs=2,pan=stereo|c0<c0+c1|c1<c2+c3” output.mp3 mono … Read more

Playing an arbitrary tone with Android

I originally found this example code on a blog, but it had some bugs in it that generated some horrendous sounds. I’ve fixed the bugs and posted the resulting code here. Seems to work well for me! public class PlaySound extends Activity { // originally from http://marblemice.blogspot.com/2010/04/generate-and-play-tone-in-android.html // and modified by Steve Pomeroy <steve@staticfree.info> private … Read more

FFMPEG mux video and audio (from another video) – mapping issue

Overview of inputs input_0.mp4 has the desired video stream and input_1.mp4 has the desired audio stream: In ffmpeg the streams look like this: $ ffmpeg -i input_0.mp4 -i input_1.mp4 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from ‘input_0.mp4’: Duration: 00:01:48.50, start: 0.000000, bitrate: 4144 kb/s Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280×720, 4014 kb/s, SAR 115:87 … Read more

Play audio from a stream using C#

Edit: Answer updated to reflect changes in recent versions of NAudio It’s possible using the NAudio open source .NET audio library I have written. It looks for an ACM codec on your PC to do the conversion. The Mp3FileReader supplied with NAudio currently expects to be able to reposition within the source stream (it builds … Read more

Creating and playing a sound in swift

This is similar to some other answers, but perhaps a little more “Swifty”: // Load “mysoundname.wav” if let soundURL = Bundle.main.url(forResource: “mysoundname”, withExtension: “wav”) { var mySound: SystemSoundID = 0 AudioServicesCreateSystemSoundID(soundURL as CFURL, &mySound) // Play AudioServicesPlaySystemSound(mySound); } Note that this is a trivial example reproducing the effect of the code in the question. You’ll … Read more

Play a Sound with Python [duplicate]

For Windows, you can use winsound. It’s built in import winsound winsound.PlaySound(‘sound.wav’, winsound.SND_FILENAME) You should be able to use ossaudiodev for linux: from wave import open as waveOpen from ossaudiodev import open as ossOpen s = waveOpen(‘tada.wav’,’rb’) (nc,sw,fr,nf,comptype, compname) = s.getparams( ) dsp = ossOpen(‘/dev/dsp’,’w’) try: from ossaudiodev import AFMT_S16_NE except ImportError: from sys import … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)