Search code examples
windowsffmpegx264mp4box

Why the audio of my mp4 file is going out of async


I am having a problem converting a wmv file to mp4. I am using x264.exe this command to get the video stream

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

Then I use ffmpeg.exe to extract the audio stream with this line:

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

finally I use MP4Box to merges each stream with this line:

MP4Box -add temporal.264 Final.mp4 MP4Box -add temporal.aac Final.mp4

The problem is that the final.mp4 audio is out of sync. It starts good but with time it goes out of sync with time.

I run this command:

MP4Box -info 010004470063PE-10022017083824-2_MultiMedia--1.mp4

and I discover that the estimated time of both streams are different:

output of command

* 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

I am not shore why this is happening, becar the original wmv is perfectly synchronize. Any help?


Solution

  • Base on the response of Gyan I use ffmpeg to transcode the wmv file to an mp4, separating the audio and video sequences was a bad idea. At the end I use the following command for transcoding:

    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