[FFmpeg-user] amix with atempo: Inconsistent behaviour creating m4a with aac
swampy1956 at gmail.com
Fri Oct 13 00:36:53 EEST 2017
If this helps anyone, I made a discovery regarding amix with atempo and trim.
Here's my FFMPEG install on Mac OSX:
ffmpeg version 3.3.4 Copyright (c) 2000-2017 the FFmpeg developers
built with Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM
configuration: --prefix=/usr/local/Cellar/ffmpeg/3.3.4 --enable-shared
--enable-pthreads --enable-version3 --enable-hardcoded-tables
--enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-gpl
--enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame
--enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265
--enable-libxvid --enable-opencl --enable-videotoolbox --disable-lzma
libavutil 55. 58.100 / 55. 58.100
libavcodec 57. 89.100 / 57. 89.100
libavformat 57. 71.100 / 57. 71.100
libavdevice 57. 6.100 / 57. 6.100
libavfilter 6. 82.100 / 6. 82.100
libavresample 3. 5. 0 / 3. 5. 0
libswscale 4. 6.100 / 4. 6.100
libswresample 2. 7.100 / 2. 7.100
libpostproc 54. 5.100 / 54. 5.100
I was trying to mix audio from 3 different mp4's. This didn't work...
When trying to run the above I got the dreaded hung terminal. No error, just
got to this line and hung...
Started examining the differences in scaling, trim times, etc for each video
(these are being set in an app I'm building so they are variable) and here's
what I saw...
I tried all kinds of things until I discovered that the issue was with the
2nd video. I could change the atrim from 0:21.35 to 0:21 and it would work.
So, trying to figure out what was different, I notivced that scaling was 1.x
rather than 0.x for that video. Btw, the only reason I had broken up the
commands in the complex filter as it was the only way I could get any of it
to work earlier in testing. Here's what ended up working for all I've tested
The magic deal is this...
Whenever the audio is scaled up in time, iow, slowed down, you have to first
apply any trimming and then pass the scaling factor. Conversely, if it's
sped up, you have to first apply scaling (atempo), then calculate the
/relative/ trim values (based on the scaling factor) and apply the resulting
trim values to the scaled audio (in the chain).
Another thing I discovered is, if there's any time-scaling applied to any
video's audio at all, even if there's no time trim, you /have/ to include
the trim command but use the full length as the values. Eg, if it's a 5
second video, trim=0:5.
Sent from: http://www.ffmpeg-archive.org/
More information about the ffmpeg-user