FFMPEG:提取具有视频精确帧长度的音频

FFMPEG:提取具有视频精确帧长度的音频

对于数字影院包,我需要从 QuickTime 电影(在本例中采用 Prores 或 Photo-JPEG 编解码器)中提取音轨(.wav,48000 kHz,16 位)。问题在于音频文件的持续时间必须与视频轨道的帧长度完全相同。输出波形文件必须为 48000 kHz 和 24 位。

这是我尝试过的命令:

"C:\Program Files (x86)\FFMPEG\bin\ffmpeg.exe" -i "input\path\file.mov" -vn -acodec pcm_s24le -ar 48000 "output\path\audio.wav"

我注意到很多时候音轨比输入的 QuickTime 影片长几帧。但是当我使用 Adob​​e Media Encoder 提取音频时,它总是具有完全相同的帧长度。例如,可以通过将音频和视频导入 After Effects 来验证这一点。

例子:

  • input.mov 由 1000 帧组成,
  • ffmpeg output.wav 大约有 1003 帧,
  • AME 输出.wav 有 1000 帧

有没有办法确保 ffmpeg 不会产生帧长度短于或长于原始视频的音轨?

控制台输出:

ffmpeg started on 2015-01-29 at 20:32:44
Report written to "ffmpeg-20150129-203244.log"
Command line:
"C:\Program Files (x86)\FFMPEG\bin\ffmpeg.exe" -report -i "G:\01_dcp_pipeline\02_a_sound_ready\01_WOE_IS_ME_1080P_24FPS.mov" -vn -acodec pcm_s24le -ar 48000 "G:\01_dcp_pipeline\02_a_sound_ready\01_WOE_IS_ME_1080P_24FPS2.wav"
ffmpeg version N-69375-g4155f2d Copyright (c) 2000-2015 the FFmpeg developers
  built on Jan 28 2015 22:14:02 with gcc 4.9.2 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --enable-decklink --enable-zlib
  libavutil  54. 18.100 / 54. 18.100
  libavcodec 56. 21.101 / 56. 21.101
  libavformat56. 19.100 / 56. 19.100
  libavdevice56.  4.100 / 56.  4.100
  libavfilter 5.  9.101 /  5.  9.101
  libswscale  3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
  libpostproc53.  3.100 / 53.  3.100
Splitting the commandline.
Reading option '-report' ... matched as option 'report' (generate a report) with argument '1'.
Reading option '-i' ... matched as input file with argument 'G:\01_dcp_pipeline\02_a_sound_ready\01_WOE_IS_ME_1080P_24FPS.mov'.
Reading option '-vn' ... matched as option 'vn' (disable video) with argument '1'.
Reading option '-acodec' ... matched as option 'acodec' (force audio codec ('copy' to copy stream)) with argument 'pcm_s24le'.
Reading option '-ar' ... matched as option 'ar' (set audio sampling rate (in Hz)) with argument '48000'.
Reading option 'G:\01_dcp_pipeline\02_a_sound_ready\01_WOE_IS_ME_1080P_24FPS2.wav' ... matched as output file.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option report (generate a report) with argument 1.
Successfully parsed a group of options.
Parsing a group of options: input file G:\01_dcp_pipeline\02_a_sound_ready\01_WOE_IS_ME_1080P_24FPS.mov.
Successfully parsed a group of options.
Opening an input file: G:\01_dcp_pipeline\02_a_sound_ready\01_WOE_IS_ME_1080P_24FPS.mov.
[mov,mp4,m4a,3gp,3g2,mj2 @ 000000000442d7c0] Format mov,mp4,m4a,3gp,3g2,mj2 probed with size=2048 and score=100
[mov,mp4,m4a,3gp,3g2,mj2 @ 000000000442d7c0] ISO: File Type Major Brand: qt  
[mov,mp4,m4a,3gp,3g2,mj2 @ 000000000442d7c0] Before avformat_find_stream_info() pos: 890445130 bytes read:186331 seeks:4
[mov,mp4,m4a,3gp,3g2,mj2 @ 000000000442d7c0] All info found
[mov,mp4,m4a,3gp,3g2,mj2 @ 000000000442d7c0] After avformat_find_stream_info() pos: 6279910 bytes read:1510667 seeks:6 frames:26
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'G:\01_dcp_pipeline\02_a_sound_ready\01_WOE_IS_ME_1080P_24FPS.mov':
  Metadata:
major_brand : qt  
minor_version   : 537199360
compatible_brands: qt  
creation_time   : 2014-07-02 14:05:41
  Duration: 00:02:23.00, start: 0.000000, bitrate: 49815 kb/s
Stream #0:0(eng), 25, 1/24: Video: prores (apch / 0x68637061), yuv422p10le(bt709), 1920x1080, 49684 kb/s, SAR 1920:1920 DAR 16:9, 24 fps, 24 tbr, 24 tbn, 24 tbc (default)
Metadata:
  creation_time   : 2014-07-02 14:05:41
  handler_name: Apple Alias Data Handler
  encoder : Apple ProRes 422 (HQ)
  timecode: 00:00:00:00
Stream #0:1(eng), 1, 1/48000: Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 120 kb/s (default)
Metadata:
  creation_time   : 2014-07-02 14:05:41
  handler_name: Apple Alias Data Handler
  timecode: 00:00:00:00
Stream #0:2(eng), 0, 1/24: Data: none (tmcd / 0x64636D74) (default)
Metadata:
  creation_time   : 2014-07-02 14:08:05
  handler_name: Apple Alias Data Handler
  timecode: 00:00:00:00
Successfully opened the file.
Parsing a group of options: output file G:\01_dcp_pipeline\02_a_sound_ready\01_WOE_IS_ME_1080P_24FPS2.wav.
Applying option vn (disable video) with argument 1.
Applying option acodec (force audio codec ('copy' to copy stream)) with argument pcm_s24le.
Applying option ar (set audio sampling rate (in Hz)) with argument 48000.
Successfully parsed a group of options.
Opening an output file: G:\01_dcp_pipeline\02_a_sound_ready\01_WOE_IS_ME_1080P_24FPS2.wav.

答案1

我找到了问题的解决方案。“apad”过滤器与“-shortest”标签一起使用会将音轨延长到与 ffmpeg 中的视频轨道相同的长度。

这是在 Windows 命令行中使用 apad 过滤器的方法(视频和音频编解码器参数只是示例):

"C:\Program Files (x86)\FFMPEG\bin\ffmpeg.exe" -i PATH/TO/INPUTVIDEO -filter_complex "[0:1]apad" -vcodec prores -profile:v 3 -acodec pcm_s24le -ar 48000 -shortest PATH/TO/OUTPUTVIDEO

ffmpeg 文档中有关 apad 过滤器的更多信息:https://www.ffmpeg.org/ffmpeg-filters.html#apad

答案2

我认为“ -async 1”应该可以解决提取音频与视频长度相同的问题

答案3

没有说明您的 MOV 的帧速率是多少,因此是否需要加快音频以匹配视频的 23.976 到 24.000 加速以符合 DCI DCP 规格。此链接概述了可能有帮助的 DCP 工作流程:http://johnpilgrim.net/client/reference/DCP/HOWTO.html(我知道这并不能直接解决 OP 的问题,但它可能会间接解决问题。)

相关内容