ffmpeg mkv 转 mp4 导致黑屏,无声音

ffmpeg mkv 转 mp4 导致黑屏,无声音

我正在尝试将 mkv 视频转换为 mp4,但是我使用的代码无法正常工作。

我通常使用以下两个代码之一:

ffmpeg -i input.mkv -c:v copy -c:a copy output.mp4 ffmpeg -i input.mkv -acodec aac -strict -2 -ab 320k -c:v copy output.mp4

对于我尝试转换的视频,这两种方法都不起作用。我对此还不太熟悉,我不明白为什么我会得到这些结果。

结果是 mp4 只有一个黑屏,无法播放任何视频或声音。

代码1:

ffmpeg -i input.mkv -c:v copy -c:a copy output.mp4

结果:

ffmpeg version N-73633-gdfc5858 Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 4.9.2 (GCC)
  configuration: --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-lzma --enable-decklink --enable-zlib
  libavutil      54. 28.100 / 54. 28.100
  libavcodec     56. 47.100 / 56. 47.100
  libavformat    56. 40.100 / 56. 40.100
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 21.100 /  5. 21.100
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.100 /  1.  2.100
  libpostproc    53.  3.100 / 53.  3.100
Input #0, matroska,webm, from 'tb1.mkv':
  Metadata:
    title           : #01 All's well that ends well.
    encoder         : libebml v1.3.0 + libmatroska v1.4.0
    creation_time   : 2013-05-22 02:07:43
  Duration: 00:24:16.33, start: 0.000000, bitrate: 4643 kb/s
    Chapter #0:0: start 0.000000, end 51.051000
    Metadata:
      title           : Introduction
    Chapter #0:1: start 51.051000, end 142.142000
    Metadata:
      title           : OP - "Orion wo Nazoru"
    Chapter #0:2: start 142.142000, end 627.293333
    Metadata:
      title           : Part A
    Chapter #0:3: start 627.293333, end 1326.033042
    Metadata:
      title           : Part B
    Chapter #0:4: start 1326.033042, end 1416.331583
    Metadata:
      title           : ED - "Hoshi no Sumika"
    Chapter #0:5: start 1416.331583, end 1440.439000
    Metadata:
      title           : Conclusion
    Chapter #0:6: start 1440.439000, end 1456.330000
    Metadata:
      title           : Next Time
    Stream #0:0: Video: h264 (High 10), yuv420p10le, 1280x720 [SAR 1:1 DAR 16:9], 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
    Metadata:
      title           : 720p 10-bit h.264
    Stream #0:1(jpn): Audio: aac (LC), 48000 Hz, stereo, fltp (default)
    Metadata:
      title           : Japanese Dialogue (2.0 AAC)
    Stream #0:2(eng): Audio: aac (LC), 48000 Hz, stereo, fltp
    Metadata:
      title           : English Dialogue (2.0 AAC)
    Stream #0:3(jpn): Subtitle: ass (default)
    Metadata:
      title           : Full Subtitles - Karaoke & Hero Colors (ASS)
    Stream #0:4(jpn): Subtitle: ass
    Metadata:
      title           : Full Subtitles - Plain (ASS)
    Stream #0:5(eng): Subtitle: ass
    Metadata:
      title           : Theme Song Only Subtitles - Karaoke (ASS)
    Stream #0:6(eng): Subtitle: ass
    Metadata:
      title           : Theme Song Only Subtitles - Plain (ASS)
    Stream #0:7: Attachment: ttf
    Metadata:
      filename        : BELL.TTF
      mimetype        : application/x-truetype-font
    Stream #0:8: Attachment: ttf
    Metadata:
      filename        : BELLI.TTF
      mimetype        : application/x-truetype-font
    Stream #0:9: Attachment: ttf
    Metadata:
      filename        : KOMTXT__.ttf
      mimetype        : application/x-truetype-font
    Stream #0:10: Attachment: ttf
    Metadata:
      filename        : KOMTXTI_.ttf
      mimetype        : application/x-truetype-font
    Stream #0:11: Attachment: ttf
    Metadata:
      filename        : TEMPSITC.TTF
      mimetype        : application/x-truetype-font
[mp4 @ 00000000053fd800] Codec for stream 0 does not use global headers but container format requires global headers
[mp4 @ 00000000053fd800] Codec for stream 1 does not use global headers but container format requires global headers
Output #0, mp4, to 'tb1.mp4':
  Metadata:
    title           : #01 All's well that ends well.
    encoder         : Lavf56.40.100
    Chapter #0:0: start 0.000000, end 51.051000
    Metadata:
      title           : Introduction
    Chapter #0:1: start 51.051000, end 142.142000
    Metadata:
      title           : OP - "Orion wo Nazoru"
    Chapter #0:2: start 142.142000, end 627.293333
    Metadata:
      title           : Part A
    Chapter #0:3: start 627.293333, end 1326.033042
    Metadata:
      title           : Part B
    Chapter #0:4: start 1326.033042, end 1416.331583
    Metadata:
      title           : ED - "Hoshi no Sumika"
    Chapter #0:5: start 1416.331583, end 1440.439000
    Metadata:
      title           : Conclusion
    Chapter #0:6: start 1440.439000, end 1456.330000
    Metadata:
      title           : Next Time
    Stream #0:0: Video: h264 ([33][0][0][0] / 0x0021), yuv420p10le, 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 23.98 fps, 23.98 tbr, 16k tbn, 1k tbc (default)
    Metadata:
      title           : 720p 10-bit h.264
    Stream #0:1(jpn): Audio: aac ([64][0][0][0] / 0x0040), 48000 Hz, stereo (default)
    Metadata:
      title           : Japanese Dialogue (2.0 AAC)
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame=34917 fps=1057 q=-1.0 Lsize=  795559kB time=00:24:16.30 bitrate=4475.2kbits/s
video:763789kB audio:30446kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.166663%

代码2:

ffmpeg -i input.mkv -acodec aac -strict -2 -ab 320k -c:v copy output.mp4

结果:

Input #0, matroska,webm, from 'tb1.mkv':
  Metadata:
    title           : #01 All's well that ends well.
    encoder         : libebml v1.3.0 + libmatroska v1.4.0
    creation_time   : 2013-05-22 02:07:43
  Duration: 00:24:16.33, start: 0.000000, bitrate: 4643 kb/s
    Chapter #0:0: start 0.000000, end 51.051000
    Metadata:
      title           : Introduction
    Chapter #0:1: start 51.051000, end 142.142000
    Metadata:
      title           : OP - "Orion wo Nazoru"
    Chapter #0:2: start 142.142000, end 627.293333
    Metadata:
      title           : Part A
    Chapter #0:3: start 627.293333, end 1326.033042
    Metadata:
      title           : Part B
    Chapter #0:4: start 1326.033042, end 1416.331583
    Metadata:
      title           : ED - "Hoshi no Sumika"
    Chapter #0:5: start 1416.331583, end 1440.439000
    Metadata:
      title           : Conclusion
    Chapter #0:6: start 1440.439000, end 1456.330000
    Metadata:
      title           : Next Time
    Stream #0:0: Video: h264 (High 10), yuv420p10le, 1280x720 [SAR 1:1 DAR 16:9], 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
    Metadata:
      title           : 720p 10-bit h.264
    Stream #0:1(jpn): Audio: aac (LC), 48000 Hz, stereo, fltp (default)
    Metadata:
      title           : Japanese Dialogue (2.0 AAC)
    Stream #0:2(eng): Audio: aac (LC), 48000 Hz, stereo, fltp
    Metadata:
      title           : English Dialogue (2.0 AAC)
    Stream #0:3(jpn): Subtitle: ass (default)
    Metadata:
      title           : Full Subtitles - Karaoke & Hero Colors (ASS)
    Stream #0:4(jpn): Subtitle: ass
    Metadata:
      title           : Full Subtitles - Plain (ASS)
    Stream #0:5(eng): Subtitle: ass
    Metadata:
      title           : Theme Song Only Subtitles - Karaoke (ASS)
    Stream #0:6(eng): Subtitle: ass
    Metadata:
      title           : Theme Song Only Subtitles - Plain (ASS)
    Stream #0:7: Attachment: ttf
    Metadata:
      filename        : BELL.TTF
      mimetype        : application/x-truetype-font
    Stream #0:8: Attachment: ttf
    Metadata:
      filename        : BELLI.TTF
      mimetype        : application/x-truetype-font
    Stream #0:9: Attachment: ttf
    Metadata:
      filename        : KOMTXT__.ttf
      mimetype        : application/x-truetype-font
    Stream #0:10: Attachment: ttf
    Metadata:
      filename        : KOMTXTI_.ttf
      mimetype        : application/x-truetype-font
    Stream #0:11: Attachment: ttf
    Metadata:
      filename        : TEMPSITC.TTF
      mimetype        : application/x-truetype-font
[mp4 @ 00000000031b8e00] Codec for stream 0 does not use global headers but container format requires global headers
Output #0, mp4, to 'tb1.mp4':
  Metadata:
    title           : #01 All's well that ends well.
    encoder         : Lavf56.40.100
    Chapter #0:0: start 0.000000, end 51.051000
    Metadata:
      title           : Introduction
    Chapter #0:1: start 51.051000, end 142.142000
    Metadata:
      title           : OP - "Orion wo Nazoru"
    Chapter #0:2: start 142.142000, end 627.293333
    Metadata:
      title           : Part A
    Chapter #0:3: start 627.293333, end 1326.033042
    Metadata:
      title           : Part B
    Chapter #0:4: start 1326.033042, end 1416.331583
    Metadata:
      title           : ED - "Hoshi no Sumika"
    Chapter #0:5: start 1416.331583, end 1440.439000
    Metadata:
      title           : Conclusion
    Chapter #0:6: start 1440.439000, end 1456.330000
    Metadata:
      title           : Next Time
    Stream #0:0: Video: h264 ([33][0][0][0] / 0x0021), yuv420p10le, 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 23.98 fps, 23.98 tbr, 16k tbn, 1k tbc (default)
    Metadata:
      title           : 720p 10-bit h.264
    Stream #0:1(jpn): Audio: aac ([64][0][0][0] / 0x0040), 48000 Hz, stereo, fltp, 320 kb/s (default)
    Metadata:
      title           : Japanese Dialogue (2.0 AAC)
      encoder         : Lavc56.47.100 aac
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
frame=34917 fps=142 q=-1.0 Lsize=  821767kB time=00:24:16.30 bitrate=4622.6kbits/s
video:763789kB audio:56654kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.161340%

如果有人能帮助我弄清楚发生了什么事,我将不胜感激。

答案1

您的输出是 10 位视频(yuv420p10le) – 我猜 WMP 和其他几个播放器无法处理它。

为了兼容性,您必须转换(重新编码)视频以-pix_fmt yuv420p恢复为 8 位编码,这是当今大多数视频应用程序的默认设置,除非您想要进行 HDR 或增加色域。

相关内容