我正在处理一个 mp4 文件 (36017P.mp4),我想使用 ffmpeg 提取其中的曲目 2 -[英语]。
我尝试在终端上使用以下命令但似乎提取Track 1 - [English]
:
ffmpeg -i 36017P.mp4 filename.mp3
问题陈述:
我想知道我需要对上面的 ffmpeg 命令进行哪些更改,以便它Track 2 -[English]
从 mp4 文件中提取
以下是流式输出:
ffmpeg version 4.0 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 7.3.0 (GCC)
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-bzlib --e
nable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libblur
ay --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-
libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enab
le-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-li
bvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --en
able-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-
libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enabl
e-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enabl
e-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enab
le-dxva2 --enable-avisynth
libavutil 56. 14.100 / 56. 14.100
libavcodec 58. 18.100 / 58. 18.100
libavformat 58. 12.100 / 58. 12.100
libavdevice 58. 3.100 / 58. 3.100
libavfilter 7. 16.100 / 7. 16.100
libswscale 5. 1.100 / 5. 1.100
libswresample 3. 1.100 / 3. 1.100
libpostproc 55. 1.100 / 55. 1.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '36017P.mp4':
Metadata:
major_brand : M4V
minor_version : 1
compatible_brands: M4V mp42isom
creation_time : 2019-04-30T03:09:22.000000Z
Duration: 00:29:29.94, start: 0.000000, bitrate: 2509 kb/s
Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv), 960x5
40 [SAR 1:1 DAR 16:9], 1998 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc (defa
ult)
Metadata:
creation_time : 2019-04-30T03:09:22.000000Z
handler_name : AliasHandler
encoder : H264
timecode : 22:30:00;02
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, flt
p, 125 kb/s (default)
Metadata:
creation_time : 2019-04-30T03:09:22.000000Z
handler_name : AliasHandler
Stream #0:2(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, flt
p, 125 kb/s (default)
Metadata:
creation_time : 2019-04-30T03:09:22.000000Z
handler_name : AliasHandler
Stream #0:3(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, flt
p, 125 kb/s (default)
Metadata:
creation_time : 2019-04-30T03:09:22.000000Z
handler_name : AliasHandler
Stream #0:4(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, flt
p, 125 kb/s (default)
Metadata:
creation_time : 2019-04-30T03:09:22.000000Z
handler_name : AliasHandler
Stream #0:5(eng): Data: none (tmcd / 0x64636D74) (default)
Metadata:
creation_time : 2019-04-30T03:09:22.000000Z
handler_name : AliasHandler
timecode : 22:30:00;02
Stream mapping:
Stream #0:2 -> #0:0 (aac (native) -> mp3 (libmp3lame))
Press [q] to stop, [?] for help
Output #0, mp3, to 'new_english.mp3':
Metadata:
major_brand : M4V
minor_version : 1
compatible_brands: M4V mp42isom
TSSE : Lavf58.12.100
Stream #0:0(eng): Audio: mp3 (libmp3lame), 48000 Hz, stereo, fltp (default)
Metadata:
creation_time : 2019-04-30T03:09:22.000000Z
handler_name : AliasHandler
encoder : Lavc58.18.100 libmp3lame
size= 27656kB time=00:29:29.95 bitrate= 128.0kbits/s speed=19.7x
video:0kB audio:27656kB subtitle:0kB other streams:0kB global headers:0kB muxing
overhead: 0.001179%
答案1
您可以使用该-map
选项来选择特定的流。要获取可用流的列表,请运行ffmpeg -i INPUT_FILE.EXT
(不要忘记-i
!),例如:
…
Input #0, EXT, from 'INPUT_FILE.EXT':
Metadata:
encoder : VirtualDubMod 1.5.10.2 (build 2542/release)
Duration: 01:35:35.88, start: 0.000000, bitrate: 1029 kb/s
Stream #0:0: Video: mpeg4 (Advanced Simple Profile) (XVID / 0x44495658), yuv420p, 640x352 [SAR 1:1 DAR 20:11], 891 kb/s, 25 fps, 25 tbr, 25 tbn, 25 tbc
Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 48000 Hz, stereo, s16p, 128 kb/s
Metadata:
title : English AC3 2.0 (Stereo) @ 128 kbps
Stream #0:2: Audio: mp3 (U[0][0][0] / 0x0055), 48000 Hz, stereo, s16p, 192 kb/s
Metadata:
title : English AC3 2.0 (Stereo) @ 192 kbps
At least one output file must be specified
如果您想要提取例如流#0:2
,请使用-map 0:2
:
ffmpeg -i INPUT_FILE.EXT -map 0:2 OUTPUT_FILE.EXT