gpt4 book ai didi

audio - ffmpeg 连接不同步音频的视频

转载 作者:行者123 更新时间:2023-12-02 23:09:02 26 4
gpt4 key购买 nike

我正在尝试将 3 个 mp4 文件连接成 1 个。
这是我正在制作的 ffmpeg 命令:

shell_exec('ffmpeg -f concat -i '.$random.'.txt -c:v libx264 -preset ultrafast -crf 30 -c:a copy '.$uploadfolder.$random.'.mp4 2>&1');

第1个和第3个文件是入口和结束图形场景,有以上信息:

pinicial.mp4
ffprobe version N-76417-gee20354 Copyright (c) 2007-2015 the FFmpeg developers
built with gcc 4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5)
configuration: --prefix=/home/dmarcos89/ffmpeg_build --extra-cflags=-I/home/dmarcos89/ffmpeg_build/include --extra-ldflags=-L/home/dmarcos89/ffmpeg_build/lib --bindir=/usr/local/bin --pkg-config-flags=--static --enable-gpl --enable-nonfree --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265
libavutil 55. 5.100 / 55. 5.100
libavcodec 57. 13.102 / 57. 13.102
libavformat 57. 13.100 / 57. 13.100
libavdevice 57. 0.100 / 57. 0.100
libavfilter 6. 14.101 / 6. 14.101
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.100 / 2. 0.100
libpostproc 54. 0.100 / 54. 0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'http://filtremoscolombia.com/test/videos/placas/pinicio.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.13.100
Duration: 00:00:03.14, start: 0.021333, bitrate: 413 kb/s
Stream #0:0(eng): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 367 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 43 kb/s (default)
Metadata:
handler_name : SoundHandler

pfinal.mp4
ffprobe version N-76417-gee20354 Copyright (c) 2007-2015 the FFmpeg developers
built with gcc 4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5)
configuration: --prefix=/home/dmarcos89/ffmpeg_build --extra-cflags=-I/home/dmarcos89/ffmpeg_build/include --extra-ldflags=-L/home/dmarcos89/ffmpeg_build/lib --bindir=/usr/local/bin --pkg-config-flags=--static --enable-gpl --enable-nonfree --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265
libavutil 55. 5.100 / 55. 5.100
libavcodec 57. 13.102 / 57. 13.102
libavformat 57. 13.100 / 57. 13.100
libavdevice 57. 0.100 / 57. 0.100
libavfilter 6. 14.101 / 6. 14.101
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.100 / 2. 0.100
libpostproc 54. 0.100 / 54. 0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'http://filtremoscolombia.com/test/videos/placas/pfinal.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.13.100
Duration: 00:00:03.99, start: 0.021333, bitrate: 612 kb/s
Stream #0:0(eng): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 576 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 39 kb/s (default)
Metadata:
handler_name : SoundHandler

“中间”之一:
ffprobe version N-76417-gee20354 Copyright (c) 2007-2015 the FFmpeg developers
built with gcc 4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5)
configuration: --prefix=/home/dmarcos89/ffmpeg_build --extra-cflags=-I/home/dmarcos89/ffmpeg_build/include --extra-ldflags=-L/home/dmarcos89/ffmpeg_build/lib --bindir=/usr/local/bin --pkg-config-flags=--static --enable-gpl --enable-nonfree --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265
libavutil 55. 5.100 / 55. 5.100
libavcodec 57. 13.102 / 57. 13.102
libavformat 57. 13.100 / 57. 13.100
libavdevice 57. 0.100 / 57. 0.100
libavfilter 6. 14.101 / 6. 14.101
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.100 / 2. 0.100
libpostproc 54. 0.100 / 54. 0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'http://filtremoscolombia.com/test/upload/videos/vC6RvCf4pn.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.13.100
Duration: 00:00:16.90, start: 0.000000, bitrate: 1185 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 640x352 [SAR 1:1 DAR 20:11], 733 kb/s, 29.96 fps, 30 tbr, 15360 tbn, 60 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, 5.1, fltp, 447 kb/s (default)
Metadata:
handler_name : SoundHandler

结果如上:
ffprobe version N-76417-gee20354 Copyright (c) 2007-2015 the FFmpeg developers
built with gcc 4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5)
configuration: --prefix=/home/dmarcos89/ffmpeg_build --extra-cflags=-I/home/dmarcos89/ffmpeg_build/include --extra-ldflags=-L/home/dmarcos89/ffmpeg_build/lib --bindir=/usr/local/bin --pkg-config-flags=--static --enable-gpl --enable-nonfree --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265
libavutil 55. 5.100 / 55. 5.100
libavcodec 57. 13.102 / 57. 13.102
libavformat 57. 13.100 / 57. 13.100
libavdevice 57. 0.100 / 57. 0.100
libavfilter 6. 14.101 / 6. 14.101
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.100 / 2. 0.100
libpostproc 54. 0.100 / 54. 0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'http://filtremoscolombia.com/test/upload/videos/lYF00bMR2p.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.13.100
Duration: 00:00:24.05, start: 0.000000, bitrate: 2121 kb/s
Stream #0:0(eng): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 1793 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 327 kb/s (default)
Metadata:
handler_name : SoundHandler

这是视频本身: http://filtremoscolombia.com/test/upload/videos/lYF00bMR2p.mp4

音频没有很好地同步,而且音频比原始文件快...
任何帮助都会很棒

最佳答案

concat demuxer 使用第一个输入的时基,并且不会重新调整第二个和更多输入的 PTS。因此,由于输出音频时基为 1/48000,因此您的中间文件的音频(44.1 KHz)正在加速。

重新编码中间以匹配入口视频或入口和结束视频以匹配中间,然后运行 ​​concat。

如果重新编码中间:

ffmpeg -i vC6RvCf4pn.mp4 -crf 18 -vf scale=1280x720,setsar=1 -profile:v baseline -ar 48000 -strict -2 new-middle.mp4 

关于audio - ffmpeg 连接不同步音频的视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35397034/

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