ffmpeg mischen Sie Audio mit Video und verringern Sie die Lautstärke

942
Rich

Ich versuche, eine Audio-MP3-Datei mit einer Video-MP4-Datei zusammenzuführen. Ich möchte, dass die Lautstärke der Audiodatei etwas verringert wird, sodass sie als Hintergrundmusik für den Videoclip dient.

So sieht mein Code jetzt aus (ich habe versucht, mich von einem vorherigen Code anzupassen, der 2 MP3s zusammenführt) -

ffmpeg \ -i output.mp4 \  -i music.mp3 \  -filter_complex "[0:a]volume=0.15[A];[1:a][A]amerge[out]" \ -map [out] -y output-final.mp4 2>&1 

BEARBEITEN

Es scheint ein Problem auf dem iPhone zu geben, wenn MP4-Videos mit filter_complex mit amerge codiert werden.

Konsolenausgabe -

ffmpeg version N-90767-g768c077-syslint Copyright (c) 2000-2018 the FFmpeg developers built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-16) configuration: --prefix=/usr/local/cpffmpeg --enable-shared --enable-nonfree --enable-gpl --enable-pthreads --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --extra-cflags=-I/usr/local/cpffmpeg/include --extra-ldflags=-L/usr/local/cpffmpeg/lib --enable-version3 --extra-version=syslint libavutil 56. 15.100 / 56. 15.100 libavcodec 58. 19.100 / 58. 19.100 libavformat 58. 13.100 / 58. 13.100 libavdevice 58. 4.100 / 58. 4.100 libavfilter 7. 18.100 / 7. 18.100 libswscale 5. 2.100 / 5. 2.100 libswresample 3. 2.100 / 3. 2.100 libpostproc 55. 2.100 / 55. 2.100 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/path/to/output-4786-second.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf58.13.100 Duration: 00:00:13.58, start: 0.000000, bitrate: 798 kb/s Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 767 kb/s, 24 fps, 24 tbr, 12288 tbn, 48 tbc (default) Metadata: handler_name : VideoHandler Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 22050 Hz, mono, fltp, 29 kb/s (default) Metadata: handler_name : SoundHandler Input #1, mp3, from '/path/to/buddy.mp3': Duration: 00:02:02.12, start: 0.025057, bitrate: 112 kb/s Stream #1:0: Audio: mp3, 44100 Hz, stereo, fltp, 112 kb/s Metadata: encoder : LAME3.99r Stream mapping: Stream #0:1 (aac) -> amerge:in0 (graph 0) Stream #1:0 (mp3float) -> volume (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 @ 0x1cae600] using SAR=1/1 [libx264 @ 0x1cae600] using cpu capabilities: none! [libx264 @ 0x1cae600] profile Constrained Baseline, level 3.1 [libx264 @ 0x1cae600] 264 - core 155 r2901 7d0ff22 - H.264/MPEG-4 AVC codec - Copyleft 2003-2018 - http://www.videolan.org/x264.html - options: cabac=0 ref=1 deblock=0:0:0 analyse=0:0 me=dia subme=0 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=1 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=22 lookahead_threads=3 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=250 keyint_min=24 scenecut=0 intra_refresh=0 rc=crf mbtree=0 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=0 [Parsed_amerge_2 @ 0x2ed3780] No channel layout for input 1 Output #0, mp4, to '/path/to/output-4786.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf58.13.100 Stream #0:0(und): Video: h264 (libx264) (avc1 / 0x31637661), yuv420p(progressive), 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 24 fps, 12288 tbn, 24 tbc (default) Metadata: handler_name : VideoHandler encoder : Lavc58.19.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.19.100 aac frame= 82 fps=0.0 q=12.0 size= 0kB time=00:00:02.50 bitrate= 0.2kbits/s speed=4.97x  frame= 157 fps=156 q=18.0 size= 512kB time=00:00:05.57 bitrate= 752.7kbits/s speed=5.53x  frame= 210 fps=139 q=13.0 size= 1280kB time=00:00:07.80 bitrate=1344.0kbits/s speed=5.18x  frame= 273 fps=136 q=12.0 size= 1280kB time=00:00:10.40 bitrate=1008.0kbits/s speed=5.18x  frame= 326 fps=145 q=-1.0 Lsize= 1607kB time=00:00:13.54 bitrate= 972.3kbits/s speed=6.04x  video:1290kB audio:310kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.406112% [libx264 @ 0x1cae600] frame I:2 Avg QP:15.50 size: 21673 [libx264 @ 0x1cae600] frame P:324 Avg QP:13.50 size: 3942 [libx264 @ 0x1cae600] mb I I16..4: 100.0% 0.0% 0.0% [libx264 @ 0x1cae600] mb P I16..4: 1.6% 0.0% 0.0% P16..4: 12.7% 0.0% 0.0% 0.0% 0.0% skip:85.7% [libx264 @ 0x1cae600] coded y,uvDC,uvAC intra: 25.5% 29.6% 12.4% inter: 4.2% 8.3% 1.4% [libx264 @ 0x1cae600] i16 v,h,dc,p: 62% 18% 9% 11% [libx264 @ 0x1cae600] i8c dc,h,v,p: 68% 16% 11% 5% [libx264 @ 0x1cae600] kb/s:777.82 [aac @ 0x1caf980] Qavg: 4402.419 

Letzter Befehl versucht -

ffmpeg \ -i '.$thepath.'/output-'.$v_Id.'-second.mp4 \ -i '.$musicpath .'/'.$music.'.mp3 \ -filter_complex "[1:a]volume=0.15,apad[A];[0:a][A]amerge[out]" \ -c:v libx264 -c:a aac -map 0:v -map "[out]" \ -preset ultrafast -threads 0 -pix_fmt yuv420p -y '.$thepath.'/output-'.$v_Id.'.mp4 2>&1 
0

1 Antwort auf die Frage

1
Gyan

Benutzen

ffmpeg \ -i output.mp4 \ -i music.mp3 \ -filter_complex "[1:a]volume=0.15,apad[A];[0:a][A]amerge[out]" \ -c:v copy -map 0:v -map [out] -y output-final.mp4 
Ich bekomme diesen Fehler - `sh: Zeile 3: -filter_complex: Befehl nicht gefunden` Rich vor 5 Jahren 0
Entfernte Leerzeichen wurden entfernt Gyan vor 5 Jahren 0
das war nicht das Problem Rich vor 5 Jahren 0
Setzen Sie einfach alles auf eine Zeile und führen Sie es aus Gyan vor 5 Jahren 0
Ich stieß auf ein Problem bei der iPhone-Safari. Die mp4-Videos lassen sich nicht darauf abspielen, aber sie werden überallhin wiedergegeben. Ich habe versucht, verschiedene Kombinationen der Optionen hinzuzufügen `-vprofile baseline -level 3.0 -pix_fmt yuv420p -movflags + faststart -shortest`, aber nichts funktioniert. Irgendwelche Ideen? Rich vor 5 Jahren 0
Bei "-c: v copy" wirkt sich keine dieser Optionen aus. Lass es fallen und schau nach. Gyan vor 5 Jahren 0
Dasselbe Problem tritt auf. Rich vor 5 Jahren 0
Teilen Sie das vollständige Protokoll. Gyan vor 5 Jahren 0
Ok, ich habe meine Frage mit dem Log aktualisiert Rich vor 5 Jahren 0
Fügen Sie Ihrem aktuellen Befehl `-profile: v baseline -ac 2` hinzu. Gyan vor 5 Jahren 1
Ja, ich denke, das hat den Trick getan. Ich werde noch mehr testen, aber bisher scheint es jetzt zu funktionieren. Vielen Dank. Rich vor 5 Jahren 0