3

Из документации видно, что это должно работать:

ffmpeg -i input.mp4 -af "pan=1c|c0=.5*c0+.5*c1" output.mp4

На выходе получается видео без звука. Когда я делаю ffprobe, он говорит, что есть аудио-моно-трек, но его всего 2 кбит / с.

Однако, когда я делаю это таким образом, кажется, что он работает и создает видео с монотреком:

ffmpeg -i input.mp4 -ac 1 output.mp4

Кто-нибудь знает причину, почему первый способ не работает для меня?

Спасибо!

Добавление вывода на консоль

вывод ffmpeg:

ffmpeg -loglevel verbose -i video.mp4 -af "pan=1c|c0=.5*c0+.5*c1" output.mp4
ffmpeg version 2.6.2 Copyright (c) 2000-2015 the FFmpeg developers
  built with Apple LLVM version 6.0 (clang-600.0.57) (based on LLVM 3.5svn)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/2.6.2 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-libx264 --enable-libmp3lame --enable-libvo-aacenc --enable-libxvid --enable-vda
  libavutil      54. 20.100 / 54. 20.100
  libavcodec     56. 26.100 / 56. 26.100
  libavformat    56. 25.101 / 56. 25.101
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 11.102 /  5. 11.102
  libavresample   2.  1.  0 /  2.  1.  0
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  3.100 / 53.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'video.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    creation_time   : 2014-11-27 01:56:02
  Duration: 00:00:24.50, start: 0.000000, bitrate: 374 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 179 kb/s, 25 fps, 25 tbr, 25 tbn, 50 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 191 kb/s (default)
    Metadata:
      creation_time   : 2014-11-27 01:56:02
      handler_name    : IsoMedia File Produced by Google, 5-11-2011
[graph 0 input from stream 0:0 @ 0x7f9bf2607300] w:1280 h:720 pixfmt:yuv420p tb:1/25 fr:25/1 sar:1/1 sws_param:flags=2
[graph 1 input from stream 0:1 @ 0x7f9bf240d280] tb:1/44100 samplefmt:fltp samplerate:44100 chlayout:0x3
[audio format for output stream 0:1 @ 0x7f9bf240d800] auto-inserting filter 'auto-inserted resampler 0' between the filter 'Parsed_pan_0' and the filter 'audio format for output stream 0:1'
[Parsed_pan_0 @ 0x7f9bf240c280] o0 = 0.5 i0 + 0.5 i1
[auto-inserted resampler 0 @ 0x7f9bf240ccc0] ch:1 chl:1 channels fmt:fltp r:44100Hz -> ch:1 chl:1 channels fmt:s16 r:44100Hz
[libx264 @ 0x7f9bf3812400] using SAR=1/1
[libx264 @ 0x7f9bf3812400] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 0x7f9bf3812400] profile High, level 3.1
[libx264 @ 0x7f9bf3812400] 264 - core 144 r2533 c8a773e - H.264/MPEG-4 AVC codec - Copyleft 2003-2015 - 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
Output #0, mp4, to 'output.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    encoder         : Lavf56.25.101
    Stream #0:0(und): Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 25 fps, 12800 tbn, 25 tbc (default)
    Metadata:
      handler_name    : VideoHandler
      encoder         : Lavc56.26.100 libx264
    Stream #0:1(und): Audio: aac (libvo_aacenc) ([64][0][0][0] / 0x0040), 44100 Hz, 1 channels, s16, 128 kb/s (default)
    Metadata:
      creation_time   : 2014-11-27 01:56:02
      handler_name    : IsoMedia File Produced by Google, 5-11-2011
      encoder         : Lavc56.26.100 libvo_aacenc
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
  Stream #0:1 -> #0:1 (aac (native) -> aac (libvo_aacenc))
Press [q] to stop, [?] for help
No more output streams to write to, finishing.e=00:00:22.90 bitrate= 139.9kbits/s    
frame=  612 fps=266 q=-1.0 Lsize=     491kB time=00:00:24.50 bitrate= 164.1kbits/s    
video:86kB audio:383kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 4.547780%
Input file #0 (video.mp4):
  Input stream #0:0 (video): 612 packets read (548636 bytes); 612 frames decoded; 
  Input stream #0:1 (audio): 1055 packets read (587929 bytes); 1055 frames decoded (1080320 samples); 
  Total: 1667 packets (1136565 bytes) demuxed
Output file #0 (output.mp4):
  Output stream #0:0 (video): 612 frames encoded; 612 packets muxed (88265 bytes); 
  Output stream #0:1 (audio): 1055 frames encoded (1080320 samples); 1057 packets muxed (392695 bytes); 
  Total: 1669 packets (480960 bytes) muxed
[libx264 @ 0x7f9bf3812400] frame I:4     Avg QP: 7.20  size:   912
[libx264 @ 0x7f9bf3812400] frame P:173   Avg QP:15.86  size:   328
[libx264 @ 0x7f9bf3812400] frame B:435   Avg QP:15.39  size:    63
[libx264 @ 0x7f9bf3812400] consecutive B-frames:  2.3%  7.5%  3.9% 86.3%
[libx264 @ 0x7f9bf3812400] mb I  I16..4: 87.9% 11.2%  0.9%
[libx264 @ 0x7f9bf3812400] mb P  I16..4:  1.7%  0.0%  0.1%  P16..4:  0.4%  0.1%  0.1%  0.0%  0.0%    skip:97.5%
[libx264 @ 0x7f9bf3812400] mb B  I16..4:  0.0%  0.0%  0.0%  B16..8:  0.2%  0.0%  0.0%  direct: 0.1%  skip:99.7%  L0:49.5% L1:44.6% BI: 5.9%
[libx264 @ 0x7f9bf3812400] 8x8 transform intra:7.5% inter:43.5%
[libx264 @ 0x7f9bf3812400] coded y,uvDC,uvAC intra: 2.6% 0.0% 0.0% inter: 0.1% 0.0% 0.0%
[libx264 @ 0x7f9bf3812400] i16 v,h,dc,p: 98%  1%  1%  0%
[libx264 @ 0x7f9bf3812400] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 21%  2% 75%  1%  0%  0%  0%  0%  1%
[libx264 @ 0x7f9bf3812400] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 40% 21% 19%  3%  3%  4%  3%  3%  3%
[libx264 @ 0x7f9bf3812400] i8c dc,h,v,p: 100%  0%  0%  0%
[libx264 @ 0x7f9bf3812400] Weighted P-Frames: Y:86.7% UV:5.2%
[libx264 @ 0x7f9bf3812400] ref P L0: 71.5% 13.0% 10.1%  3.3%  2.1%
[libx264 @ 0x7f9bf3812400] ref B L0: 80.1% 12.5%  7.4%
[libx264 @ 0x7f9bf3812400] ref B L1: 97.1%  2.9%
[libx264 @ 0x7f9bf3812400] kb/s:28.62

Вывод ffprobe:

ffprobe output.mp4 
ffprobe version 2.6.2 Copyright (c) 2007-2015 the FFmpeg developers
  built with Apple LLVM version 6.0 (clang-600.0.57) (based on LLVM 3.5svn)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/2.6.2 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-libx264 --enable-libmp3lame --enable-libvo-aacenc --enable-libxvid --enable-vda
  libavutil      54. 20.100 / 54. 20.100
  libavcodec     56. 26.100 / 56. 26.100
  libavformat    56. 25.101 / 56. 25.101
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 11.102 /  5. 11.102
  libavresample   2.  1.  0 /  2.  1.  0
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  3.100 / 53.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'output.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf56.25.101
  Duration: 00:00:24.53, start: 0.036281, bitrate: 163 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 28 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, mono, fltp, 128 kb/s (default)
    Metadata:
      handler_name    : SoundHandler

1 ответ1

4

Обходной путь должен использовать mono или 1 вместо 1c:

ffmpeg -i video.mp4 -af "pan=mono|c0=.5*c0+.5*c1" -c:v copy output.mp4

Я не уверен, почему пример в документации не работает должным образом, или это регрессия или нет.

Я добавил -c:v copy если вы предпочитаете потоковое копирование вместо перекодирования видео.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками .