Log in

View Full Version : MP4 (mp4v vfr) to MP4 H264 Variable Framerate (vfr)


asbonasty
8th February 2010, 16:03
Hey,

Ive been trying to get an MP4/mp4v that has a variable frame rate converted to an mp4/h264 with a variable frame rate. Simple enough I thought.....

Using mediainfo (on linux) I can see that my source mp4 has a variable frame rate.

---snip 8<---
Frame rate mode : Variable
Frame rate : 28.152 fps
Minimum frame rate : 14.706 fps
Maximum frame rate : 57.692 fps
---snip 8<---

So using MP4Box I extracted the nhml...heres a sample from the top of the file.

---snip 8<---
<?xml version="1.0" encoding="UTF-8" ?>
<NHNTStream version="1.0" timeScale="30000" streamType="4" objectTypeIndication="32" specificInfoFile="n97-mini_track1.info" width="640" height="480" trackID="1" baseMediaFile="n97-mini_track1.media" >
<NHNTSample DTS="0" dataLength="21156" isRAP="yes" />
<NHNTSample DTS="520" dataLength="14410" />
<NHNTSample DTS="1040" dataLength="18135" />
<NHNTSample DTS="1560" dataLength="15857" />
<NHNTSample DTS="2580" dataLength="19907" />
<NHNTSample DTS="3570" dataLength="15480" />
<NHNTSample DTS="4590" dataLength="15733" />
<NHNTSample DTS="5610" dataLength="16543" />
<NHNTSample DTS="6630" dataLength="15778" />
<NHNTSample DTS="7650" dataLength="15599" />
<NHNTSample DTS="8670" dataLength="15866" />
<NHNTSample DTS="9690" dataLength="16246" />
---snip 8<---

As you can see there are no CTS offsets and there are none in the rest of the file.

I did the usual process of extracting audio and video, transcoded the video and then created a new mp4, added the nhml and video.

..create the mp4
/usr/local/bin/MP4Box -add n97-mini_track1.nhml -new test.mp4

..add the tracks
/usr/local/bin/MP4Box -add out.264 -add audio.m4a test.mp4

...and I get horrible out of sync video. mediainfo reports the video as having a fixed video frame rate.

--- snip 8<---
Frame rate mode : Constant
Frame rate : 30.000 fps
Original frame rate : 100.000 fps
--- snip 8<---

If I apply the ntml **after** adding the video I do get CTS values in my nhml, but again the video is out of sync and media info still reports the video of having a fixed frame rate.

Can anyone put any light onto this situation as Ive run out of things to try.

If Ive missed anything out that might help please just ask and Ill provide whatever is needed.

I can also provide the video if needed.

Cheers,
Tom

Guest
8th February 2010, 16:41
If Ive missed anything out that might help please just ask and Ill provide whatever is needed. What is the content and where did you get it?

asbonasty
8th February 2010, 16:44
What is the content and where did you get it?

I have several source files. They are filmed using Nokia n900's and also N97 minis. I took some sample footage to do some testing with.

EDIT: the content is me going round the office annoying people :)

Cheers,
Tom

b66pak
8th February 2010, 16:54
if you have windows machine on hand you can deal with your situation very easy with these special x264 build:

Direct264 - special x264 CLI build that supports input from DirectShow

http://forum.doom9.org/showthread.php?t=141441
_

asbonasty
8th February 2010, 17:01
Thanks for the info. Ive just tried getting the timecodes out of my source mp4 using dtsedit, and then setting the timecodes back using dtsedit to me target mp4. It works (under windows).

Unfortunately the workflow requires I use tools on linux, so I need a method of extracting the timecodes under linux. I could then use tc2mp4 and mp4box.

Thanks for the reply..I should have mentioned this to begin with.

Cheers,
Tom

roozhou
8th February 2010, 17:20
Try ffmpeg.

asbonasty
9th February 2010, 10:46
Try ffmpeg.

Thanks for the reply but thats as useful as "use a computer" :)

ffmpeg doesnt allow me to extract the timecodes I need. FFMpegsource does...but this isnt any use to me.

Or does it?

Im currently using wine and dtsedit to do what I need. This is not ideal. MP4Box should really be able to generate an nhml from a file and then reuse its own content. If it can already then Id love to know what Im doing wrong.

Anyone else??

Cheers,
Tom

Ritsuka
9th February 2010, 14:05
Can't you transcode it directly? HandBrake, x264, QuickTime and many others can work directly with your vfr file.

Selur
10th February 2010, 14:50
Problem isn't the vfr input it's the vfr output,...

Aktan
11th March 2010, 20:14
This is quite late, but you're transcoding to H.264 with what, x264? I've written a java utility that converts a NHML to VFR with MKV v2 timecodes, but using NHML DTS times could work also especially since there is no CTS offsets. I could quickly modify it to do this, if you're still interested and could give me 2 sample NHML files. One the original source NHML and the other the new NHML from the transcoded file. I've only worked with modifying NHML files from x264 encode, hence why I asked how you are transcoding.

Aktan
11th March 2010, 20:32
A couple of more details. Since your source NHML didn't have any offsets, basically the source had no B-frames. Since you transcoded to H.264, I assumed you used a transcoder that does use B-frames, thus requiring CTS offsets and also making the source NHML invalid. So I guess a workaround is to transcode to H.264 without B-frames.

asbonasty
14th May 2010, 09:55
An even later response but I really apprecaite the reply :)

Ok I use mencoder to encode the video stream. Im no expert with all this to CTS offsets etc doesnt really mean that much to me so please be gentle :)

What exactly do I need to do?

Cheers,
Tom

Aktan
17th May 2010, 19:55
Sorry for the late response as somehow the notification of a message posted in this thread was counted as spam. Well I need a sample files. Maybe a sample source NHML and the final encode MP4 that needs to have it applied.