【转】用ffmpeg转多音轨的mkv文件
命令:
ffmpeg -i AmericanCaptain.mkv -map 0:v -vcodec copy -map 0:a:1 -acodec copyAmericanCaptain.mp4 -strict -2
命令说明: 0:v 代表提取所有视频流(一般视频流只有1路)
0:a:1 代表提取第2路音频流
这个MKV是有2个音轨的,第一个为英文,第二个为中文,若不清楚原文件的信息,输入ffmpeg-i AmericanCaptain.mkv查看。
下面是我的文件信息。
Input #0, matroska,webm, from 'AmericanCaptain.mkv':
Metadata:
creation_time : 2014-04-06 07:05:17
Duration: 02:04:11.58, start: 0.000000, bitrate: 2497 kb/s
Stream #0:0: Video: h264 (High), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
Stream #0:1(eng): Audio: ac3, 48000 Hz, stereo, fltp, 448 kb/s (default)
Metadata:
title : 英语
Stream #0:2(chi): Audio: ac3, 48000 Hz, stereo, fltp, 448 kb/s
Metadata:
title : 国语
如下查看视频信息:
ffmpeg -i qianyan.trec
结果如下:
ffmpeg version N-87353-g183fd30 Copyright (c) 2000-2017 the FFmpeg developers built with gcc 7.2.0 (GCC) configuration: --enable-gpl --enable-version3 --enable-cuda --enable-cuvid --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --e -enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable- -enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libsnappy --enable-libs -libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 l2 --enable-libzimg --enable-lzma --enable-zlib libavutil 55. 76.100 / 55. 76.100 libavcodec 57.106.101 / 57.106.101 libavformat 57. 82.101 / 57. 82.101 libavdevice 57. 8.101 / 57. 8.101 libavfilter 6.105.100 / 6.105.100 libswscale 4. 7.103 / 4. 7.103 libswresample 2. 8.100 / 2. 8.100 libpostproc 54. 6.100 / 54. 6.100 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'qianyan.trec': Metadata: major_brand : mp42 minor_version : 0 compatible_brands: mp42isom creation_time : 2017-11-13T05:47:44.000000Z Duration: 00:05:03.04, start: 0.000000, bitrate: 2139 kb/s Stream #0:0(und): Video: tscc2 (tsc2 / 0x32637374), yuv444p, 1916x1040, 720 kb/s, 27.87 fps, 30 tbr, 30 tbn, 30 tbc (default) Metadata: creation_time : 2017-11-13T05:47:44.000000Z Stream #0:1(und): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p(tv), 640x480 [SAR 1:1 DAR 4:3], 1156 kb/s, 30 fps, 30 tbr, 30k tbn, 60 tbc (default) Metadata: creation_time : 2017-11-13T05:47:44.000000Z encoder : JVT/AVC Coding Stream #0:2(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 253 kb/s (default) Metadata: creation_time : 2017-11-13T05:47:44.000000Z At least one output file must be specified
以上有两个视频轨,一个音频轨,导出第一个视频轨为图片
ffmpeg -i qianyan.trec -map 0:v:0 -r 1 -f image2 image-%05d.jpeg
from:http://blog.csdn.net/season_hangzhou/article/details/27503421