LexManos
15th January 2011, 11:41
Alright So here is my situation, I have a few videos that I retardily used mencoder to encode into avi/x264/mp3.
Turns out my media player {the 360} doesn't support the 264/mp3 combo and I need to re-encode the audio into mp4/x264/aac.
So, instead of re-encoding the video, I figured i'd use MP4Box to extract the different tracks, re-encode the audio, and recombine.
I did that, and tried to play the file, and the audio was out of sync. Found out about the audio delay.
This is the MediaInfo (http://mediainfo.sourceforge.net/en/Download) of the original file:
General
Complete name : j:\Home071509.avi
Format : AVI
Format/Info : Audio Video Interleave
File size : 298 MiB
Duration : 44mn 15s
Overall bit rate : 941 Kbps
Writing application : MEncoder 1.0rc1-3.4.2
Writing library : MPlayer
Video
ID : 0
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High@L5.1
Format settings, CABAC : Yes
Format settings, ReFrames : 8 frames
Codec ID : h264
Duration : 44mn 15s
Bit rate : 736 Kbps
Width : 720 pixels
Height : 576 pixels
Display aspect ratio : 16:9
Frame rate : 23.976 fps
Standard : PAL
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.074
Stream size : 233 MiB (78%)
Writing library : x264 core 54
Encoding settings : cabac=1 / ref=5 / deblock=1:0:0 / analyse=0x3:0x133 / me=umh / subme=6 / br
do=0 / mixed_ref=0 / me_range=16 / chroma_me=1 / trellis=0 / 8x8dct=1 / cqm=0 / deadzone=21,11 / chroma_qp_off
set=0 / slices=1 / nr=0 / decimate=1 / mbaff=0 / bframes=3 / b_pyramid=1 / b_adapt=1 / b_bias=0 / direct=1 / w
predb=1 / bime=0 / keyint=250 / keyint_min=25 / scenecut=40 / rc=cqp / qp=26 / ip_ratio=1.40 / pb_ratio=1.30
Audio
ID : 1
Format : MPEG Audio
Format version : Version 1
Format profile : Layer 3
Mode : Joint stereo
Mode extension : MS Stereo
Codec ID : 55
Codec ID/Hint : MP3
Duration : 44mn 15s
Bit rate mode : Constant
Bit rate : 192 Kbps
Channel(s) : 2 channels
Sampling rate : 44.1 KHz
Compression mode : Lossy
Video delay : 83ms
Stream size : 60.8 MiB (20%)
Alignment : Aligned on interleaves
Interleave, duration : 26 ms (0.63 video frame)
Interleave, preload duration : 522 ms
Writing library : LAME3.96.1If you notice the 'Video Delay' is 83ms, which i'm guessing is the right delay as there are no others.
This is the command set I used:
mp4box -aviraw audio %1 -out c:\tmp\aud.mp3
mp4box -aviraw video %1 -out c:\tmp\vid.h264
start /wait audioconverter c:\tmp\aud_audio.mp3 c:\tmp\aud.aac -c aac
"c:\Program Files\MediaCoder\tools\mediainfo.exe" --inform=Audio;%%Delay%% %1 > c:\tmp\log.txt
set /p delay=<c:\tmp\log.txt
mp4box -add "c:\tmp\aud.aac" -add "c:\tmp\vid_video.h264" -delay 1=%delay% -new "%_file%.mp4"
Which results in this file:
General
Complete name : j:\Home071509.mp4
Format : MPEG-4
Format profile : Base Media
Codec ID : isom
File size : 276 MiB
Duration : 44mn 15s
Overall bit rate : 871 Kbps
Encoded date : UTC 2011-01-15 09:57:49
Tagged date : UTC 2011-01-15 09:57:49
Video
ID : 2
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High@L5.1
Format settings, CABAC : Yes
Format settings, ReFrames : 8 frames
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 44mn 8s
Bit rate mode : Variable
Bit rate : 738 Kbps
Maximum bit rate : 4 469 Kbps
Width : 720 pixels
Height : 576 pixels
Display aspect ratio : 16:9
Frame rate mode : Constant
Frame rate : 23.976 fps
Standard : PAL
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.074
Stream size : 233 MiB (85%)
Title : Imported with GPAC 0.4.6-DEV (internal rev. 8)
Encoded date : UTC 2011-01-15 09:57:52
Tagged date : UTC 2011-01-15 10:15:58
Audio
ID : 1
Format : AAC
Format/Info : Advanced Audio Codec
Format version : Version 4
Format profile : LC
Codec ID : 67
Duration : 44mn 15s
Bit rate mode : Variable
Bit rate : 132.3 Kbps
Maximum bit rate : 186 Kbps
Channel(s) : 2 channels
Channel positions : Front: L R
Sampling rate : 44.1 KHz
Compression mode : Lossy
Stream size : 41.4 MiB (15%)
Title : Imported with GPAC 0.4.6-DEV (internal rev. 8)
Encoded date : UTC 2011-01-15 09:57:49
Tagged date : UTC 2011-01-15 10:15:58
The MediaInfo doesn't say anything about a delay, the audio is still out of sync. And I really want to figure out a simple way to re-encode the audio without touching the video.
Also, Somehow according to MediaInfo, the video looses about 7 seconds... I don't know what that is about.
Turns out my media player {the 360} doesn't support the 264/mp3 combo and I need to re-encode the audio into mp4/x264/aac.
So, instead of re-encoding the video, I figured i'd use MP4Box to extract the different tracks, re-encode the audio, and recombine.
I did that, and tried to play the file, and the audio was out of sync. Found out about the audio delay.
This is the MediaInfo (http://mediainfo.sourceforge.net/en/Download) of the original file:
General
Complete name : j:\Home071509.avi
Format : AVI
Format/Info : Audio Video Interleave
File size : 298 MiB
Duration : 44mn 15s
Overall bit rate : 941 Kbps
Writing application : MEncoder 1.0rc1-3.4.2
Writing library : MPlayer
Video
ID : 0
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High@L5.1
Format settings, CABAC : Yes
Format settings, ReFrames : 8 frames
Codec ID : h264
Duration : 44mn 15s
Bit rate : 736 Kbps
Width : 720 pixels
Height : 576 pixels
Display aspect ratio : 16:9
Frame rate : 23.976 fps
Standard : PAL
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.074
Stream size : 233 MiB (78%)
Writing library : x264 core 54
Encoding settings : cabac=1 / ref=5 / deblock=1:0:0 / analyse=0x3:0x133 / me=umh / subme=6 / br
do=0 / mixed_ref=0 / me_range=16 / chroma_me=1 / trellis=0 / 8x8dct=1 / cqm=0 / deadzone=21,11 / chroma_qp_off
set=0 / slices=1 / nr=0 / decimate=1 / mbaff=0 / bframes=3 / b_pyramid=1 / b_adapt=1 / b_bias=0 / direct=1 / w
predb=1 / bime=0 / keyint=250 / keyint_min=25 / scenecut=40 / rc=cqp / qp=26 / ip_ratio=1.40 / pb_ratio=1.30
Audio
ID : 1
Format : MPEG Audio
Format version : Version 1
Format profile : Layer 3
Mode : Joint stereo
Mode extension : MS Stereo
Codec ID : 55
Codec ID/Hint : MP3
Duration : 44mn 15s
Bit rate mode : Constant
Bit rate : 192 Kbps
Channel(s) : 2 channels
Sampling rate : 44.1 KHz
Compression mode : Lossy
Video delay : 83ms
Stream size : 60.8 MiB (20%)
Alignment : Aligned on interleaves
Interleave, duration : 26 ms (0.63 video frame)
Interleave, preload duration : 522 ms
Writing library : LAME3.96.1If you notice the 'Video Delay' is 83ms, which i'm guessing is the right delay as there are no others.
This is the command set I used:
mp4box -aviraw audio %1 -out c:\tmp\aud.mp3
mp4box -aviraw video %1 -out c:\tmp\vid.h264
start /wait audioconverter c:\tmp\aud_audio.mp3 c:\tmp\aud.aac -c aac
"c:\Program Files\MediaCoder\tools\mediainfo.exe" --inform=Audio;%%Delay%% %1 > c:\tmp\log.txt
set /p delay=<c:\tmp\log.txt
mp4box -add "c:\tmp\aud.aac" -add "c:\tmp\vid_video.h264" -delay 1=%delay% -new "%_file%.mp4"
Which results in this file:
General
Complete name : j:\Home071509.mp4
Format : MPEG-4
Format profile : Base Media
Codec ID : isom
File size : 276 MiB
Duration : 44mn 15s
Overall bit rate : 871 Kbps
Encoded date : UTC 2011-01-15 09:57:49
Tagged date : UTC 2011-01-15 09:57:49
Video
ID : 2
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High@L5.1
Format settings, CABAC : Yes
Format settings, ReFrames : 8 frames
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 44mn 8s
Bit rate mode : Variable
Bit rate : 738 Kbps
Maximum bit rate : 4 469 Kbps
Width : 720 pixels
Height : 576 pixels
Display aspect ratio : 16:9
Frame rate mode : Constant
Frame rate : 23.976 fps
Standard : PAL
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.074
Stream size : 233 MiB (85%)
Title : Imported with GPAC 0.4.6-DEV (internal rev. 8)
Encoded date : UTC 2011-01-15 09:57:52
Tagged date : UTC 2011-01-15 10:15:58
Audio
ID : 1
Format : AAC
Format/Info : Advanced Audio Codec
Format version : Version 4
Format profile : LC
Codec ID : 67
Duration : 44mn 15s
Bit rate mode : Variable
Bit rate : 132.3 Kbps
Maximum bit rate : 186 Kbps
Channel(s) : 2 channels
Channel positions : Front: L R
Sampling rate : 44.1 KHz
Compression mode : Lossy
Stream size : 41.4 MiB (15%)
Title : Imported with GPAC 0.4.6-DEV (internal rev. 8)
Encoded date : UTC 2011-01-15 09:57:49
Tagged date : UTC 2011-01-15 10:15:58
The MediaInfo doesn't say anything about a delay, the audio is still out of sync. And I really want to figure out a simple way to re-encode the audio without touching the video.
Also, Somehow according to MediaInfo, the video looses about 7 seconds... I don't know what that is about.