在我本地E盘BaiduNetdiskDownload目录下存在一个football.mkv的视频,太长了,我只要前面一部分。比如我只想要第一分钟到第二十分钟,截完后还放在原目录,新文件名叫footest.mkv,操作命令如下:
E:BaiduNetdiskDownload>ffmpeg -i football.mkv -vcodec copy -acodec copy -ss 00:01:00 -to 00:20:00 footest.mkv ffmpeg version git-2020-03-06-cfd9a65 Copyright (c) 2000-2020 the FFmpeg developers built with gcc 9.2.1 (GCC) 20200122 configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-ffnvcodec --enable-cuda-llvm --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf libavutil 56. 42.100 / 56. 42.100 libavcodec 58. 73.102 / 58. 73.102 libavformat 58. 39.101 / 58. 39.101 libavdevice 58. 9.103 / 58. 9.103 libavfilter 7. 77.100 / 7. 77.100 libswscale 5. 6.100 / 5. 6.100 libswresample 3. 6.100 / 3. 6.100 libpostproc 55. 6.100 / 55. 6.100 Input #0, matroska,webm, from 'football.mkv': Metadata: title : 天下足球网 http://www.txzqw.cc encoder : libebml v1.3.0 + libmatroska v1.4.1 creation_time : 2017-04-23T13:24:10.000000Z Duration: 00:50:34.92, start: 0.000000, bitrate: 4392 kb/s Stream #0:0: Video: h264 (Main), yuv420p(progressive), 1280x720 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 1k tbn, 50 tbc (default) Stream #0:1: Audio: ac3, 48000 Hz, 5.1(side), fltp, 384 kb/s (default) Output #0, matroska, to 'footest.mkv': Metadata: title : 天下足球网 http://www.txzqw.cc encoder : Lavf58.39.101 Stream #0:0: Video: h264 (Main) (H264 / 0x34363248), yuv420p(progressive), 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 25 fps, 25 tbr, 1k tbn, 1k tbc (default) Stream #0:1: Audio: ac3 ([0] [0][0] / 0x2000), 48000 Hz, 5.1(side), fltp, 384 kb/s (default) Stream mapping: Stream #0:0 -> #0:0 (copy) Stream #0:1 -> #0:1 (copy) Press [q] to stop, [?] for help [matroska,webm @ 00000189925aa500] Element at 0x1ee7223b ending at 0x1ef70de1 exceeds containing master element ending at 0x1ef50980 frame=28331 fps=5099 q=-1.0 Lsize= 609181kB time=00:18:59.96 bitrate=4377.7kbits/s speed= 205x video:555362kB audio:53358kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.075676%
命令参数说明:
-i 源视频文件
-vcodec copy 使用跟原视频相同的视频编解码器
-acodec copy 使用跟原视频相同的音频编解码器
-ss 从哪个时间点开始截取
-to 从哪个时间点结束截取