Log in

View Full Version : Does Matroska support Soft Telecine?


LigH
25th February 2014, 09:47
I just read an issue about FFMS2 2.19 and L-SMASH Source r713 (from MeGUI) returning ridiculous framerates like 24.374 fps in AviSynth reading a specific MKV file.

The thread starter reported the following MediaInfo log (excerpt):

Frame rate mode : CFR
Frame rate mode : Constant
Frame rate : 23.976
Frame rate : 23.976 fps
Original frame rate : 29.970
Original frame rate : 29.970 fps
Frame count : 33081
Standard : NTSC
Resolution : 8
Resolution : 8 bits
Colorimetry : 4:2:0
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8
Bit depth : 8 bits
Scan type : Progressive
Scan type : Progressive
Interlacement : PPF
Interlacement : Progressive

and the following AviSynth Info() overlay:

Frame 0 of 33629
Time: 00:00:00:000 of 00:22:59:729
ColorSpace: YV12
Width: 720 pixels, Height: 480 pixels.
Frames per second: 24.3736 (24398/1001)
FieldBased (Separated) Video: NO
Parity: Assumed Bottom Field First
Video Pitch: 736 bytes.

We already wondered if some rate skewing (forcing audio and video of different standards to match by Matroska features) could have caused this, but the full MediaInfo report and mkvinfo output don't flag any suspicious attributes (video and audio stream have equal length). So I wonder what causes AviSynth to believe in a frame rate "24398/1001", if the ratio between encoded and "original" framerate may point to a reason.

Kurtnoise
25th February 2014, 10:28
I would say it's related to the video stream, not to the container...and how ffmpeg libraries deal with framerate from the source, not avisynth itself.

LigH
25th February 2014, 10:35
MediaInfo reports 33081 frames / 23 min; AviSynth reports 33629 frames?! Seems that the indexing of FFMS2 and L-SMASH Source find more frames than expected.

DirectShowSource returns 41359 frames (which is quite close to 3:2 pulldown for 33081 * 5:4 ~ 41351).

foxyshadis
26th February 2014, 01:07
This is definitely a libav problem then, since both FFMS2 and L-SMASH use it. What do avconv or ffmpeg have to say about the file? Use
[ff/av]probe -count_frames -show_streams file.mkv
Look at nb_read_frames in particular, if it's wrong it's a definite bug in the base library. On the other hand, if it's right and nb_frames has an incorrect value, it might be that ffms2 and L-SMASH are taking the container's incorrectly frame count as gospel; avisynth has no notion of timecodes so it would be totally confused even if they're all correct. I wonder what would show up if you extracted the timecodes.

If everything looks right, maybe an identical bug in both ffms2 and L-SMASH?

It might be that something as simple as a remux will fix the file, especially if it was ffmpeg or libav that muxed it in the first place. mkvtoolnix has always been far more reliable for me when it comes to files playing, seeking, and such.

Edit: Forgot to answer the thread question: Yes, Matroska supports soft telecine via DefaultDecodedFieldDuration, as this file shows.

LigH
26th February 2014, 08:44
I will forward this request to the owner of this file.

The original file (not available in public) appears to be created with mkvtoolnix 2.0 in 2007; a snippet trimmed with mkvtoolnix 6.7 seems to be in sync while a trim of the original file in AviSynth was reported to be out of sync and timing...

LigH
26th February 2014, 11:21
So, ffprobe reports for the video stream:

nb_frames=N/A
nb_read_frames=33629
nb_read_packets=N/A


Possibly interesting: If I split the file into raw streams and reconstruct it in MKVmerge GUI, the video stream is either too fast without specifying a frame rate (NTSC rate assumed: 18:42.1) or too slow when NTSC-Film-rate is specified (23:22.6). For some reason, the average of 24.3736 fps seems to make sense. So I wonder if there is indeed some unobvious VFR (MediaInfo reported CFR), or some kind of "inserted blind frames" at subtitle positions. May have to analyze the timecode progress in the original file.