ffmpeg concatenate导致第二个输入文件的输出错误/乱码

时间:2017-02-28 16:14:33

标签: ffmpeg

我正在尝试使用ffmpeg concat demuxer将两个视频连接在一起:一个5秒的介绍启动和一个60秒的主/视频。我知道两个文件的编码需要相同才能实现。我认为它们是,但结果输出显示介绍就好了,接着是一个完全乱码的身体。我错过了什么?

ffmpeg -f concat -i concat.txt -c copy output.mp4

concat.txt的内容:

file 'intro.mp4'
file 'body.mp4'

和两个输入文件的ffprobe输出:

intro.mp4

ffprobe version 3.2.4 Copyright (c) 2007-2017 the FFmpeg developers
  built with Apple LLVM version 7.0.2 (clang-700.1.81)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/3.2.4 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-opencl --disable-lzma --enable-vda
  libavutil      55. 34.101 / 55. 34.101
  libavcodec     57. 64.101 / 57. 64.101
  libavformat    57. 56.101 / 57. 56.101
  libavdevice    57.  1.100 / 57.  1.100
  libavfilter     6. 65.100 /  6. 65.100
  libavresample   3.  1.  0 /  3.  1.  0
  libswscale      4.  2.100 /  4.  2.100
  libswresample   2.  3.100 /  2.  3.100
  libpostproc    54.  1.100 / 54.  1.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'intro.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.56.101
  Duration: 00:00:05.04, start: 0.000000, bitrate: 73 kb/s
    Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 960x720 [SAR 1:1 DAR 4:3], 69 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
    Metadata:
      handler_name    : VideoHandler

body.mp4

ffprobe version 3.2.4 Copyright (c) 2007-2017 the FFmpeg developers
  built with Apple LLVM version 7.0.2 (clang-700.1.81)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/3.2.4 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-opencl --disable-lzma --enable-vda
  libavutil      55. 34.101 / 55. 34.101
  libavcodec     57. 64.101 / 57. 64.101
  libavformat    57. 56.101 / 57. 56.101
  libavdevice    57.  1.100 / 57.  1.100
  libavfilter     6. 65.100 /  6. 65.100
  libavresample   3.  1.  0 /  3.  1.  0
  libswscale      4.  2.100 /  4.  2.100
  libswresample   2.  3.100 /  2.  3.100
  libpostproc    54.  1.100 / 54.  1.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'body.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.56.101
  Duration: 00:00:36.84, start: 0.000000, bitrate: 5615 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 960x720 [SAR 1:1 DAR 4:3], 5613 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
    Metadata:
      handler_name    : VideoHandler

输出ffmpeg:

ffmpeg version 3.2.4 Copyright (c) 2000-2017 the FFmpeg developers
  built with Apple LLVM version 7.0.2 (clang-700.1.81)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/3.2.4 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-opencl --disable-lzma --enable-vda
  libavutil      55. 34.101 / 55. 34.101
  libavcodec     57. 64.101 / 57. 64.101
  libavformat    57. 56.101 / 57. 56.101
  libavdevice    57.  1.100 / 57.  1.100
  libavfilter     6. 65.100 /  6. 65.100
  libavresample   3.  1.  0 /  3.  1.  0
  libswscale      4.  2.100 /  4.  2.100
  libswresample   2.  3.100 /  2.  3.100
  libpostproc    54.  1.100 / 54.  1.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fdda3018000] Auto-inserting h264_mp4toannexb bitstream filter
Input #0, concat, from 'concat.txt':
  Duration: N/A, start: 0.000000, bitrate: 69 kb/s
    Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 960x720 [SAR 1:1 DAR 4:3], 69 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc
    Metadata:
      handler_name    : VideoHandler
Output #0, mp4, to 'output.mp4':
  Metadata:
    encoder         : Lavf57.56.101
    Stream #0:0(eng): Video: h264 (High) ([33][0][0][0] / 0x0021), yuv420p, 960x720 [SAR 1:1 DAR 4:3], q=2-31, 69 kb/s, 25 fps, 25 tbr, 12800 tbn, 12800 tbc
    Metadata:
      handler_name    : VideoHandler
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fdda3800000] Auto-inserting h264_mp4toannexb bitstream filter
frame= 1047 fps=973 q=-1.0 Lsize=   25299kB time=00:00:41.76 bitrate=4962.8kbits/s speed=38.8x    
video:25286kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.050621%

据我所知,除了比特率和语言之外,一切都是相同的。设置语言似乎没有什么区别。我试图将介绍转换为更高比特率的介绍但不能让它坚持输出。我可以转码其中一个文件(理想情况是介绍),但不知道还有什么可以尝试更改。想法?

1 个答案:

答案 0 :(得分:0)

感谢@Mulvya的建议,我使用mediainfo检查文件,发现这两个文件已使用不同的crf设置编码。使用相同的crf重新编码简介会导致工作连接文件。