3

I have a MP4 parser software that get's a fragmented .mp4 video, parses the MOOV and fragment headers and streams it. I have generated a .mp4 file myself using FFMPEG and MP4Box/bento4, but the software has problems processing it.

ffmpeg -i input.mp4 -g 25 -c:v libx264 -c:a copy out1.mp4

mp4fragment out1.mp4 --fragment-duration 1000 --track 'video' output.mp4

Using the MP4 Explorer software, I noticed in my generated .mp4 file, for all moof.traf.trun, sample duration is set to 0, but in the Track Fragment Header box, it sets the default_sample_duration to 512. While in the another .mp4 file which works fine, there is no default_sample_duration field, but each individual sample has a duration of size 512. Looks like this might cause the problem. The right figure shows the working mp4, and the left one is my generated mp4.

Is this an update in the newer versions of FFMPEG (or MP4Box or bento4)? Is there any ways to force setting the sample duration in samples?

My .mp4 file

The working .mp4 file

enter image description here

Mary
  • 393
  • 1
  • 4
  • 17
  • This looks like a `mp4box` issue, since it's creating the `MOOF` boxes. Share your mp4box command. – Gyan Jul 28 '17 at 15:57
  • Are you sure that 0x000100 sample-duration-present flag is actually set? - May be your viewer may default to zero. – Markus Schumann Jul 28 '17 at 17:34
  • @MarkusSchumann yes that is what I was thinking about. Probably there is no field that the processing software `segmentation faults`. Do you know how I can check this? – Mary Jul 28 '17 at 18:36
  • @Mulvya I actually used bento4 to fragment and save video only track: `bento4 --fragment-duration 1000 --track 'video' output.mp4` – Mary Jul 28 '17 at 18:39
  • Can you share the file(s)? – Markus Schumann Jul 28 '17 at 19:07
  • @MarkusSchumann I updated the question with the links – Mary Jul 28 '17 at 19:20
  • final_v.mp4 has not set the duration flag. Your viewer is misleading by displaying the duration as '0' - it is simple not set which is correctly flagged in trun.flags (0x100 is not set). Just looking at trun.entry[].duration - final_v.mp4 is correctly authored. Your file is likely not playing for some other reason. – Markus Schumann Jul 28 '17 at 19:41
  • So maybe the processing software assumes this field exists, and wants to get the data value, but doesn't find it. Right? – Mary Jul 28 '17 at 19:48
  • @MarkusSchumann How can we access the `default sample duration` field in the fragment header? – Mary Jul 28 '17 at 20:14
  • What software are you using for playback (or processing)? Do you have the source? Can you debug it?Using the default length makes more sense since it is more space efficient. – Markus Schumann Jul 28 '17 at 23:24
  • It is a huge base on proprietary code. But I just need a C++ function that returns the value of `default_sample_duration` given a file name! I couldn't find anything online. – Mary Jul 29 '17 at 15:26
  • @MarkusSchumann Hi Markus, I can share the source with you. But let's have a private chat. It should be easy for a C++ guy. – Mary Jul 31 '17 at 14:27
  • @MarkusSchumann I couldn't find your email. But please let me know how to get in touch. – Mary Jul 31 '17 at 14:30
  • 1
    go4shoe at hotmail com – Markus Schumann Jul 31 '17 at 14:41
  • @MarkusSchumann ok sent u a message. – Mary Jul 31 '17 at 20:06
  • I use http://www.onlinemp4parser.com/ for parsing my MP4 files. It gives lot more details than MP4 Explorer. – Alam Oct 16 '18 at 17:55

1 Answers1

2
  1. parse the TFHD
  2. extract the default_sample_duration
  3. use the default_sample_duration instead of the absent duration from TRUN
Pierz
  • 7,064
  • 52
  • 59
Markus Schumann
  • 7,636
  • 1
  • 21
  • 27