ffmpeg throw a silent video output when trying to merge video and audio - audio

I tried to combine mp4 format video and wav format audio.
The video is shorter than the audio and start second is same as 00:00.
I used command as bellows:
ffmpeg -i video.mp4 -i audio.wav -filter_complex "[0:a]volume=0.2[A];[1:a][A]amerge[Aout]" -map 0:v -map [Aout] -y -shortest output_video.mp4
The problem is the output_video.mp4 is a silent video without the sound.
How can I get the output_video.mp4 with sound from audio.wav?
ffmpeg output is:
ffmpeg version 4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 7.3.0 (crosstool-NG 1.23.0.449-a04d0)
configuration: --prefix=/tmp/build/80754af9/ffmpeg_1587154242452/\_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeho --cc=/tmp/build/80754af9/ffmpeg_1587154242452/\_build_env/bin/x86_64-conda_cos6-linux-gnu-cc --disable-doc --enable-avresample --enable-gmp --enable-hardcoded-tables --enable-libfreetype --enable-libvpx --enable-pthreads --enable-libopus --enable-postproc --enable-pic --enable-pthreads --enable-shared --enable-static --enable-version3 --enable-zlib --enable-libmp3lame --disable-nonfree --enable-gpl --enable-gnutls --disable-openssl --enable-libopenh264 --enable-libx264
libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'video.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.29.100
Duration: 00:00:19.04, start: 0.000000, bitrate: 510 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720, 373 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
handler_name : SoundHandler
Guessed Channel Layout for Input Stream #1.0 : mono
Input #1, wav, from 'audio.wav':
Duration: 00:00:14.70, bitrate: 352 kb/s
Stream #1:0: Audio: pcm_s16le (\[1\]\[0\]\[0\]\[0\] / 0x0001), 22050 Hz, mono, s16, 352 kb/s
Stream mapping:
Stream #0:1 (aac) -\> volume (graph 0)
Stream #1:0 (pcm_s16le) -\> amerge:in0 (graph 0)
Stream #0:0 -\> #0:0 (h264 (native) -\> h264 (libx264))
amerge (graph 0) -\> Stream #0:1 (aac)
Press \[q\] to stop, \[?\] for help
\[libx264 # 0x55aa9a642ac0\] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2 AVX512
\[libx264 # 0x55aa9a642ac0\] profile High, level 3.1, 4:2:0, 8-bit
\[libx264 # 0x55aa9a642ac0\] 264 - core 157 - H.264/MPEG-4 AVC codec - Copyleft 2003-2018 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=22 lookahead_threads=3 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
\[Parsed_amerge_1 # 0x55aa9b37c140\] No channel layout for input 1
Output #0, mp4, to 'output_video.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.29.100
Stream #0:0(und): Video: h264 (libx264) (avc1 / 0x31637661), yuv420p(progressive), 1280x720, q=-1--1, 30 fps, 15360 tbn, 30 tbc (default)
Metadata:
handler_name : VideoHandler
encoder : Lavc58.54.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 22050 Hz, 3.0, fltp, 197 kb/s (default)
Metadata:
encoder : Lavc58.54.100 aac
frame= 507 fps=291 q=-1.0 Lsize= 1116kB time=00:00:16.80 bitrate= 544.3kbits/s speed=9.64x
video:760kB audio:342kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.242977%
\[libx264 # 0x55aa9a642ac0\] frame I:3 Avg QP:16.24 size: 19770
\[libx264 # 0x55aa9a642ac0\] frame P:154 Avg QP:20.29 size: 3227
\[libx264 # 0x55aa9a642ac0\] frame B:350 Avg QP:19.84 size: 633
\[libx264 # 0x55aa9a642ac0\] consecutive B-frames: 0.6% 15.8% 18.9% 64.7%
\[libx264 # 0x55aa9a642ac0\] mb I I16..4: 23.5% 67.4% 9.1%
\[libx264 # 0x55aa9a642ac0\] mb P I16..4: 0.7% 3.0% 0.3% P16..4: 13.0% 3.1% 1.0% 0.0% 0.0% skip:78.8%
\[libx264 # 0x55aa9a642ac0\] mb B I16..4: 0.2% 0.1% 0.0% B16..8: 10.4% 0.3% 0.0% direct: 0.6% skip:88.3% L0:41.5% L1:57.2% BI: 1.3%
\[libx264 # 0x55aa9a642ac0\] 8x8 transform intra:68.2% inter:81.9%
\[libx264 # 0x55aa9a642ac0\] coded y,uvDC,uvAC intra: 24.6% 22.9% 6.1% inter: 1.2% 1.7% 0.0%
\[libx264 # 0x55aa9a642ac0\] i16 v,h,dc,p: 68% 16% 6% 10%
\[libx264 # 0x55aa9a642ac0\] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 24% 10% 50% 2% 2% 3% 2% 4% 3%
\[libx264 # 0x55aa9a642ac0\] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 32% 25% 13% 5% 5% 6% 5% 6% 4%
\[libx264 # 0x55aa9a642ac0\] i8c dc,h,v,p: 75% 10% 12% 2%
\[libx264 # 0x55aa9a642ac0\] Weighted P-Frames: Y:0.0% UV:0.0%
\[libx264 # 0x55aa9a642ac0\] ref P L0: 65.9% 16.2% 13.5% 4.4%
\[libx264 # 0x55aa9a642ac0\] ref B L0: 84.1% 13.4% 2.5%
\[libx264 # 0x55aa9a642ac0\] ref B L1: 97.1% 2.9%
\[libx264 # 0x55aa9a642ac0\] kb/s:368.24
\[aac # 0x55aa9a62a280\] Qavg: 8290.713

There's no need to mess about with filter_complex, you are not changing anything. You simply want to map the video from one source to the audio from another.
ffmpeg -i input.mp4 -i input.wav -shortest -map 0:v -map 1:a out.mp4
should achieve what you require.

Related

How to include audio in an overlay ffmpeg command?

Using ffmpeg I add a video overlay successfully over an origin video (origin has audio, overlay doesn't). However the audio of the origin video doesn't appear in the result video.
ffmpeg -i source.mp4 -i overlay.mp4 -filter_complex "[0:v]setpts=PTS-STARTPTS, scale=1280x720[top];
[1:v]setpts=PTS-STARTPTS, scale=1280x720, format=yuva420p,
colorchannelmixer=aa=0.2[bottom]; [top][bottom]overlay=shortest=1"
-shortest -acodec copy -vcodec libx264 result1.mp4
Even if I execute the following separate command on the result of the previous command - still no audio appears in the new result video.
ffmpeg -i result1.mp4 -i audio.mp3 -c:v copy -c:a aac result2.mp4
Here is the log:
ffmpeg version 4.4 Copyright (c) 2000-2021 the FFmpeg developers
built with Apple clang version 11.0.0 (clang-1100.0.33.17)
configuration: --prefix=/usr/local/Cellar/ffmpeg/4.4 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-videotoolbox
libavutil 56. 70.100 / 56. 70.100
libavcodec 58.134.100 / 58.134.100
libavformat 58. 76.100 / 58. 76.100
libavdevice 58. 13.100 / 58. 13.100
libavfilter 7.110.100 / 7.110.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 9.100 / 5. 9.100
libswresample 3. 9.100 / 3. 9.100
libpostproc 55. 9.100 / 55. 9.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'course/final_video/3008_01_01_01_audio.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.76.100
Duration: 00:06:01.48, start: 0.000000, bitrate: 215 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 141 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
Metadata:
handler_name : VideoHandler
vendor_id : [0][0][0][0]
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 22050 Hz, mono, fltp, 70 kb/s (default)
Metadata:
handler_name : SoundHandler
vendor_id : [0][0][0][0]
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'images/overlay.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.76.100
Duration: 00:24:00.38, start: 0.000000, bitrate: 575 kb/s
Stream #1:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1280x720 [SAR 1:1 DAR 16:9], 442 kb/s, 24 fps, 24 tbr, 12288 tbn, 48 tbc (default)
Metadata:
handler_name : ISO Media file produced by Google Inc. Created on: 11/22/2020.
vendor_id : [0][0][0][0]
Stream #1:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 127 kb/s (default)
Metadata:
handler_name : ISO Media file produced by Google Inc. Created on: 11/22/2020.
vendor_id : [0][0][0][0]
Stream mapping:
Stream #0:0 (h264) -> setpts
Stream #1:0 (h264) -> setpts
overlay -> Stream #0:0 (libx264)
Stream #1:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[swscaler # 0x10c590000] No accelerated colorspace conversion found from yuva420p to argb.
[libx264 # 0x7fc532813200] using SAR=1/1
[libx264 # 0x7fc532813200] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 # 0x7fc532813200] profile High, level 3.1, 4:2:0, 8-bit
[libx264 # 0x7fc532813200] 264 - core 161 r3049 55d517b - H.264/MPEG-4 AVC codec - Copyleft 2003-2021 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'course/final_video/3008_01_01_01_overlay.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.76.100
Stream #0:0: Video: h264 (avc1 / 0x31637661), yuv420p(progressive), 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 25 fps, 12800 tbn (default)
Metadata:
encoder : Lavc58.134.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 127 kb/s (default)
Metadata:
handler_name : ISO Media file produced by Google Inc. Created on: 11/22/2020.
vendor_id : [0][0][0][0]
Stream mapping:
Stream #0:0 (h264) -> setpts
Stream #1:0 (h264) -> setpts
overlay -> Stream #0:0 (libx264)
Stream #1:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[swscaler # 0x10c590000] No accelerated colorspace conversion found from yuva420p to argb.
[libx264 # 0x7fc532813200] using SAR=1/1
[libx264 # 0x7fc532813200] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 # 0x7fc532813200] profile High, level 3.1, 4:2:0, 8-bit
[libx264 # 0x7fc532813200] 264 - core 161 r3049 55d517b - H.264/MPEG-4 AVC codec - Copyleft 2003-2021 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'course/final_video/3008_01_01_01_overlay.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.76.100
Stream #0:0: Video: h264 (avc1 / 0x31637661), yuv420p(progressive), 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 25 fps, 12800 tbn (default)
Metadata:
encoder : Lavc58.134.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 127 kb/s (default)
Metadata:
handler_name : ISO Media file produced by Google Inc. Created on: 11/22/2020.
vendor_id : [0][0][0][0]
frame= 9037 fps= 32 q=-1.0 Lsize= 20954kB time=00:06:01.62 bitrate= 474.7kbits/s speed=1.26x
video:15006kB audio:5651kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.439596%
[libx264 # 0x7fc532813200] frame I:37 Avg QP:14.51 size:123799
[libx264 # 0x7fc532813200] frame P:2277 Avg QP:16.97 size: 3221
[libx264 # 0x7fc532813200] frame B:6723 Avg QP:24.31 size: 513
[libx264 # 0x7fc532813200] consecutive B-frames: 0.8% 0.0% 0.0% 99.2%
[libx264 # 0x7fc532813200] mb I I16..4: 8.3% 64.9% 26.9%
[libx264 # 0x7fc532813200] mb P I16..4: 0.5% 1.1% 0.2% P16..4: 16.1% 3.1% 2.3% 0.0% 0.0% skip:76.7%
[libx264 # 0x7fc532813200] mb B I16..4: 0.0% 0.0% 0.0% B16..8: 10.5% 0.1% 0.0% direct: 0.2% skip:89.2% L0:45.2% L1:54.7% BI: 0.1%
[libx264 # 0x7fc532813200] 8x8 transform intra:63.6% inter:83.0%
[libx264 # 0x7fc532813200] coded y,uvDC,uvAC intra: 56.4% 61.0% 42.7% inter: 1.9% 1.9% 0.0%
[libx264 # 0x7fc532813200] i16 v,h,dc,p: 29% 18% 18% 35%
[libx264 # 0x7fc532813200] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 24% 19% 31% 4% 4% 4% 4% 5% 5%
[libx264 # 0x7fc532813200] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 32% 22% 15% 4% 5% 6% 5% 5% 5%
[libx264 # 0x7fc532813200] i8c dc,h,v,p: 51% 29% 14% 6%
[libx264 # 0x7fc532813200] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 # 0x7fc532813200] ref P L0: 66.0% 6.9% 17.0% 10.1%
[libx264 # 0x7fc532813200] ref B L0: 77.2% 20.6% 2.2%
[libx264 # 0x7fc532813200] ref B L1: 90.2% 9.8%
[libx264 # 0x7fc532813200] kb/s:340.06
Tell it which audio you want with -map:
ffmpeg -i source.mp4 -i overlay.mp4 -filter_complex "[0:v]setpts=PTS-STARTPTS, scale=1280x720[top];
[1:v]setpts=PTS-STARTPTS, scale=1280x720, format=yuva420p,
colorchannelmixer=aa=0.2[bottom]; [top][bottom]overlay=shortest=1[v]"
-map "[v]" -map 0:a -shortest -acodec copy -vcodec libx264 result1.mp4
See FFmpeg Wiki: Map.
Your original command did not use -map so automatic stream selection was enabled. This will choose the stream with the most channels which was the audio from overlay.mp4 (Stream #1:1).

ffmpeg xfade not working well with acrossfade

I'm having trouble using xfade together with acrossfade.
I have two videos t1.mp4 and t2.mp4 of same fps, resolution and so on. Both videos are 15 seconds long.
Now I want a one-second fade transition in between.
Without acrossfade,
ffmpeg -i t1.mp4 -i t2.mp4 -filter_complex "xfade=transition=fade:duration=1:offset=14,format=yuv420p" output.mp4
after checking all the frames, the transition looks good. There are some overlapped frames with fading effect.
Please see below two consecutive frames.
But the second part of the result has no audio, that's why I decide to use acrossfade.
ffmpeg -i t1.mp4 -i t2.mp4 -filter_complex "xfade=transition=fade:duration=1:offset=14,format=yuv420p;acrossfade=d=1" output.mp4
Now it seems the transition effect is incomplete, there are less overlapped frames with fading effect, and the transition is sharp. Please see below two consecutive frames, same frame nubmer as above.
What am I missing here please?
ffmpeg -i t1.mp4 -i t2.mp4 -filter_complex "xfade=transition=fade:duration=1:offset=14,format=yuv420p;acrossfade=d=1" output.mp4
ffmpeg version 4.3.1-static https://johnvansickle.com/ffmpeg/ Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 8 (Debian 8.3.0-6)
configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gmp --enable-libgme --enable-gray --enable-libaom --enable-libfribidi --enable-libass --enable-libvmaf --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libdav1d --enable-libxvid --enable-libzvbi --enable-libzimg
libavutil 56. 51.100 / 56. 51.100
libavcodec 58. 91.100 / 58. 91.100
libavformat 58. 45.100 / 58. 45.100
libavdevice 58. 10.100 / 58. 10.100
libavfilter 7. 85.100 / 7. 85.100
libswscale 5. 7.100 / 5. 7.100
libswresample 3. 7.100 / 3. 7.100
libpostproc 55. 7.100 / 55. 7.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 't1.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.29.100
Duration: 00:00:15.02, start: 0.000000, bitrate: 2447 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 2315 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
handler_name : SoundHandler
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 't2.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.29.100
Duration: 00:00:15.02, start: 0.000000, bitrate: 1643 kb/s
Stream #1:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 1509 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #1:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
handler_name : SoundHandler
Stream mapping:
Stream #0:0 (h264) -> xfade:main
Stream #0:1 (aac) -> acrossfade:crossfade0
Stream #1:0 (h264) -> xfade:xfade
Stream #1:1 (aac) -> acrossfade:crossfade1
format -> Stream #0:0 (libx264)
acrossfade -> Stream #0:1 (aac)
Press [q] to stop, [?] for help
[libx264 # 0x5963dc0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 # 0x5963dc0] profile High, level 4.0, 4:2:0, 8-bit
[libx264 # 0x5963dc0] 264 - core 161 r3018 db0d417 - H.264/MPEG-4 AVC codec - Copyleft 2003-2020 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=34 lookahead_threads=5 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'output.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.45.100
Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p(progressive), 1920x1080, q=-1--1, 25 fps, 12800 tbn, 25 tbc (default)
Metadata:
encoder : Lavc58.91.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
encoder : Lavc58.91.100 aac
frame= 726 fps= 69 q=-1.0 Lsize= 7114kB time=00:00:29.00 bitrate=2009.4kbits/s dup=1 drop=0 speed=2.76x
video:6633kB audio:456kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.351093%
[libx264 # 0x5963dc0] frame I:8 Avg QP:16.38 size: 96958
[libx264 # 0x5963dc0] frame P:319 Avg QP:19.49 size: 14630
[libx264 # 0x5963dc0] frame B:399 Avg QP:23.99 size: 3379
[libx264 # 0x5963dc0] consecutive B-frames: 4.5% 63.6% 8.7% 23.1%
[libx264 # 0x5963dc0] mb I I16..4: 16.4% 61.0% 22.6%
[libx264 # 0x5963dc0] mb P I16..4: 3.5% 9.8% 0.7% P16..4: 26.6% 4.9% 1.9% 0.0% 0.0% skip:52.5%
[libx264 # 0x5963dc0] mb B I16..4: 0.3% 0.6% 0.2% B16..8: 13.8% 0.9% 0.1% direct: 0.9% skip:83.1% L0:44.1% L1:52.3% BI: 3.6%
[libx264 # 0x5963dc0] 8x8 transform intra:67.2% inter:81.6%
[libx264 # 0x5963dc0] coded y,uvDC,uvAC intra: 26.3% 38.2% 8.9% inter: 3.2% 5.8% 0.1%
[libx264 # 0x5963dc0] i16 v,h,dc,p: 43% 25% 15% 17%
[libx264 # 0x5963dc0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 34% 17% 37% 2% 2% 2% 2% 3% 2%
[libx264 # 0x5963dc0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 29% 19% 14% 6% 7% 7% 6% 6% 5%
[libx264 # 0x5963dc0] i8c dc,h,v,p: 60% 19% 18% 3%
[libx264 # 0x5963dc0] Weighted P-Frames: Y:0.9% UV:0.9%
[libx264 # 0x5963dc0] ref P L0: 69.4% 7.6% 17.5% 5.5% 0.0%
[libx264 # 0x5963dc0] ref B L0: 85.1% 12.9% 2.1%
[libx264 # 0x5963dc0] ref B L1: 99.0% 1.0%
[libx264 # 0x5963dc0] kb/s:1870.80
[aac # 0x58bb580] Qavg: 174.733
fixed by separating the video and audio track.
ffmpeg -i t1.mp4 -i t2.mp4 -filter_complex "[0:v][1:v]xfade=transition=fadeblack:duration=1.000:offset=8.960,format=yuv420p[video];[0:a][1:a]acrossfade=d=1.000:c1=tri:c2=tri[audio]" -map [video] -map [audio] -movflags +faststart output.mp4
There is an open bug report for a similar issue that I've stumbled upon, in which separating video and audio does not solve the problem.
Here, the only reliable workaround was to process the audio completely separately from the video, in another ffmpeg command, and later merge it via stream-copying, e.g.:
ffmpeg -i t1.mp4 -i t2.mp4 -filter_complex "[0:v][1:v]xfade=transition=fadeblack:duration=1.000:offset=8.960,format=yuv420p[video]" -an video.mp4
ffmpeg -i t1.mp4 -i t2.mp4 -filter_complex "[0:a][1:a]acrossfade=d=1.000:c1=tri:c2=tri[audio]" -vn audio.m4a
ffmpeg -i video.mp4 -i audio.m4a -c copy -movflags +faststart output.mp4

ffmpeg xfade audio out of sync

hi I am using ffmpeg xfade to concat two clips, the transition looks fine, but the second clip has no audio in the output. I don't find more information about this in https://trac.ffmpeg.org/wiki/Xfade and the official doc. Can I keep the audio of both clips in sync?
I'm puttting the complete log below, it's massive
ffmpeg -i teacher1.mp4 -i teacher2.mp4 -filter_complex xfade=transition=fadewhite:duration=1:offset=14.5 output.mp4
ffmpeg version 4.3.1-static https://johnvansickle.com/ffmpeg/ Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 8 (Debian 8.3.0-6)
configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gmp --enable-libgme --enable-gray --enable-libaom --enable-libfribidi --enable-libass --enable-libvmaf --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libdav1d --enable-libxvid --enable-libzvbi --enable-libzimg
libavutil 56. 51.100 / 56. 51.100
libavcodec 58. 91.100 / 58. 91.100
libavformat 58. 45.100 / 58. 45.100
libavdevice 58. 10.100 / 58. 10.100
libavfilter 7. 85.100 / 7. 85.100
libswscale 5. 7.100 / 5. 7.100
libswresample 3. 7.100 / 3. 7.100
libpostproc 55. 7.100 / 55. 7.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'teacher1.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.29.100
Duration: 00:00:15.02, start: 0.000000, bitrate: 2447 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 2315 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
handler_name : SoundHandler
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'teacher2.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.29.100
Duration: 00:00:15.02, start: 0.000000, bitrate: 1643 kb/s
Stream #1:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 1509 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #1:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
handler_name : SoundHandler
Stream mapping:
Stream #0:0 (h264) -> xfade:main (graph 0)
Stream #1:0 (h264) -> xfade:xfade (graph 0)
xfade (graph 0) -> Stream #0:0 (libx264)
Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
[libx264 # 0x64603c0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 # 0x64603c0] profile High 4:4:4 Predictive, level 4.0, 4:4:4, 8-bit
[libx264 # 0x64603c0] 264 - core 161 r3018 db0d417 - H.264/MPEG-4 AVC codec - Copyleft 2003-2020 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=4 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'output.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.45.100
Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv444p, 1920x1080, q=-1--1, 25 fps, 12800 tbn, 25 tbc (default)
Metadata:
encoder : Lavc58.91.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
handler_name : SoundHandler
encoder : Lavc58.91.100 aac
frame= 738 fps= 25 q=-1.0 Lsize= 7317kB time=00:00:29.40 bitrate=2038.9kbits/s speed=1.01x
video:7064kB audio:236kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.241368%
[libx264 # 0x64603c0] frame I:8 Avg QP:16.56 size:100307
[libx264 # 0x64603c0] frame P:332 Avg QP:19.50 size: 15211
[libx264 # 0x64603c0] frame B:398 Avg QP:24.35 size: 3467
[libx264 # 0x64603c0] consecutive B-frames: 6.2% 62.6% 8.9% 22.2%
[libx264 # 0x64603c0] mb I I16..4: 18.7% 60.5% 20.9%
[libx264 # 0x64603c0] mb P I16..4: 4.5% 7.6% 0.6% P16..4: 24.1% 5.6% 1.9% 0.0% 0.0% skip:55.7%
[libx264 # 0x64603c0] mb B I16..4: 0.4% 0.5% 0.1% B16..8: 14.3% 0.9% 0.1% direct: 0.4% skip:83.3% L0:42.9% L1:53.9% BI: 3.3%
[libx264 # 0x64603c0] 8x8 transform intra:59.2% inter:84.3%
[libx264 # 0x64603c0] coded y,u,v intra: 25.3% 11.9% 13.0% inter: 3.2% 1.7% 1.8%
[libx264 # 0x64603c0] i16 v,h,dc,p: 49% 25% 15% 12%
[libx264 # 0x64603c0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 31% 17% 37% 2% 2% 3% 2% 3% 2%
[libx264 # 0x64603c0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 28% 19% 15% 6% 7% 7% 6% 6% 5%
[libx264 # 0x64603c0] Weighted P-Frames: Y:3.3% UV:1.5%
[libx264 # 0x64603c0] ref P L0: 66.0% 8.0% 18.5% 7.5% 0.0%
[libx264 # 0x64603c0] ref B L0: 84.9% 13.1% 2.0%
[libx264 # 0x64603c0] ref B L1: 98.8% 1.2%
[libx264 # 0x64603c0] kb/s:1960.04
[aac # 0x64d1280] Qavg: 171.394

Looking for a general purpose way to merge audio and video file and make an output have stereo audio with FFmpeg

So have have the following FFmpeg command
ffmpeg -i vidab.mp4 -i recab.webm -filter_complex "[0:a]volume=0.2,apad[A];[1:a][A]amerge[Aout]" -map 0:v -map [Aout] -y mergeab.mp4
When the input files are played separately their audio is played equally through both headphones.
But after being merged the audio from the video is on the right side and the audio from the webm file is on the left side.
I see this in the output when I run the cmd
[Parsed_amerge_2 # 0x7fa0faf01bc0] No channel layout for input 1
[Parsed_amerge_2 # 0x7fa0faf01bc0] Input channel layouts overlap: output layout will be determined by the number of distinct input channels
How can I adjust this so that the output file has the audio from both the inputs in equally in the left and right sides?
Also is there a generic way to do this such that even different configurations (video has stereo and audio has mono ... or both have stereo) result in the Audio being split evenly.
I tried using the pan filter but there is something I am not understanding about how it works because either nothing happens or I flip left and right. But I am not getting even stereo.
fwiw here is the full output.
ffmpeg -i vidab.mp4 -i recab.webm -filter_complex "[0:a]volume=0.2,apad[A];[1:a][A]amerge[Aout]" -map 0:v -map [Aout] -y mergeab.mp4
ffmpeg version 4.2.1 Copyright (c) 2000-2019 the FFmpeg developers
built with Apple clang version 11.0.0 (clang-1100.0.33.8)
configuration: --prefix=/usr/local/Cellar/ffmpeg/4.2.1_2 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags='-I/Library/Java/JavaVirtualMachines/adoptopenjdk-13.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/adoptopenjdk-13.jdk/Contents/Home/include/darwin -fno-stack-check' --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libmp3lame --enable-libopus --enable-librubberband --enable-libsnappy --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-libsoxr --enable-videotoolbox --disable-libjack --disable-indev=jack
libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'vidab.mp4':
Metadata:
major_brand : qt
minor_version : 0
compatible_brands: qt
creation_time : 2020-02-21T00:35:25.000000Z
Duration: 00:00:10.65, start: 0.000000, bitrate: 2539 kb/s
Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 96 kb/s (default)
Metadata:
creation_time : 2020-02-21T00:35:25.000000Z
handler_name : Core Media Audio
Stream #0:1(und): Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc, bt709), 1280x640, 2436 kb/s, 29.87 fps, 29.97 tbr, 90k tbn, 180k tbc (default)
Metadata:
creation_time : 2020-02-21T00:35:25.000000Z
handler_name : Core Media Video
encoder : H.264
Input #1, matroska,webm, from 'recab.webm':
Metadata:
encoder : opus-media-recorder
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #1:0(eng): Audio: opus, 48000 Hz, mono, fltp (default)
Stream mapping:
Stream #0:0 (aac) -> volume (graph 0)
Stream #1:0 (opus) -> amerge:in0 (graph 0)
Stream #0:1 -> #0:0 (h264 (native) -> h264 (libx264))
amerge (graph 0) -> Stream #0:1 (aac)
Press [q] to stop, [?] for help
[libx264 # 0x7fa0fb004000] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 # 0x7fa0fb004000] profile High, level 3.1
[libx264 # 0x7fa0fb004000] 264 - core 155 r2917 0a84d98 - H.264/MPEG-4 AVC codec - Copyleft 2003-2018 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
[Parsed_amerge_2 # 0x7fa0faf01bc0] No channel layout for input 1
[Parsed_amerge_2 # 0x7fa0faf01bc0] Input channel layouts overlap: output layout will be determined by the number of distinct input channels
Output #0, mp4, to 'mergeab.mp4':
Metadata:
major_brand : qt
minor_version : 0
compatible_brands: qt
encoder : Lavf58.29.100
Stream #0:0(und): Video: h264 (libx264) (avc1 / 0x31637661), yuvj420p(pc, progressive), 1280x640, q=-1--1, 29.97 fps, 30k tbn, 29.97 tbc (default)
Metadata:
creation_time : 2020-02-21T00:35:25.000000Z
handler_name : Core Media Video
encoder : Lavc58.54.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
encoder : Lavc58.54.100 aac
frame= 318 fps=107 q=-1.0 Lsize= 1568kB time=00:00:17.72 bitrate= 724.8kbits/s speed=5.99x
video:1282kB audio:272kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.902630%
[libx264 # 0x7fa0fb004000] frame I:2 Avg QP:19.72 size: 51154
[libx264 # 0x7fa0fb004000] frame P:148 Avg QP:21.28 size: 6644
[libx264 # 0x7fa0fb004000] frame B:168 Avg QP:25.18 size: 1351
[libx264 # 0x7fa0fb004000] consecutive B-frames: 1.3% 84.9% 0.0% 13.8%
[libx264 # 0x7fa0fb004000] mb I I16..4: 23.2% 49.3% 27.5%
[libx264 # 0x7fa0fb004000] mb P I16..4: 2.1% 2.0% 0.2% P16..4: 29.0% 5.1% 4.8% 0.0% 0.0% skip:56.8%
[libx264 # 0x7fa0fb004000] mb B I16..4: 0.5% 0.3% 0.0% B16..8: 16.7% 0.8% 0.2% direct: 6.1% skip:75.4% L0:24.8% L1:71.1% BI: 4.1%
[libx264 # 0x7fa0fb004000] 8x8 transform intra:45.4% inter:74.3%
[libx264 # 0x7fa0fb004000] coded y,uvDC,uvAC intra: 29.3% 51.4% 11.6% inter: 5.7% 16.6% 0.3%
[libx264 # 0x7fa0fb004000] i16 v,h,dc,p: 11% 53% 10% 26%
[libx264 # 0x7fa0fb004000] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 13% 36% 35% 2% 2% 2% 4% 2% 3%
[libx264 # 0x7fa0fb004000] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 24% 30% 12% 4% 6% 5% 7% 5% 6%
[libx264 # 0x7fa0fb004000] i8c dc,h,v,p: 47% 33% 17% 4%
[libx264 # 0x7fa0fb004000] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 # 0x7fa0fb004000] ref P L0: 76.6% 7.6% 11.1% 4.7%
[libx264 # 0x7fa0fb004000] ref B L0: 89.1% 10.3% 0.6%
[libx264 # 0x7fa0fb004000] ref B L1: 99.7% 0.3%
[libx264 # 0x7fa0fb004000] kb/s:989.60
[aac # 0x7fa0fb005800] Qavg: 13376.354
Use amix instead of amerge and resample to stereo using -ac 2. Since you're mapping the first video, tell amix to terminate with first input.
ffmpeg -i vidab.mp4 -i recab.webm -filter_complex "[0:a]volume=0.2[A];[A][1:a]amix=inputs=2:duration=first[Aout]" -map 0:v -map [Aout] -y mergeab.mp4

amix filter is causing audio to disappear

I'm trying overlay audio onto a video. I have a very simple ffmpeg command (auido.mp3 is much longer than the video)
ffmpeg -i video.mp4 -i audio.mp3 -filter_complex "[0:a] [1:a] amix=duration=shortest [a]" -map 0:v -map [a] test.mp4
This produces a silent video. However, when not mapping the video stream
ffmpeg -i video.mp4 -i audio.mp3 -filter_complex "[0:a] [1:a] amix=duration=shortest [a]" -map [a] test.mp4
The resulting audio file is as expected.
What could be causing this issues?
(Is there a better way to overlay audio onto a video via ffmpeg?)
Edit: log
ffmpeg version 4.2.1 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 9.1.1 (GCC) 20190807
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'video.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: mp42mp41
creation_time : 2019-11-15T05:28:05.000000Z
Duration: 00:00:00.53, start: 0.000000, bitrate: 9463 kb/s
Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080, 9546 kb/s, 30 fps, 30 tbr, 30k tbn, 60 tbc (default)
Metadata:
creation_time : 2019-11-15T05:28:05.000000Z
handler_name : ?Mainconcept Video Media Handler
encoder : AVC Coding
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 317 kb/s (default)
Metadata:
creation_time : 2019-11-15T05:28:05.000000Z
handler_name : #Mainconcept MP4 Sound Media Handler
[mp3 # 000001fdf5f7f040] Estimating duration from bitrate, this may be inaccurate
Input #1, mp3, from 'audio.mp3':
Metadata:
date : 2019-11-14 23:31
id3v2_priv.XMP : <?xpacket begin="\xef\xbb\xbf" id="W5M0MpCehiHzreSzNTczkc9d"?>\x0a<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 5.6-c148 79.163765, 2019/01/24-18:11:46 ">\x0a <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">\x0a <rdf
Duration: 00:22:01.91, start: 0.000000, bitrate: 256 kb/s
Stream #1:0: Audio: mp3, 44100 Hz, stereo, fltp, 256 kb/s
Stream mapping:
Stream #0:1 (aac) -> amix:input0 (graph 0)
Stream #1:0 (mp3float) -> amix:input1 (graph 0)
Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
amix (graph 0) -> Stream #0:1 (aac)
Press [q] to stop, [?] for help
[libx264 # 000001fdf64ab700] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 # 000001fdf64ab700] profile High, level 4.0, 4:2:0, 8-bit
[libx264 # 000001fdf64ab700] 264 - core 158 r2984 3759fcb - H.264/MPEG-4 AVC codec - Copyleft 2003-2019 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'test.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: mp42mp41
encoder : Lavf58.29.100
Stream #0:0(eng): Video: h264 (libx264) (avc1 / 0x31637661), yuv420p(progressive), 1920x1080, q=-1--1, 30 fps, 15360 tbn, 30 tbc (default)
Metadata:
creation_time : 2019-11-15T05:28:05.000000Z
handler_name : ?Mainconcept Video Media Handler
encoder : Lavc58.54.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
encoder : Lavc58.54.100 aac
frame= 15 fps=0.0 q=-1.0 Lsize= 695kB time=00:00:00.40 bitrate=14232.7kbits/s speed=0.437x
video:693kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.226150%
[libx264 # 000001fdf64ab700] frame I:1 Avg QP:30.52 size:101545
[libx264 # 000001fdf64ab700] frame P:7 Avg QP:28.22 size: 44755
[libx264 # 000001fdf64ab700] frame B:7 Avg QP:30.76 size: 42074
[libx264 # 000001fdf64ab700] consecutive B-frames: 20.0% 40.0% 40.0% 0.0%
[libx264 # 000001fdf64ab700] mb I I16..4: 68.3% 10.5% 21.2%
[libx264 # 000001fdf64ab700] mb P I16..4: 17.6% 4.8% 4.3% P16..4: 28.5% 4.5% 2.8% 0.0% 0.0% skip:37.6%
[libx264 # 000001fdf64ab700] mb B I16..4: 17.6% 2.4% 1.3% B16..8: 37.9% 6.7% 1.3% direct: 4.9% skip:27.8% L0:40.5% L1:54.3% BI: 5.2%
[libx264 # 000001fdf64ab700] 8x8 transform intra:13.9% inter:59.5%
[libx264 # 000001fdf64ab700] coded y,uvDC,uvAC intra: 54.5% 53.3% 42.3% inter: 15.3% 27.8% 21.6%
[libx264 # 000001fdf64ab700] i16 v,h,dc,p: 5% 88% 5% 2%
[libx264 # 000001fdf64ab700] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 10% 53% 29% 1% 1% 1% 2% 1% 2%
[libx264 # 000001fdf64ab700] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 6% 80% 9% 1% 1% 0% 1% 0% 2%
[libx264 # 000001fdf64ab700] i8c dc,h,v,p: 16% 80% 3% 1%
[libx264 # 000001fdf64ab700] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 # 000001fdf64ab700] ref P L0: 40.3% 4.9% 11.0% 43.8%
[libx264 # 000001fdf64ab700] ref B L0: 80.0% 11.1% 8.9%
[libx264 # 000001fdf64ab700] kb/s:11349.57
[aac # 000001fdf64ac600] Qavg: 41522.195

Resources