Log in

View Full Version : mp4 muxing shortened time of video?


Songoo
16th February 2009, 23:32
I get this shortening problems only with some videos others are all right.

I tried mkv2vob, mp4muxer and mp4box , all the same .
After muxing with same fps to mp4 video is from 23mn 35s duration changed to 21mn 42s (same time with all 3programs, when add sound that have same lenght as source = desinchronised A/V).


Exact example using mp4box :

Command :
MP4Box -fps 29.970 -add RawTrack1.h264 -flat -new outfile.mp4

Media info from source (media info): (mkv)
Format : Matroska
File size : 339 MiB
Duration : 23mn 36s
Overall bit rate : 2 009 Kbps
Encoded date : UTC 2006-12-26 19:50:17
Writing application : mkvmerge v1.7.0 ('What Do You Take Me For') built on Apr 28 2006 17:20:19
Writing library : libebml v0.7.7 + libmatroska v0.8.0
Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High@L5.1
Format settings, CABAC : Yes
Format settings, ReFrames : 8 frames
Muxing mode : Container profile=Unknown@5.1
Codec ID : V_MPEG4/ISO/AVC
Duration : 23mn 35s
Bit rate : 1 245 Kbps
Nominal bit rate : 1 446 Kbps
Width : 640 pixels
Height : 480 pixels
Display aspect ratio : 4/3
Frame rate : 29.970 fps
Resolution : 24 bits
Colorimetry : 4:2:0
Scan type : Progressive
Bits/(Pixel*Frame) : 0.135
Writing library : x264 core 54 svn-614M
Encoding settings : cabac=1 / ref=5 / deblock=1:-1:-1 / analyse=0x3:0x133 / me=umh / subme=6 / brdo=1 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=1 / cqm=0 / deadzone=21,11 / chroma_qp_offset=0 / threads=1 / nr=0 / decimate=1 / mbaff=0 / bframes=2 / b_pyramid=1 / b_adapt=1 / b_bias=0 / direct=2 / wpredb=1 / bime=1 / keyint=250 / keyint_min=25 / scenecut=40 / rc=2pass / bitrate=1446 / ratetol=1.0 / rceq='blurCplx^(1-qComp)' / qcomp=0.60 / qpmin=10 / qpmax=51 / qpstep=4 / cplxblur=20.0 / qblur=0.5 / ip_ratio=1.40 / pb_ratio=1.30

Media info from newmade mp4(with mp4box)(mp4) :

Format : MPEG-4
Format profile : Base Media
Codec ID : isom
File size : 225 MiB
Duration : 21mn 42s
Overall bit rate : 1 449 Kbps
Encoded date : UTC 2009-02-15 19:54:19
Tagged date : UTC 2009-02-15 19:54:19
Video
ID : 1
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 : 21mn 42s
Bit rate mode : Variable
Bit rate : 1 446 Kbps
Maximum bit rate : 5 655 Kbps
Width : 640 pixels
Height : 480 pixels
Display aspect ratio : 4/3
Frame rate mode : Constant
Frame rate : 29.970 fps
Resolution : 24 bits
Colorimetry : 4:2:0
Scan type : Progressive
Bits/(Pixel*Frame) : 0.157
Stream size : 224 MiB (100%)
Writing library : x264 core 54 svn-614M
Encoding settings : cabac=1 / ref=5 / deblock=1:-1:-1 / analyse=0x3:0x133 / me=umh / subme=6 / brdo=1 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=1 / cqm=0 / deadzone=21,11 / chroma_qp_offset=0 / threads=1 / nr=0 / decimate=1 / mbaff=0 / bframes=2 / b_pyramid=1 / b_adapt=1 / b_bias=0 / direct=2 / wpredb=1 / bime=1 / keyint=250 / keyint_min=25 / scenecut=40 / rc=2pass / bitrate=1446 / ratetol=1.0 / rceq='blurCplx^(1-qComp)' / qcomp=0.60 / qpmin=10 / qpmax=51 / qpstep=4 / cplxblur=20.0 / qblur=0.5 / ip_ratio=1.40 / pb_ratio=1.30
Encoded date : UTC 2009-02-15 19:54:19
Tagged date : UTC 2009-02-15 19:55:20


Please help .

Kurtnoise
17th February 2009, 08:39
maybe your matroska file is vfr...

SamLowry
17th February 2009, 08:58
If original MKV is a result of concatenation of several parts, most probably there are small gaps in the video stream. When you extract the video stream from matroska, the resulting elementary stream may be shorter.
If this is the case, I can't think of reasonable procedure to get accurate result when extracting from MKV and muxing.

Why are you trying to convert your video from MKV to MP4?


And something more: Get latest mkvfinfo. Get grep (http://www.interlog.com/~tcharron/grep.html) command. Try:

mkvinfo -v original.mkv | grep "track number 1, 1 frame"

This will get you the timecode of each video frame. If timecodes are smoothly (linearly) increasing all along the movie - there are no gaps. Otherwise your video is most likely to be result of concatenation.

SeeMoreDigital
17th February 2009, 10:28
It might be easier for Songoo to re-encode from his original source directly to the .MP4 container....

Songoo
17th February 2009, 10:32
+ Block (track number 1, 1 frame(s), timecode 1415.883s = 00:23:35.883000000)

+ Block (track number 1, 1 frame(s), timecode 1415.916s = 00:23:35.916000000)

+ Block (track number 1, 1 frame(s), timecode 1415.999s = 00:23:35.999000000)

+ Block (track number 1, 1 frame(s), timecode 1415.958s = 00:23:35.958000000)

+ Block (track number 1, 1 frame(s), timecode 1416.041s = 00:23:36.041000000)

+ Block (track number 1, 1 frame(s), timecode 1416.083s = 00:23:36.083000000)

+ Block (track number 1, 1 frame(s), timecode 1416.124s = 00:23:36.124000000)

+ Block (track number 1, 1 frame(s), timecode 1416.166s = 00:23:36.166000000)

+ Block (track number 1, 1 frame(s), timecode 1416.208s = 00:23:36.208000000)

+ Block (track number 1, 1 frame(s), timecode 1416.250s = 00:23:36.250000000)

+ Block (track number 1, 1 frame(s), timecode 1416.333s = 00:23:36.333000000)

+ Block (track number 1, 1 frame(s), timecode 1416.291s = 00:23:36.291000000)

+ Block (track number 1, 1 frame(s), timecode 1416.375s = 00:23:36.375000000)

+ Block (track number 1, 1 frame(s), timecode 1416.416s = 00:23:36.416000000)

+ Block (track number 1, 1 frame(s), timecode 1416.458s = 00:23:36.458000000)

+ Block (track number 1, 1 frame(s), timecode 1416.500s = 00:23:36.500000000)

+ Block (track number 1, 1 frame(s), timecode 1416.542s = 00:23:36.542000000)

+ Block (track number 1, 1 frame(s), timecode 1416.583s = 00:23:36.583000000)


Most of people need mp4 to play videos from mkv to ps3, i need them since mp4 is streamable format and mkv is not . (using vlc for streaming, with mp4 no transcoding needed)

SamLowry
17th February 2009, 13:58
Can you check the total number of video frames? VirtualDubMod can report it.
Open the original mkv file in virtualdubmod (ignore all warnings about frame order or missing video decompressor).
Then select File -> File Information. There you can get the total number of frames. So, how many video frames do you have in the problematic mkv?

SeeMoreDigital
17th February 2009, 18:01
Most of people need mp4 to play videos from mkv to ps3, i need them since mp4 is streamable format and mkv is not . (using vlc for streaming, with mp4 no transcoding needed)As I suggested before.... re-encode from your original source directly to the .MP4 container.

Given that your source has a run-time of less than half an hour, you could have re-encoded it by now!

Songoo
17th February 2009, 23:18
Tnx Kurtnoise.
Vfr was the right direction, at the beginning i even didnt know what it mean :D .

MkvExtractgui(mkvtoolnix)-dragged mkv- options/tabs/timecode-selected video-extractet- got .h264 + TimeCode_Track1.txt(with video variable timecodes)***MP4box.exe make from
.h264 to mp4 (-flat,and without sound, with fps from mkvinfo.exe(mkvtoolnix))**** tc2mp4(need in its florder mp4box) will join that cfr mp4 with timecodes txt to vfr mp4,
Afther that the mp4 have right time duration, one last step mp4box and add sound.

Succesfuly tested, tnx for help.

ps :
SeeMoreDigital : i will need to mux about 200 files (maybe more, who knows :D),so encoding its not option :( , mainly since it cause quallity loos and i dont have right knowledge to start with this :/

SeeMoreDigital
17th February 2009, 23:38
SeeMoreDigital : i will need to mux about 200 hundred files (maybe more, who knows :D),so encoding its not option :( , mainly since it cause quallity loos and i dont have right knowledge to start with this :/So where did you get these files from then?

Songoo
18th February 2009, 01:36
SamLowry: virtual dub couldnt open this videos at all, some error with subtitles .

setarip_old
18th February 2009, 03:36
Hi!I get this shortening problems only with some videos others are all right.i will need to mux about 200 files (maybe more, who knows )

1) Which is it, "some" or "about 200 files (maybe more)? How/why would you create so many problematic files?

2) What software and procedures did you use to create your original non-problematic files?

3) What software and procedures did you use to create your original problematic files?

Songoo
18th February 2009, 11:17
Hi!

1) Which is it, "some" or "about 200 files (maybe more)? How/why would you create so many problematic files?

2) What software and procedures did you use to create your original non-problematic files?

3) What software and procedures did you use to create your original problematic files?


-Most of them mkv(h264 or xvid), problematic was vfr
-need mp4 for vlc streaming (since mp4 is standard streamable format, mkv have problems)
-mp4box, but as i wrote in upper post, problem is solved,i just didnt know enough about vfr(shame on me X_x), but thnx for your time anyway.

SeeMoreDigital
18th February 2009, 16:02
SeeMoreDigital : I dont think that this is forum for this type of questions, i can answer you in private message if you want.

2.
-I didnt create them
Asking for help for files you did not create yourself is a viotation of this forums rules!

Songoo
18th February 2009, 18:33
maybe will be usefull to somebody :
Vfr mkv to Vfr mp4 :

Example video : examplevideo.mkv

Run MkvExtractgui.exe(v1.6.4.1, mkvtoolnix), drag examplevideo.mkv to it ,
in MkvExtractgui select options/tabs/timecode,
in MkvExtractgui in content window check a box which is located next to video track(mainly track ID 1(mpg4,h264 and so) ),
click extract, you ll get examplevideo_Track1.h264 and TimeCode_Track1.txt(its txt with video variable timecodes).
(*with MkvExtractgui you can get all parts of mkv like audio tracks and subtitles extracted)

So we have examplevideo_Track1.h264 and TimeCode_Track1.txt,
Mux examplevideo_Track1.h264 with MP4box.exe to mp4 with constant frame rate.
(I used mkvinfo(mkvtoolnix) to find out fps of mkv video [**in totalcomander go to MKVtoolnix florder ,use "cmd" command in totalcmd command line (at bottom), or just (xp) start/run/cmd and use cd "targetflorder"(TAB can help) or cd .., anyway in cmd i used command "mkvinfo E:\Anime\mp4\examplevideo.mkv" to get
detailed informations and mainly fps,in our case 29.970 .
Or simply use mediainfo program.)

Mux examplevideo_Track1.h264 with MP4box.exe with command(**) :
MP4Box -fps 29.970 -add E:\videos\examplevideo_Track1.h264 -flat -new cfrexamplevideo.mp4

cfrexamplevideo.mp4 have shortened time duration because it have constant frame rate .

Use tc2mp4 (**)(there is needed to add mp4box files to its florder) to join cfrexamplevideo.mp4 with TimeCode_Track1.txt :
tc2mp4 -i E:\videos\mp4\cfrexamplevideo.mp4 -t E:\videos\mp4\TimeCode_Track1.txt -o vfrexamplevideo.mp4

We get vfrexamplevideo.mp4, which have right time duration(same as source).
last step use mp4box(**) and add audio track:
MP4Box -fps 23.970 -add E:\video\sound\examplevideo_track2.mp4#ID=2 -flat vfrexamplevideo.mp4
(there doestnt matter on fps value while adding audio , just gave it same as video.
This will add audio to video and all is sync well, in source video i had uncompatible audio format i used BeLight(BeSweet)
to change it to acc muxed in (mp4examplevideo_track2.mp4), .acc or .mp3 should work without problems too)

SeeMoreDigital
18th February 2009, 18:51
I misspeled.
I created them .

SeeMoreDigital :Find other hobby ..I have requested that this thread is closed.

Songoo. Please follow our forum rules or "find another forum".

avih
18th February 2009, 19:16
Thread closed. Rule 6 violation.