Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
23rd November 2005, 11:13 | #1 | Link |
Registered User
Join Date: May 2005
Posts: 55
|
Help with concatenating avc into mp4...
So I'm trying to concatenate two clips I encoded with the exact same settings in x264... but mp4box keeps saying they're incompatible and making a seperate stream for them.
Here are (representative) clips of the RAW 264 output from x264. www.arienai.com/Clipped.264 www.arienai.com/Clipped2.264 they were made with this command line: "x264.exe" --pass 1 --qp 22 --stats ".stats" --ref 1 --bframes 1 --filter 0:0 --subme 4 --analyse all --8x8dct --qcomp 0.9 --me dia --verbose --progress --no-psnr --output "E:\Anime\New Series\Sugar Sugar Rune\Fansub\01\Final Build\Clipped.264" "E:\Anime\New Series\Sugar Sugar Rune\Fansub\01\Final Build\dvdavs.avs" "x264.exe" --pass 1 --qp 22 --stats ".stats" --ref 1 --bframes 1 --filter 0:0 --subme 4 --analyse all --8x8dct --qcomp 0.9 --me dia --verbose --progress --no-psnr --output "E:\Anime\New Series\Sugar Sugar Rune\Fansub\01\Final Build\Clipped2.264" "E:\Anime\New Series\Sugar Sugar Rune\Fansub\01\Final Build\dvdavsending.avs" Now, when I type mp4box -cat Clipped.264 -cat Clipped2.264 -new out.mp4 all I get is an mp4 with two seperate video streams. I traced it back in the source code to a call to "gf_isom_is_same_sample_description" returning 0... but as far as I can tell the two video tracks should be compatible, no? Thanks for any help... |
23rd November 2005, 17:37 | #2 | Link |
x264 developer
Join Date: Sep 2004
Posts: 2,392
|
They have different fps. MP4Box ignores the fps for the purpose of determining frames' timestamps, but it still means that the SPS headers are not bitwise identical.
Simplest way I can fix it: mux each to mp4, then append them in mkvmerge. |
23rd November 2005, 18:36 | #3 | Link | |
Registered User
Join Date: Nov 2001
Posts: 9,770
|
Quote:
or do you want a vfr stream?
__________________
Between the weak and the strong one it is the freedom which oppresses and the law that liberates (Jean Jacques Rousseau) I know, that I know nothing (Socrates) MPEG-4 ASP FAQ | AVC/H.264 FAQ | AAC FAQ | MP4 FAQ | MP4Menu stores DVD Menus in MP4 (guide) Ogg Theora | Ogg Vorbis use WM9 today and get Micro$oft controlling the A/V market tomorrow for free |
|
23rd November 2005, 22:46 | #4 | Link |
Registered User
Join Date: May 2005
Posts: 55
|
Hmmm... I thought I tried specifically to make them the same fps...
Does using assumefps in the avisynth script not sufficient to really change the framerate information in the outputted raw video? And yes, my goal was to create a vfr mp4.... My source was a hybrid dvd, and I really wanted to have the ending in 29.97. Also, I already tried muxing them into mp4's with the same fps and THEN trying to concatenate, but it didn't help. Last edited by Quarkboy; 23rd November 2005 at 22:49. |
23rd November 2005, 23:08 | #5 | Link |
Registered User
Join Date: Nov 2001
Posts: 9,770
|
propably mp4box doesnt handle creating vfr that way
__________________
Between the weak and the strong one it is the freedom which oppresses and the law that liberates (Jean Jacques Rousseau) I know, that I know nothing (Socrates) MPEG-4 ASP FAQ | AVC/H.264 FAQ | AAC FAQ | MP4 FAQ | MP4Menu stores DVD Menus in MP4 (guide) Ogg Theora | Ogg Vorbis use WM9 today and get Micro$oft controlling the A/V market tomorrow for free |
23rd November 2005, 23:54 | #6 | Link | |
Registered User
Join Date: May 2005
Posts: 55
|
Quote:
then mux the same clip to a 29.97 mp4 (using the -fps command), then concat them together, it works, and produces a vfr mp4.... So why doesn't it work with the two clips? arg, I've tried almost everything.... |
|
24th November 2005, 00:28 | #7 | Link | |
Registered User
Join Date: Nov 2001
Posts: 9,770
|
Quote:
what clips are you muxing and getting vfr? clip1_23.976fps.mp4 + clip1_29.97fps.mp4?
__________________
Between the weak and the strong one it is the freedom which oppresses and the law that liberates (Jean Jacques Rousseau) I know, that I know nothing (Socrates) MPEG-4 ASP FAQ | AVC/H.264 FAQ | AAC FAQ | MP4 FAQ | MP4Menu stores DVD Menus in MP4 (guide) Ogg Theora | Ogg Vorbis use WM9 today and get Micro$oft controlling the A/V market tomorrow for free |
|
24th November 2005, 01:10 | #8 | Link | |
Registered User
Join Date: May 2005
Posts: 55
|
Quote:
specifically: mp4box -add Clipped.264 -fps 23.976 -new test1.mp4 mp4box -add Clipped.264 -fps 29.97 -new test2.mp4 mp4box -cat test1.mp4 -cat test2.mp4 -new vfwClip.mp4 That works fine... but switch the second clip to Clipped2 and it won't concatenate... I've traced the problem to my call to "Tdecimate(mode=1...)" in the avisynth... In one of the clips I call it and in the other I don't. However, in the one which I don't call tdecimate I call "Assumefps(24000,1001)"... so both clips SHOULD have the same fps, right? Is it maybe some decimal rounding thing that I don't see at higher order? |
|
24th November 2005, 01:33 | #9 | Link |
Registered User
Join Date: Nov 2001
Posts: 9,770
|
i guess the thing is that akupenguin's point is still valid even after you import the raw stream to .mp4 with a different fps than the original one
try extracting the avc stream to raw again from the .mp4 file which has the fps set differently to the one of Clipped.264 and run the "h264_parse.exe" tool from mpeg4ip over it if the SPS still says the original framerate you know that this is the reason why mp4box doesnt let you combine the two streams, as the SPS are not identical if thats the case you can try to make a bug report at gpac's sourceforge bug tracker and tell the devs that they should ignore the fps signalled in the SPS when doing cat
__________________
Between the weak and the strong one it is the freedom which oppresses and the law that liberates (Jean Jacques Rousseau) I know, that I know nothing (Socrates) MPEG-4 ASP FAQ | AVC/H.264 FAQ | AAC FAQ | MP4 FAQ | MP4Menu stores DVD Menus in MP4 (guide) Ogg Theora | Ogg Vorbis use WM9 today and get Micro$oft controlling the A/V market tomorrow for free |
24th November 2005, 02:56 | #10 | Link |
Registered User
Join Date: May 2005
Posts: 55
|
aha!!! got it to work...
It WAS a decimal appromation problem. Using your suggestion of h264_parse (which I didn't know about...), I realized that assumefps(23.976) wasn't correct, because the numerator/denominator it sets were somewhat implementation dependent. I had to use "assumefpd(2997,125)" specifically (or assumefps(2997,100) on the other clip. Then overrideing the fps when making the mp4 and concatinating makes the vfr mp4! Phew. Well, everyone can look forward to the very first vfr mp4 fansubbed anime episode ever released now . I had tried assumefps(24000,1001) before... but it seems that was TOO accurate Last edited by Quarkboy; 24th November 2005 at 07:39. |
26th November 2005, 17:24 | #11 | Link |
Registered User
Join Date: Nov 2001
Posts: 9,770
|
beaware that there seems to be a bug in using -cat on streams with different fps i described here
__________________
Between the weak and the strong one it is the freedom which oppresses and the law that liberates (Jean Jacques Rousseau) I know, that I know nothing (Socrates) MPEG-4 ASP FAQ | AVC/H.264 FAQ | AAC FAQ | MP4 FAQ | MP4Menu stores DVD Menus in MP4 (guide) Ogg Theora | Ogg Vorbis use WM9 today and get Micro$oft controlling the A/V market tomorrow for free |
26th November 2005, 21:00 | #12 | Link | |
Registered User
Join Date: May 2005
Posts: 55
|
Quote:
In any case, neither of the things you point out would affect playback or synch, I bet. They maybe just aren't exactly what you expect the behavior to be. |
|
27th November 2005, 04:37 | #13 | Link |
Registered User
Join Date: Nov 2001
Posts: 9,770
|
stts defines how long a frame should be shown, if its not correct frames will show with wrong lengths causing desync
__________________
Between the weak and the strong one it is the freedom which oppresses and the law that liberates (Jean Jacques Rousseau) I know, that I know nothing (Socrates) MPEG-4 ASP FAQ | AVC/H.264 FAQ | AAC FAQ | MP4 FAQ | MP4Menu stores DVD Menus in MP4 (guide) Ogg Theora | Ogg Vorbis use WM9 today and get Micro$oft controlling the A/V market tomorrow for free |
27th November 2005, 04:43 | #14 | Link | |
Registered User
Join Date: May 2005
Posts: 55
|
Quote:
the output stts looks like this: entryCount = 141 (0x0000008d) sampleCount = 211 (0x000000d3) sampleDelta = 1000 (0x000003e8) sampleCount[1] = 3 (0x00000003) sampleDelta[1] = 833 (0x00000341) sampleCount[2] = 1 (0x00000001) sampleDelta[2] = 834 (0x00000342) sampleCount[3] = 2 (0x00000002) sampleDelta[3] = 833 (0x00000341) sampleCount[4] = 1 (0x00000001) sampleDelta[4] = 834 (0x00000342) sampleCount[5] = 2 (0x00000002) sampleDelta[5] = 833 (0x00000341) the first clip was 25.00 fps, and the second half was 30 fps, correct? so the first 211 frames are shown for "1000" somethings each, what should the delta be for the concatenated part? Well, clearly 1000*25/30= 833.3333333 But the delta can't be non-integer, so to approximate the frame rate as best as possible, mp4box alternates 833 for two frames, 834 for one frame, back and forth. That seems like logical behavior to me. The final frame is wrong though, you're right about that. |
|
27th November 2005, 04:54 | #15 | Link |
Registered User
Join Date: Nov 2001
Posts: 9,770
|
yeah its propably as you say, but maybe its possible to not need this somewhat "dirty approximitation", eg the 30fps sample alone also doesnt have these strange values
__________________
Between the weak and the strong one it is the freedom which oppresses and the law that liberates (Jean Jacques Rousseau) I know, that I know nothing (Socrates) MPEG-4 ASP FAQ | AVC/H.264 FAQ | AAC FAQ | MP4 FAQ | MP4Menu stores DVD Menus in MP4 (guide) Ogg Theora | Ogg Vorbis use WM9 today and get Micro$oft controlling the A/V market tomorrow for free |
27th November 2005, 05:00 | #16 | Link |
Registered User
Join Date: May 2005
Posts: 55
|
Well, the other way of doing it is to raise the delta for the first clip...
i.e. if the frame rate is 25000/1000, raise it to 25000000/1000000 Then you could use 833333 as the delta for the seconds part, and ther wouldn't be any desynching unless the movie was....more than 10,000 frames long But the problem with this way of doing things is that it slowly, over time, becomes more innaccurate. The alternting approach causes imperceptable desynching every frame (1 frame is too slow, the next 2 too fast) but no OVERALL desynching. I'm pretty sure there is no other way around this problem... The real problem is, when trying to cat two ARBITRARY frame rate mp4's, then you can easily run into problems. |
3rd December 2005, 22:17 | #17 | Link |
Registered User
Join Date: Nov 2001
Posts: 9,770
|
the time of the last frame is fixed now in cvs
so its now absolutely save to use the -cat function for creating vfr mp4 files
__________________
Between the weak and the strong one it is the freedom which oppresses and the law that liberates (Jean Jacques Rousseau) I know, that I know nothing (Socrates) MPEG-4 ASP FAQ | AVC/H.264 FAQ | AAC FAQ | MP4 FAQ | MP4Menu stores DVD Menus in MP4 (guide) Ogg Theora | Ogg Vorbis use WM9 today and get Micro$oft controlling the A/V market tomorrow for free |
Thread Tools | Search this Thread |
Display Modes | |
|
|