windows - 为什么我的 mp4 文件的音频不同步

标签 windows ffmpeg x264 mp4box

我在将 wmv 文件转换为 mp4 时遇到问题。我正在使用 x264.exe 这个命令来获取视频流
x264 --output temporal.264 --fps 25 --preset slow --bitrate 2048 --vbv-maxrate 2048 --vbv-bufsize 9600 --min-keyint 48 --keyint 48 --scenecut 0 --no-scenecut --pass 1 --video-filter "resize:width=640,height=480" Original.wmv
然后我使用 ffmpeg.exe 用这一行提取音频流:
ffmpeg -i .wmv -acodec libfdk_aac -b:a 32000 temporal.aac
最后我使用 MP4Box 将每个流与这一行合并:
MP4Box -add temporal.264 Final.mp4 MP4Box -add temporal.aac Final.mp4
问题是 final.mp4 音频不同步。它开始很好,但随着时间的推移,它与时间不同步。

我运行这个命令:
MP4Box -info 010004470063PE-10022017083824-2_MultiMedia--1.mp4
我发现两个流的估计时间不同:

命令的输出
* Movie Info * Timescale 600 - 2 tracks Computed Duration 01:00:03.643 - Indicated Duration 01:00:03.643 Fragmented File: no File suitable for progressive download (moov before mdat) File Brand isom - version 1 Compatible brands: isom avc1 Created: GMT Wed Jun 27 16:31:44 2018 Modified: GMT Wed Jun 27 16:31:44 2018 File has root IOD (9 bytes) Scene PL 0xff - Graphics PL 0xff - OD PL 0xff Visual PL: AVC/H264 Profile (0x7f) Audio PL: AAC Profile @ Level 2 (0x29) No streams included in root OD Track # 1 Info - TrackID 1 - TimeScale 25000 Media Duration 00:59:57.520 - Indicated Duration 00:59:57.520 Track has 1 edit lists: track duration is 00:59:57.320 Media Info: Language "Undetermined (und)" - Type "vide:avc1" - 89938 samples Visual Track layout: x=0 y=0 width=640 height=480 MPEG-4 Config: Visual Stream - ObjectTypeIndication 0x21 AVC/H264 Video - Visual Size 640 x 480 AVC Info: 1 SPS - 1 PPS - Profile Main @ Level 3 NAL Unit length bits: 32 Chroma format YUV 4:2:0 - Luma bit depth 8 - chroma bit depth 8 SPS#1 hash: 41EE779BEF2AA71A7131EAFD3C77C7E3BC95FD8E PPS#1 hash: 086E1D72A40A0E8CF35D102F34A9DF6CD44D6CEF Self-synchronized RFC6381 Codec Parameters: avc1.4D401E Average GOP length: 250 samples Track # 2 Info - TrackID 2 - TimeScale 44100 Media Duration 01:00:03.644 - Indicated Duration 01:00:03.644 Media Info: Language "Undetermined (und)" - Type "soun:mp4a" - 155196 samples MPEG-4 Config: Audio Stream - ObjectTypeIndication 0x40 MPEG-4 Audio AAC LC - 2 Channel(s) - SampleRate 44100 Synchronized on stream 1 RFC6381 Codec Parameters: mp4a.40.2 All samples are sync
我不支持为什么会发生这种情况,因为原始的 wmv 是完全同步的。有什么帮助吗?

最佳答案

.aac是一个没有时间戳的原始容器,如果源音频中存在 PTS 间隙,它们将丢失。

您有两种解决方法:

a) 提取到定时 sample 容器

ffmpeg -i .wmv -acodec libfdk_aac -b:a 32000 -vn temporal.m4a

b) 填补空白并提取
ffmpeg -i .wmv -af aresample=async=1 -acodec libfdk_aac -b:a 32000 temporal.aac

关于windows - 为什么我的 mp4 文件的音频不同步,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51108865/

相关文章:

windows - 如何让 grep 在 Windows 上的 Emacs 中工作 (EmacsW32)

c++ - fwrite 4 字符数组,将写入 7 而不是 4

无法恢复最小化窗口

audio - 为什么我不能用 ffmpeg 重新排序我的 mpg 容器中的流?

php - 我可以从 PHP 调用多核 LAMP 机器上的多个 FFMPEG 进程吗?

ffmpeg - 使用 av_interleaved_write_frame 而不是 avio_write 时为 "moov atom not found"

macos - 在 Mac OS X 上编译 x264 时出错

linux - 从 Windows Web 服务获取 Linux 服务器硬件信息

python - 如何使用 FFMPEG 驱动程序使 opencv 工作

audio - 使用 FFMPEG 对视频进行音量调整和 channel 合并