ffmpeg 将 .mkv 转换为 .264

ffmpeg converting .mkv to .264

我想将 .mkv 转换为 .264。 我尝试使用 ffmpeg:

ffmpeg -i input.mkv -vcodec copy -acodec copy output.264

它可以正常工作,但是当我尝试使用 ffplay 播放 output.264 时:

ffplay -f h264 -i output.264

ffplay 响应是:

ffplay version N-75924-gd25c033 Copyright (c) 2003-2015 the FFmpeg developers
  built with gcc 5.2.0 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-av
isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab
le-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --
enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-l
ibilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enab
le-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --en
able-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --ena
ble-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc
 --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enabl
e-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --ena
ble-decklink --enable-zlib
  libavutil      55.  3.100 / 55.  3.100
  libavcodec     57.  5.100 / 57.  5.100
  libavformat    57.  3.100 / 57.  3.100
  libavdevice    57.  0.100 / 57.  0.100
  libavfilter     6. 11.100 /  6. 11.100
  libswscale      4.  0.100 /  4.  0.100
  libswresample   2.  0.100 /  2.  0.100
  libpostproc    54.  0.100 / 54.  0.100
[h264 @ 03972220] sps_id 24 out of rangeq=    0KB sq=    0B f=0/0
[h264 @ 03972220] missing picture in access unit with size 12836207
[h264 @ 03972220] data partitioning is not implemented. Update your FFmpeg versi
on to the newest one from Git. If the problem still occurs, it means that your f
ile has a feature which has not been implemented.
[h264 @ 03972220] If you want to help, upload a sample of this file to ftp://upl
oad.ffmpeg.org/incoming/ and contact the ffmpeg-devel mailing list. (ffmpeg-deve
l@ffmpeg.org)
[h264 @ 03972220] data partitioning is not implemented. Update your FFmpeg versi
on to the newest one from Git. If the problem still occurs, it means that your f
ile has a feature which has not been implemented.
[h264 @ 03972220] If you want to help, upload a sample of this file to ftp://upl
oad.ffmpeg.org/incoming/ and contact the ffmpeg-devel mailing list. (ffmpeg-deve
l@ffmpeg.org)
[h264 @ 03972220] sps_id 24 out of range
[h264 @ 03972220] data partitioning is not implemented. Update your FFmpeg versi
on to the newest one from Git. If the problem still occurs, it means that your f
ile has a feature which has not been implemented.
[h264 @ 03972220] If you want to help, upload a sample of this file to ftp://upl
oad.ffmpeg.org/incoming/ and contact the ffmpeg-devel mailing list. (ffmpeg-deve
l@ffmpeg.org)
[h264 @ 03972220] no frame!
[h264 @ 039696e0] Stream #0: not enough frames to estimate rate; consider increa
sing probesize
[h264 @ 039696e0] decoding for stream 0 failed
[h264 @ 039696e0] Could not find codec parameters for stream 0 (Video: h264, non
e): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Contagion.264: could not find codec parameters

如何修复它并将 .mkv 正确转换为 .264?

您不能将音轨放入原始 H.264 文件中,您需要使用 h264_mp4toannexb 比特流过滤器将流转换为 Annex B 格式:

ffmpeg -i input.mkv -c:v copy -an -bsf:v h264_mp4toannexb out.264

比特流过滤器无需重新编码即可工作。