现在我正在尝试使用ffmpeg命令修剪mkv文件。
ffmpeg -y -i 1.mkv -filter_complex "[0:0]trim=start=201:duration=28,setpts=PTS-STARTPTS" a.mp4
处理a.mp4后创建长度(28s),但有问题。
那么你们能告诉我我能做些什么吗?
当ffmpeg处理时,它会显示一些错误:
D:\Work\ffmpeg\files> ffmpeg -y -i 1.mkv -filter_complex "[0:0]trim=start=201:duration=28,setpts=PTS-STARTPTS" a.mp4
ffmpeg version N-77883-gd7c75a5 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 5.2.0 (GCC)
configuration: --disable-static --enable-shared --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-libdcadec --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-libzimg --enable-lzma --enable-decklink --enable-zlib
libavutil 55. 13.100 / 55. 13.100
libavcodec 57. 22.100 / 57. 22.100
libavformat 57. 21.101 / 57. 21.101
libavdevice 57. 0.100 / 57. 0.100
libavfilter 6. 25.100 / 6. 25.100
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
Guessed Channel Layout for Input Stream #0.1 : mono
Input #0, matroska,webm, from '1.mkv':
Metadata:
ENCODER : Lavf56.1.0
Duration: 00:35:40.08, start: 0.000000, bitrate: 348 kb/s
Stream #0:0: Video: vp8, yuv420p, 640x480, SAR 1:1 DAR 4:3, 29.97 fps, 29.97 tbr, 1k tbn, 1k tbc
Stream #0:1: Audio: pcm_mulaw ([7][0][0][0] / 0x0007), 8000 Hz, 1 channels, s16, 64 kb/s
[libx264 @ 000002859baf3300] using SAR=1/1
[libx264 @ 000002859baf3300] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 000002859baf3300] profile High, level 3.0
[libx264 @ 000002859baf3300] 264 - core 148 r2638 7599210 - 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=6 lookahead_threads=1 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 'a.mp4':
Metadata:
encoder : Lavf57.21.101
Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 640x480 [SAR 1:1 DAR 4:3], q=-1--1, 29.97 fps, 30k tbn, 29.97 tbc
Metadata:
encoder : Lavc57.22.100 libx264
Side data:
unknown side data type 10 (24 bytes)
Stream #0:1: Audio: aac (LC) ([64][0][0][0] / 0x0040), 8000 Hz, mono, fltp, 48 kb/s
Metadata:
encoder : Lavc57.22.100 aac
Stream mapping:
Stream #0:0 (vp8) -> trim (graph 0)
setpts (graph 0) -> Stream #0:0 (libx264)
Stream #0:1 -> #0:1 (pcm_mulaw (native) -> aac (native))
Press [q] to stop, [?] for help
[vp8 @ 000002859d9ae460] Discarding interframe without a prior keyframe!
[vp8 @ 000002859d9aeb00] Discarding interframe without a prior keyframe!
[vp8 @ 000002859e8eee40] Discarding interframe without a prior keyframe!
[vp8 @ 000002859e8f5460] Discarding interframe without a prior keyframe!
Error while decoding stream #0:0: Invalid data found when processing input
Last message repeated 3 times
frame= 0 fps=0.0 q=0.0 size= 62kB time=00:00:22.27 bitrate= 22.6kbits/s
frame= 0 fps=0.0 q=0.0 size= 154kB time=00:00:41.08 bitrate= 30.6kbits/s
frame= 0 fps=0.0 q=0.0 size= 255kB time=00:01:02.20 bitrate= 33.6kbits/s
frame= 0 fps=0.0 q=0.0 size= 340kB time=00:01:19.34 bitrate= 35.1kbits/s
frame= 0 fps=0.0 q=0.0 size= 423kB time=00:01:39.31 bitrate= 34.9kbits/s
frame= 88 fps= 29 q=29.0 size= 518kB time=00:01:43.79 bitrate= 40.9kbits/
frame= 140 fps= 40 q=29.0 size= 613kB time=00:01:45.46 bitrate= 47.6kbits/
frame= 194 fps= 48 q=29.0 size= 719kB time=00:01:47.38 bitrate= 54.8kbits/
...
frame= 839 fps= 14 q=29.0 size= 10881kB time=00:34:51.52 bitrate= 42.6kbits/
frame= 839 fps= 14 q=29.0 size= 10962kB time=00:35:10.46 bitrate= 42.5kbits/
frame= 839 fps= 14 q=29.0 size= 11031kB time=00:35:25.44 bitrate= 42.5kbits/
frame= 839 fps= 14 q=-1.0 Lsize= 11266kB time=00:35:40.16 bitrate= 43.1kbits/s dup=284 drop=328 speed=34.6x
video:1083kB audio:10104kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.706855%
[libx264 @ 000002859baf3300] frame I:4 Avg QP:15.24 size: 22651
[libx264 @ 000002859baf3300] frame P:305 Avg QP:19.95 size: 2626
[libx264 @ 000002859baf3300] frame B:530 Avg QP:25.41 size: 408
[libx264 @ 000002859baf3300] consecutive B-frames: 15.7% 0.0% 0.4% 83.9%
[libx264 @ 000002859baf3300] mb I I16..4: 15.9% 63.7% 20.4%
[libx264 @ 000002859baf3300] mb P I16..4: 0.3% 1.9% 0.3% P16..4: 22.3% 6.2% 2.4% 0.0% 0.0% skip:66.5%
[libx264 @ 000002859baf3300] mb B I16..4: 0.0% 0.1% 0.0% B16..8: 16.1% 0.6% 0.1% direct: 0.2% skip:82.9% L0:48.2% L1:48.5% BI: 3.4%
[libx264 @ 000002859baf3300] 8x8 transform intra:71.1% inter:71.4%
[libx264 @ 000002859baf3300] coded y,uvDC,uvAC intra: 72.2% 78.3% 40.7% inter: 5.9% 4.0% 0.1%
[libx264 @ 000002859baf3300] i16 v,h,dc,p: 29% 30% 21% 20%
[libx264 @ 000002859baf3300] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 28% 18% 14% 5% 6% 9% 6% 9% 6%
[libx264 @ 000002859baf3300] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 38% 20% 11% 5% 5% 7% 5% 6% 4%
[libx264 @ 000002859baf3300] i8c dc,h,v,p: 46% 16% 27% 11%
[libx264 @ 000002859baf3300] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 000002859baf3300] ref P L0: 63.4% 21.5% 11.5% 3.6%
[libx264 @ 000002859baf3300] ref B L0: 92.6% 6.4% 1.0%
[libx264 @ 000002859baf3300] ref B L1: 96.4% 3.6%
[libx264 @ 000002859baf3300] kb/s:316.59
[aac @ 000002859baf4400] Qavg: 65377.508
D:\Work\ffmpeg\files>
答案 0 :(得分:0)
尝试以下两个步骤:
ffmpeg -y -i 1.mkv -c copy 1new.mkv
ffmpeg -y -i 1new.mkv -vf "trim=start=201:duration=28,setpts=PTS-STARTPTS" -af "atrim=start=201:duration=28,asetpts=PTS-STARTPTS" a.mp4
我已经添加了第一步,因为我已经看到了这个错误 - Discarding interframe without a prior keyframe
- 在格式错误的MKV中,ffmpeg无法正确读取。重新打包通常可以解决这个问题。
你可能应该升级你的ffmpeg,这是一个相当古老的版本。