Bento4 icon indicating copy to clipboard operation
Bento4 copied to clipboard

Video tracks are not aligned (different frame rates)

Open sasquatch74 opened this issue 6 years ago • 16 comments

I am facing the following issue:

  1. The inputs are 5 multi bit-rate mp4 files. Four of these have a frame rate of 25 fps and the fifth one has 10 fps.
  2. I checked the GOP size on each of them. The 25 fps files have GOP size of 1 second (i.e., one I-frame every 25 frames). The 10 fps file has the GOP size of 1 second (i.e., one I-frame every 10 frames).
  3. mp4fragment command seems to work fine: mp4fragment.exe --fragment-duration 10000 inputfile.mp4 outputfile.mp4
  4. mp4dash always returns the following error: WARNING: video sample count mismatch between "File 5#1" and "File 4#1" ERROR: video tracks are not aligned ("File 5#1" differs from File 1#1)
  5. If I remove the 10 fps file from the mp4dash command, it works fine and generates the dash manifest.

I understand that mp4dash requires the key-frames to align, but when you have files with different frame rates, the key frames do not align by frame count but they do align if you consider the time in seconds or milliseconds.

What am I doing wrong?

sasquatch74 avatar Apr 09 '18 11:04 sasquatch74

@sasquatch74 I'm facing the same issue. Did you find a solution/workaround?

maetthu avatar Jun 30 '18 21:06 maetthu

To be honest, this isn't a scenario I have tested (different frame rates). So it may very well be an issue with the Bento4 packager. I will try this use case and followup.

barbibulle avatar Jul 01 '18 23:07 barbibulle

@barbibulle thanks :)

Up until now, we had all our videos up to 1080p, all being 30fps and a fixed 60 frames keyframe interval, but now we're trying to add 1080p@60 and 1440p@60 with a 120 frame keyframe interval to the mix, but with them added, mp4dash complains about the alignment. I tried forcing mp4fragment to a 2s segment size for both, but with the same result. As far as I understand, both align at 2s, despite the different framerate.

maetthu avatar Jul 02 '18 09:07 maetthu

@maetthu We couldn't make Bento4 packager work when source mp4 files had different frame rates. We used a different packager (the one from Unified Streaming - this is not free) to get it to work.

sasquatch74 avatar Jul 03 '18 04:07 sasquatch74

@barbibulle Did you have a chance to look into this? No worries if not, it's just that we will start with our encoding project soon and it would be nice to know if multiple framerates is something you'd consider worth supporting in the Bento4 packager.

maetthu avatar Sep 21 '18 12:09 maetthu

@maetthu Sorry for not having looked at this earlier. Would it be possible for send me a link to some sample files that I could use to easily replicate the issue on my side? This would save me some time. Thanks.

barbibulle avatar Sep 23 '18 18:09 barbibulle

@barbibulle sure! thanks for looking at it :slightly_smiling_face:

These are streaming versions I transcoded from 1080p@60fps version of the Big Buck Bunny video:

  • 1080p@60fps with a fixed 120 frame keyframe interval: https://labs.emgag.com/bento4/1080p_60.mp4
  • 720p@30fps with a fixed 60 frame keyframe interval: https://labs.emgag.com/bento4/720p_30.mp4

Steps to reproduce:

$ mp4fragment 1080p_60.mp4 1080p_60.fmp4
found regular I-frame interval: 120 frames (at 60.000 frames per second)
$ mp4fragment 720p_30.mp4 720p_30.fmp4
found regular I-frame interval: 60 frames (at 30.000 frames per second)
$ mp4dash -o out/ -f --mpd-name=master.mpd --hls *.fmp4
Parsing media file 1: 1080p_60.fmp4
Parsing media file 2: 720p_30.fmp4
WARNING: video sample count mismatch between "File 2#2" and "File 1#2"
ERROR: video tracks are not aligned ("File 2#2" differs from File 1#2)

maetthu avatar Sep 24 '18 12:09 maetthu

@barbibulle did you have a chance looking into it?

maetthu avatar Oct 29 '18 12:10 maetthu

I have fixed this on master (still haven't pushed a new set of pre-compiled binaries). Let me know if this works for you.

barbibulle avatar Nov 17 '18 23:11 barbibulle

@barbibulle Thanks for the fix on this. I'm however facing this issue when running mp4dash for 360, 480 and 720p renditions of my mp4 file to generate an ABR stream. I'm using the latest binaries for macOS but still facing this issue. What can I do to run it successfully?

wmucheru avatar Oct 03 '19 17:10 wmucheru

Same issue here

Benny739 avatar Jun 19 '20 19:06 Benny739

Same problem here, the last Linux release returns the same error.

rodrigo-brito avatar Sep 17 '20 02:09 rodrigo-brito

Facing the same issue. can someone help me? not sure how and what to fix FFmpeg Transcoding:

ffmpeg -loglevel error -i source.mp4
-map 0:v
-movflags +faststart -vsync 1
-c:v libx264
-s 256x144
-g 30
-profile:v main
-b:v 244894
-y 1.mp4

ffmpeg -loglevel error -i source.mp4
-map 0:v
-movflags +faststart -vsync 1
-c:v libx264
-s 416x234
-b:v 424101
-g 30
-profile:v main
-y 2.mp4

ERROR: video tracks are not aligned ("File 2#1" differs from File 1#1)

debug output of mp4dash: Segment Count = 56 Type = video Sample Count = 2767 Average segment bitrate = 253547 Max segment bitrate = 645680 Required bandwidth = 386983 Average segment duration = 2.001481481481483

Segment Count            = 56
Type                     = video
Sample Count             = 2767
Average segment bitrate  = 439965
Max segment bitrate      = 1136650
Required bandwidth       = 721261
Average segment duration = 2.001481481481483

baloda avatar Nov 06 '20 05:11 baloda

Hi @baloda. I solved the problem with a fixed fps (24FPS) and segments of two seconds (gop = 2 * 24 = 48). My FFMPEG parameters are:

-c:v libx264 -preset faster -x264opts keyint=48:min-keyint=48:no-scenecut -strict -2 -r 24

In mp4fragment, I also used the parameter --fragment-duration 2000

rodrigo-brito avatar Nov 06 '20 11:11 rodrigo-brito

Issue should be due to GOP Misalignment Adding following options to ffmpeg command solved my issue -keyint_min 48 -g 48 -sc_threshold 0

What these do? -keyint_min 48: keyint represents the key frame (IDR frame) interval. This option limits the IDR frame interval to a minimum of 48 frames, which is the same length as the previously set GOP. -sc_threshold 0: Disable scene recognition, that is, disable automatic addition of IDR frames

deBilla avatar Jan 30 '24 15:01 deBilla

Any solve ?

maytham553 avatar Jun 19 '24 18:06 maytham553