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

时间:2018-06-29 20:18:40

标签: 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可以完美同步。有帮助吗?

2 个答案:

答案 0 :(得分:0)

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

您有两种解决方法:

a)提取到定时样品容器中

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

答案 1 :(得分:0)

基于Gyan的响应,我使用ffmpeg将wmv文件转码为mp4,分离​​音频和视频序列是一个坏主意。最后,我使用以下命令进行转码:

ffmpeg -i <input>.wmv -c:v libx264 -preset slow -crf 23 -c:a aac -r 25 -b:a 48k -strict -2 -max_muxing_queue_size 4000 <output>.mp4