FFmpeg amix过滤器


0

我正在尝试将我的视频的音频与音乐曲目合并 保持图片部分相同。要做到这一点,我试图使用 amix过滤器,但是当我运行命令时FFmpeg似乎挂起了。我 做错了什么?

$ ffmpeg -y -i aae635a604ff16c9a320376398ac121b_0.000_5.015.mp4 -i
full_dillon_in_pro_audio.mp3 -filter_complex
"[1:a][0:a]amix=inputs=2[m]" -map 0:v -map [m] -c:v libx264 -preset
ultrafast -c:a aac 4615491572977860225_PLzGS5hkLTwTfxlgkk0.mp4

ffmpeg version N-86394-g66cf78e Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 4.9.2 (Debian 4.9.2-10)
  configuration: --prefix=/usr/local
--extra-cflags=-I/usr/local/include --extra-ldflags=-L/usr/local/lib
--bindir=/usr/local/bin --disable-doc --disable-static --enable-shared
--disable-ffplay --extra-libs=-ldl --enable-version3
--enable-libfreetype --enable-libx264 --enable-gpl --enable-openssl
--enable-nonfree --disable-debug
  libavutil      55. 63.100 / 55. 63.100
  libavcodec     57. 96.101 / 57. 96.101
  libavformat    57. 72.101 / 57. 72.101
  libavdevice    57.  7.100 / 57.  7.100
  libavfilter     6. 91.100 /  6. 91.100
  libswscale      4.  7.101 /  4.  7.101
  libswresample   2.  8.100 /  2.  8.100
  libpostproc    54.  6.100 / 54.  6.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from
'aae635a604ff16c9a320376398ac121b_0.000_5.015.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.71.100
  Duration: 00:00:05.04, start: 0.000000, bitrate: 656 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p,
1280x720 [SAR 1:1 DAR 16:9], 522 kb/s, 30 fps, 30 tbr, 15360 tbn, 60
tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz,
stereo, fltp, 127 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
[mp3 @ 0xf20a60] Estimating duration from bitrate, this may be inaccurate
Input #1, mp3, from 'full_dillon_in_pro_audio.mp3':
  Metadata:
    title           : Dillon in Pro Audio
    artist          : Jingle Punks
    album           : YouTube Audio Library
    genre           : Dance & Electronic
    encoder         : Google
  Duration: 00:01:18.84, start: 0.000000, bitrate: 320 kb/s
    Stream #1:0: Audio: mp3, 44100 Hz, stereo, s16p, 320 kb/s
Stream mapping:
  Stream #0:1 (aac) -> amix:input1 (graph 0)
  Stream #1:0 (mp3) -> amix:input0 (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 @ 0xf338e0] using SAR=1/1
[libx264 @ 0xf338e0] using cpu capabilities: MMX2 SSE2Fast SSSE3
SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
[libx264 @ 0xf338e0] profile Constrained Baseline, level 3.1
[libx264 @ 0xf338e0] 264 - core 148 - H.264/MPEG-4 AVC codec -
Copyleft 2003-2016 - 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=0
8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0
threads=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1
interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0
keyint=250 keyint_min=25 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
Output #0, mp4, to '4615491572977860225_PLzGS5hkLTwTfxlgkk0.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.72.101
    Stream #0:0(und): Video: h264 (libx264) ([33][0][0][0] / 0x0021),
yuv420p(progressive), 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 30 fps,
15360 tbn, 30 tbc (default)
    Metadata:
      handler_name    : VideoHandler
      encoder         : Lavc57.96.101 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
    Stream #0:1: Audio: aac (LC) ([64][0][0][0] / 0x0040), 44100 Hz,
stereo, fltp, 128 kb/s (default)
    Metadata:
      encoder         : Lavc57.96.101 aac
<hang for more than 10 minutes>

其他明显更复杂的命令在几秒或几分钟内运行。


是否有可能其中一个文件很短?当我自己尝试时,它会很好地运行,直到FFmpeg到达较短文件的末尾。我用了 ffmpeg -i vid_input.mkv -f lavfi -i color=color=black -i aud_input.flac' -filter_complex "[0:v][1:v]overlay=eof_action=endall[v];[2:a][0:a]amix=inputs=2:duration=longest[a]" -map [v] -map [a] -c:v libx264 -crf 30 -preset ultrafast -c:a aac -b:a 128k test.mkv 并且可以使用此代码;但是,当然现在你的视频中有一个方框,而且VLC在视频结束后不知道在哪里设置时间片...
flolilolilo

@flolilolilo在那个例子中,两个持续时间是:00:00:05.04和00:01:18.84,所以不同......导致它挂起?如果我将两者都修剪到相同的长度它会起作用吗?
Jon G

我试过用 -to 这对我有用 - 但是,我认为这个问题有一个解决办法,但是我的想法一直停留在 overlay -事情...
flolilolilo

我想知道是否 amix=input‌​s=2:duration=shortest 可以解决它,但它没有在我的测试中。同样如果我使用 [1:a]atrim=0:5[a1];[a1][0:a]amix[m] 它仍然挂起。
Jon G

对我来说什么是修剪两个输入(即使[0]已经是5s长) [0:v]trim=0:5[v0];[0:a]atrim=0:5[a0];[1:a]atrim=0:5[a1];[a0][a1]amix[m]。这算作FFmpeg错误吗?或者只是我需要计划的事情?
Jon G

Answers:


By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.