我正在尝试将视频与concat演示程序连接起来,但是当使用一个视频(下面的“视频2.mp4”)时,它不起作用。所谓不工作,我的意思是在播放器上播放连在一起的视频,直到第二个视频部分开始工作(它只是不能再读取视频了)。不过,它可以与凹式过滤器一起工作。它们都是mp4视频,所以我想是因为时间的关系?我可以连接其他视频与凹式演示程序,它的工作很好(甚至不同的分辨率/比特率)。只有在试图连接“视频2.mp4”时才会发生这种情况。
另外,我也有很多这样的警告/错误,可能是在ffmpeg开始连接第二个视频时:
[mp4 @ 0x7f847a814800] Non-monotonous DTS in output stream 0:0; previous: 906906, current: 302359; changing to 906907. This may result in incorrect timestamps in the output file.
什么是最好的方式,有一个最低限度的时间?我真的需要使用串接过滤器吗?如果真的有问题的话,我可以改变“concat 1.mp4”的时间基吗?
任何帮助都将不胜感激,谢谢!
视频1:
ffprobe version 3.2.2 Copyright (c) 2007-2016 the FFmpeg developers
built with Apple LLVM version 8.0.0 (clang-800.0.42.1)
configuration: --prefix=/usr/local/Cellar/ffmpeg/3.2.2 --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.100 / 55. 34.100
libavcodec 57. 64.101 / 57. 64.101
libavformat 57. 56.100 / 57. 56.100
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 'video1.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
creation_time : 2016-08-17T22:50:35.000000Z
Duration: 00:00:10.11, start: 0.000000, bitrate: 38018 kb/s
Stream #0:0(eng): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p, 1696x848, 37832 kb/s, 29.97 fps, 29.97 tbr, 90k tbn, 180k tbc (default)
Metadata:
creation_time : 2016-08-18T00:02:24.000000Z
handler_name : VideoHandle
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 189 kb/s (default)
Metadata:
creation_time : 2016-08-18T00:02:24.000000Z
handler_name : SoundHandle
视频2:
ffprobe version 3.2.2 Copyright (c) 2007-2016 the FFmpeg developers
built with Apple LLVM version 8.0.0 (clang-800.0.42.1)
configuration: --prefix=/usr/local/Cellar/ffmpeg/3.2.2 --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.100 / 55. 34.100
libavcodec 57. 64.101 / 57. 64.101
libavformat 57. 56.100 / 57. 56.100
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 'video2.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: mp42mp41
creation_time : 2017-01-06T22:30:23.000000Z
Duration: 00:00:08.19, start: 0.000000, bitrate: 101474 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 4096x2048 [SAR 1:1 DAR 2:1], 101549 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc (default)
Metadata:
creation_time : 2017-01-06T22:30:23.000000Z
handler_name : ?Mainconcept Video Media Handler
encoder : AVC Coding
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 125 kb/s (default)
Metadata:
creation_time : 2017-01-06T22:30:23.000000Z
handler_name : #Mainconcept MP4 Sound Media Handler
FFMpeg命令:
ffmpeg -f concat -safe 0 -i concat.txt -c copy result.mp4
concat.txt:
file '/path/to/video1.mp4'
file '/path/to/video2.mp4'
指挥结果:
ffmpeg version 3.2.2 Copyright (c) 2000-2016 the FFmpeg developers
built with Apple LLVM version 8.0.0 (clang-800.0.42.1)
configuration: --prefix=/usr/local/Cellar/ffmpeg/3.2.2 --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.100 / 55. 34.100
libavcodec 57. 64.101 / 57. 64.101
libavformat 57. 56.100 / 57. 56.100
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 @ 0x7fbd8b808c00] Auto-inserting h264_mp4toannexb bitstream filter
Input #0, concat, from 'concat.txt':
Duration: N/A, start: 0.000000, bitrate: 38021 kb/s
Stream #0:0(eng): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p, 1696x848, 37832 kb/s, 29.97 fps, 29.97 tbr, 90k tbn, 180k tbc
Metadata:
creation_time : 2016-08-18T00:02:24.000000Z
handler_name : VideoHandle
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 189 kb/s
Metadata:
creation_time : 2016-08-18T00:02:24.000000Z
handler_name : SoundHandle
Output #0, mp4, to 'result.mp4':
Metadata:
encoder : Lavf57.56.100
Stream #0:0(eng): Video: h264 (Baseline) ([33][0][0][0] / 0x0021), yuv420p, 1696x848, q=2-31, 37832 kb/s, 29.97 fps, 29.97 tbr, 90k tbn, 90k tbc
Metadata:
creation_time : 2016-08-18T00:02:24.000000Z
handler_name : VideoHandle
Stream #0:1(eng): Audio: aac (LC) ([64][0][0][0] / 0x0040), 48000 Hz, stereo, 189 kb/s
Metadata:
creation_time : 2016-08-18T00:02:24.000000Z
handler_name : SoundHandle
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame= 112 fps=0.0 q=-1.0 size= 12701kB time=00:00:03.70 bitrate=28092.2kbits/s speed= 7.4x
frame= 151 fps=151 q=-1.0 size= 18853kB time=00:00:05.00 bitrate=30857.5kbits/s speed= 5x
frame= 224 fps=149 q=-1.0 size= 30042kB time=00:00:07.44 bitrate=33074.8kbits/s speed=4.95x
frame= 268 fps=134 q=-1.0 size= 36596kB time=00:00:08.90 bitrate=33650.8kbits/s speed=4.44x
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fbd8a808000] Auto-inserting h264_mp4toannexb bitstream filter.9x
[mp4 @ 0xb545d000] Non-monotonous DTS in output stream 0:1; previous: 484352, current: 445939; changing to 484353. This may result in incorrect timestamps in the output file.
[concat @ 0xb545c400] DTS 304057 < 906906 out of order
[mp4 @ 0xb545d000] Non-monotonous DTS in output stream 0:0; previous: 906906, current: 304057; changing to 906907. This may result in incorrect timestamps in the output file.
[mp4 @ 0xb545d000] Non-monotonous DTS in output stream 0:1; previous: 484353, current: 446963; changing to 484354. This may result in incorrect timestamps in the output file.
...
... like 100 DTS errors ...
...
[mp4 @ 0xb545d000] Non-monotonous DTS in output stream 0:0; previous: 907150, current: 548301; changing to 907151. This may result in incorrect timestamps in the output file.
frame= 548 fps=169 q=-1.0 Lsize= 148399kB time=00:00:18.28 bitrate=66493.7kbits/s speed=5.64x
video:148027kB audio:359kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.008622%
提前谢谢你!
发布于 2017-01-19 14:17:35
视频2.mp4中的H.264比特流有点古怪。
下面的步骤(一次应用)为我解决了这个问题,由此产生的接口可以很好地使用ffplay、Potplayer、VLC、WMP、Chrome和Firefox。
#1将视频2转换为匹配视频1
ffmpeg -i video2.mp4 -vf scale=1696x848 -profile:v baseline -c:a copy v2.mp4
#2提取到原始比特流
ffmpeg -i v2.mp4 -c copy -f h264 v2.h264
#3 Mux到新容器
ffmpeg -i v2.h264 -i v2.mp4 -c copy -video_track_timescale 90000 -map 0 -map 1:a v2-ok.mp4
现在,您可以将v2-ok.mp4与视频1.mp4连接起来。
发布于 2019-05-03 04:36:43
问题在于时间基础。Ffmpeg在第二个流中添加了一个偏移量,但在其他情况下,它不会改变它们的时间戳,尽管它应该这样做。
我从来没有得到任何与时间相关的选择来做任何事情。对我起作用的是:复制到mkv,它对视频流有1/1000的时间基(ffmpeg报告为'1k tbn')。这使得所有时间戳一致。那就打电话。
通常情况下,webm和mkv基本上是一样的,但是mkv接受H.264,而webm目前不接受。
请注意,带有来自四舍五入的任何轻微抖动的时间戳可能会导致丢弃或重复的帧和设计不当的fps更改过滤器。
如果仍然存在空白(但没有速度变化或错误消息),请确保音频不略长于视频流,并在必要时对其进行修剪;您可以使用'ffmpeg -i video 1.mp4 -i video 1.mp4 -c copy -map 0:v -map 1:a -shortest trimed.mp4‘自动完成此操作。
我把这两个问题的答案都贴上了,不知道这是否允许。
发布于 2018-07-13 13:27:32
在我看来,问题的关键在于,在审查这两段视频时,它们的比特率显然有很大的不同。与其他因素不同,这是一个只有通过重新编码才能纠正的问题.
根据用户发布的数据,视频1的视频比特率为37,832 kb/s,而视频2的视频比特率为101,549 kb/s。
无论采取什么其他措施(例如匹配帧大小),视频播放器都将在连接点暂停,因为它必须调整以(低)初始比特率积累和显示数据,并开始以新的(高得多的)比特率显示修改后的图像。
有趣的是,如果问题是以另一种方式向播放器提出的,则可能不是这样(即可能不会引起注意):如果视频1是以高比特率编码的,并且合并的文件随后下降到一个较低的比特率部分。在这种情况下,最初的缓冲水平对电影的两部分来说都是足够的,因为后半段需要更少的缓冲。根据我的经验,回放中的暂停是必须在连接点提高缓冲速率的结果,需要时间缓冲额外的数据,如果缓冲速率被降低,则不会出现这种情况。
此外,我还要指出这种差异的极端性质。比特率增加了200 %,新的比特率是初始速率每秒大小的3倍。对于玩家来说,这确实是一个极端的挑战,它一直在以一种速度飞快地前进,然后遇到一个瞬时的、永久的三倍的比特率。如果跳跃是适度的,那么播放中的停顿可能根本就不会被察觉。但是,如果比特率在没有警告的情况下达到三倍,那么初始视频缓冲区就很难使其平滑,并且必然需要时间来缓冲额外的数据。这甚至不是数据率的飙升,而是永久性的增长。
难怪有些玩家会崩溃。这说明了任何视频软件播放器的健壮性,它只是暂停,或口吃,面对这种情况。总的来说,如果增幅低于初始比特率的50 %,我预计不会停下来,但200 %的增长只是在讨好麻烦。
显然,如果你不平衡图像的帧大小,即使缓冲是完全足够的,变化也是非常明显的。我要说的是,即使视频1和视频2都有相同的图像大小,如果比特率在连接点跳到更高的值,播放中仍会出现暂停。
https://stackoverflow.com/questions/41701511
复制相似问题