我有几个视频文件想要合并在一起,在加速了一段 2 分钟的视频后(这段 2 分钟的视频很无趣,但加速后就没问题了,而且不会失去连续性。)当我尝试将编辑后的文件与其他文件合并时,失败了。以下是错误的示例。
[mp4 @ 0x103b180] Non-monotonous DTS in output stream 0:0; previous: 22228547, current: 7750549; changing to 22228548. This may result in incorrect timestamps in the output file.
发出此命令时出现此错误:
ffmpeg -f concat -safe 0 -i mylist.txt -c copy output.mp4
我刚刚发布了这个:
ffprobe -select_streams a -show_entries stream=time_base -of compact=p=0 newout8.mp4
输出如下:
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'newout8.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf56.40.101
Duration: 00:00:14.68, start: 0.021333, bitrate: 23787 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc), 1920x1080 [SAR 1:1 DAR 16:9], 23651 kb/s, 29.97 fps, 29.97 tbr, 29967 tbn, 59.94 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 128 kb/s (default)
Metadata:
handler_name : SoundHandler
time_base=1/48000
这是我需要合并(concat)的文件之一。我使用了:
ffprobe -select_streams a -show_entries stream=time_base -of compact=p=0 out7.mp4
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'out7.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf56.40.101
Duration: 00:04:07.02, start: 0.000000, bitrate: 30106 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 29972 kb/s, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
handler_name : SoundHandler
time_base=1/48000
据我了解,我需要重新编码短片 (newout8.mp4),然后文件才能很好地合并。此外,ffmpeg 确实输出了一个文件,但播放无法正常进行。
* 以下是新内容 *
以下是尝试连接的完整输出:
/New$ ffmpeg -f concat -safe 0 -i mylist.txt -c copy output.mp4ffmpeg version 2.8.11-0ubuntu0.16.04.1 Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.4) 20160609
configuration: --prefix=/usr --extra-version=0ubuntu0.16.04.1 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-libx264 --enable-libopencv
libavutil 54. 31.100 / 54. 31.100
libavcodec 56. 60.100 / 56. 60.100
libavformat 56. 40.101 / 56. 40.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 40.101 / 5. 40.101
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.101 / 1. 2.101
libpostproc 53. 3.100 / 53. 3.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0xfda560] Auto-inserting h264_mp4toannexb bitstream filter
Input #0, concat, from 'mylist.txt':
Duration: N/A, start: 0.000000, bitrate: 30100 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 29972 kb/s, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
Metadata:
handler_name : VideoHandler
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s
Metadata:
handler_name : SoundHandler
File 'output.mp4' already exists. Overwrite ? [y/N] y
[mp4 @ 0xfe2180] Codec for stream 0 does not use global headers but container format requires global headers
[mp4 @ 0xfe2180] Codec for stream 1 does not use global headers but container format requires global headers
Output #0, mp4, to 'output.mp4':
Metadata:
encoder : Lavf56.40.101
Stream #0:0(eng): Video: h264 ([33][0][0][0] / 0x0021), yuvj420p, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 29972 kb/s, 29.97 fps, 29.97 tbr, 90k tbn, 90k tbc
Metadata:
handler_name : VideoHandler
Stream #0:1(eng): Audio: aac ([64][0][0][0] / 0x0040), 48000 Hz, stereo, 128 kb/s
Metadata:
handler_name : SoundHandler
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[mov,mp4,m4a,3gp,3g2,mj2 @ 0xfda560] Auto-inserting h264_mp4toannexb bitstream filter
[mp4 @ 0xfe2180] Non-monotonous DTS in output stream 0:0; previous: 22228206, current: 7409208; changing to 22228207. This may result in incorrect timestamps in the output file.
[mp4 @ 0xfe2180] Non-monotonous DTS in output stream 0:0; previous: 22228207, current: 7410209; changing to 22228208. This may result in incorrect timestamps in the output file.
[mp4 @ 0xfe2180] Non-monotonous DTS in output stream 0:0; previous: 22228208, current: 7411210; changing to 22228209. This may result in incorrect timestamps in the output file.
[mp4 @ 0xfe2180] Non-monotonous DTS in output stream 0:0; previous: 22228209, current: 7412211; changing to 22228210. This may result in incorrect timestamps in the output file.
[mp4 @ 0xfe2180] Non-monotonous DTS in output stream 0:0; previous: 22228210, current: 7413212; changing to 22228211. This may result in incorrect timestamps in the output file.
[mp4 @ 0xfe2180] Non-monotonous DTS in output stream 0:0; previous: 22228211, current: 7414213; changing to 22228212. This may result in incorrect timestamps in the output file.
[mp4 @ 0xfe2180] Non-monotonous DTS in output stream 0:0; previous: 22228212, current: 7415214; changing to 22228213. This may result in incorrect timestamps in the output file.
[mp4 @ 0xfe2180] Non-monotonous DTS in output stream 0:0; previous: 22228213, current: 7416215; changing to 22228214. This may result in incorrect timestamps in the output file.
[mp4 @ 0xfe2180] Non-monotonous DTS in output stream 0:0; previous: 22228214, current: 7417216; changing to 22228215. This may result in incorrect timestamps in the output file.
[mp4 @ 0xfe2180] Non-monotonous DTS in output stream 0:0; previous: 22228215, current: 7418217; changing to 22228216. This may result in incorrect timestamps in the output file.
[mp4 @ 0xfe2180] Non-monotonous DTS in output stream 0:0; previous: 22228216, current: 7419218; changing to 22228217. This may result in incorrect timestamps in the output file.
[mp4 @ 0xfe2180] Non-monotonous DTS in output stream 0:0; previous: 22228217, current: 7420219; changing to 22228218. This may result in incorrect timestamps in the output file.
[mp4 @ 0xfe2180] Non-monotonous DTS in output stream 0:0; previous: 22228218, current: 7421220; changing to 22228219. This may result in incorrect timestamps in the output file.
[mp4 @ 0xfe2180] Non-monotonous DTS in output stream 0:0; previous: 22228219, current: 7422221; changing to 22228220. This may result in incorrect timestamps in the output file.
[mp4 @ 0xfe2180] Non-monotonous DTS in output stream 0:0; previous: 22228220, current: 7423222; changing to 22228221. This may result in incorrect timestamps in the output file.
[mp4 @ 0xfe2180] Non-monotonous DTS in output stream 0:0; previous: 22228221, current: 7424223; changing to 22228222. This may result in incorrect timestamps in the output file.
[mp4 @ 0xfe2180] Non-monotonous DTS in output stream 0:0; previous: 22228222, current: 7425224; changing to 22228223. This may result in incorrect timestamps in the output file.
[mp4 @ 0xfe2180] Non-monotonous DTS in output stream 0:0; previous: 22228223, current: 7426225; changing to 22228224. This may result in incorrect timestamps in the output file.
<<< Cut out many lines of errors because body limit of 30,000 charactors prevented me from posting all 70844 characters. >>
[mp4 @ 0xfe2180] Non-monotonous DTS in output stream 0:0; previous: 22228555, current: 7758557; changing to 22228556. This may result in incorrect timestamps in the output file.
[mov,mp4,m4a,3gp,3g2,mj2 @ 0xfda560] Auto-inserting h264_mp4toannexb bitstream filter
[mp4 @ 0xfe2180] Packet with invalid duration -29667 in stream 0ate=30032.2kbits/s
frame= 9451 fps=412 q=-1.0 Lsize= 1157876kB time=00:05:15.70 bitrate=30045.3kbits/s
video:1152663kB audio:4933kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.024227%
以下是 mylist.txt 的内容
#file './out1.mp4'
#file './out2.mp4'
#file './out4.mp4'
#file './out5.mp4'
#file './out6.mp4'
file './out7.mp4'
file './out8speed3.mp4'
file './out9.mp4'
#file './out10.mp4'
正如您上面看到的,我通过将其限制为合并 3 个文件(2 个未编辑的文件和中间的已编辑文件(out8speed3))缩短了错误。
我尝试发布整个错误信息,但是对于 30,000 个字符的帖子限制来说,这太多了(如上所述)。
这是新编辑的 ffprob(我将音频比特率更改为 127k,就像其他文件一样,在将剪辑从 2 分钟加速到 15 秒后。)
/New$ ffprobe -select_streams a -show_entries stream=time_base -of compact=p=0 out8speed3.mp4
ffprobe version 2.8.11-0ubuntu0.16.04.1 Copyright (c) 2007-2017 the FFmpeg developers
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.4) 20160609
configuration: --prefix=/usr --extra-version=0ubuntu0.16.04.1 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-libx264 --enable-libopencv
libavutil 54. 31.100 / 54. 31.100
libavcodec 56. 60.100 / 56. 60.100
libavformat 56. 40.101 / 56. 40.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 40.101 / 5. 40.101
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.101 / 1. 2.101
libpostproc 53. 3.100 / 53. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'out8speed3.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf56.40.101
Duration: 00:00:11.68, start: 0.021333, bitrate: 29167 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc), 1920x1080 [SAR 1:1 DAR 16:9], 29032 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
handler_name : SoundHandler
time_base=1/48000
ffprobe 输出的 out7.mp4 前面已经列出,下面是 out9.mp4 的输出
/New$ ffprobe -select_streams a -show_entries stream=time_base -of compact=p=0 out9.mp4
ffprobe version 2.8.11-0ubuntu0.16.04.1 Copyright (c) 2007-2017 the FFmpeg developers
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.4) 20160609
configuration: --prefix=/usr --extra-version=0ubuntu0.16.04.1 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-libx264 --enable-libopencv
libavutil 54. 31.100 / 54. 31.100
libavcodec 56. 60.100 / 56. 60.100
libavformat 56. 40.101 / 56. 40.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 40.101 / 5. 40.101
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.101 / 1. 2.101
libpostproc 53. 3.100 / 53. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'out9.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf56.40.101
Duration: 00:00:57.00, start: 0.008000, bitrate: 29959 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 30006 kb/s, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 127 kb/s (default)
Metadata:
handler_name : SoundHandler
time_base=1/48000
答案1
新$ ffmpeg -i newout8.mp4 -video_track_timescale 90000 -strict -2 newout8speed3.mp4
修复了文件。
我在这里找到了这个: https://stackoverflow.com/questions/31691943/ffmpeg-concat-poduces-dts-out-of-order-errors
我能弄清楚他们正在谈论 tbn 值。我说的是 90k,而不是 90000,这让我更难弄清楚。
事实证明,我的视频需要转换为 90000,就像另一篇文章中所说的那样。