gpt4 book ai didi

video - FFmpeg - 不同时基的 Concat 视频

转载 作者:行者123 更新时间:2023-12-04 22:45:09 27 4
gpt4 key购买 nike

这个问题在这里已经有了答案:





ffmpeg - Join two movies with different timebase

(3 个回答)


3年前关闭。




我正在尝试使用 concat demuxer 连接视频,但在使用一个视频(下面的“video2.mp4”)时它不起作用。不起作用,我的意思是在播放器上播放连接的视频将一直有效,直到第二个视频部分开始(它只是无法再读取视频)。虽然它适用于 concat 过滤器。它们都是mp4视频,所以我认为是因为时基?我可以使用 concat demuxer 连接其他视频,并且效果很好(即使分辨率/比特率不同)。它仅在尝试连接“video2.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 过滤器吗,或者如果真的有问题,我可以更改“video1.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

连接.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%

先感谢您 !

最佳答案

video2.mp4 中的 H.264 比特流有些奇怪

下面的步骤(应用一次)为我解决了这个问题,生成的 concat 在 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 将其混合到新容器
ffmpeg -i v2.h264 -i v2.mp4 -c copy -video_track_timescale 90000 -map 0 -map 1:a v2-ok.mp4

现在,您可以将 v2-ok.mp4 与 video1.mp4 连接起来

关于video - FFmpeg - 不同时基的 Concat 视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41701511/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com