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. |
28th September 2015, 11:11 | #1 | Link |
Registered User
Join Date: Apr 2009
Posts: 478
|
Help needed with VFR Framerate Conversion?
Hi all. I have been stumped at trying to re-encode a certain MP4 file.
Here's the MediaInfo for it: Code:
Video ID : 1 Format : AVC Format/Info : Advanced Video Codec Format profile : Main@L4 Format settings, CABAC : Yes Format settings, ReFrames : 1 frame Format settings, GOP : M=1, N=60 Codec ID : avc1 Codec ID/Info : Advanced Video Coding Duration : 2h 10mn Bit rate : 5 779 Kbps Width : 1 920 pixels Height : 1 080 pixels Display aspect ratio : 16:9 Frame rate mode : Variable Frame rate : 29.102 fps Original frame rate : 29.970 fps Minimum frame rate : 9.990 fps Maximum frame rate : 30.000 fps Color space : YUV Chroma subsampling : 4:2:0 Bit depth : 8 bits Scan type : Progressive Bits/(Pixel*Frame) : 0.096 Stream size : 5.25 GiB (97%) Language : English Encoded date : UTC 2015-08-19 01:48:20 Tagged date : UTC 2015-08-19 01:48:20 So I Googled and the Avisynth Wiki suggested using mp4fpsmod to extract the timecode and mux it with the resulting file. So, I went ahead and used MKVMerge to mux the MP4, along with the timecode, and the resultant mkv file plays in sync. However, if I were to do my 60fps encoding, MKVMerge throws up an error when I try to mux the timecode file with the resulting 60fps mkv, complaining that the amount of frames in the timecode is lesser than the file. What would be the proper way to handle this? I hope that I'm making sense here, I know it's a complex issue. Thanks in advance tl;dr Trying to convert VFR file to 60fps-ish. Result has video/audio sync problems. Edit: I have tried using DirectShowSource in conjunction with convertfps=true and this does not work as well. Last edited by aegisofrime; 28th September 2015 at 11:15. |
28th September 2015, 11:21 | #2 | Link |
Anime addict
Join Date: Feb 2009
Location: Spain
Posts: 673
|
Invoke video with:
LSMASHVideoSource("xxxx.mp4").assumefps(30000,1001.0) #Now interframe
__________________
Intel i7-6700K + Noctua NH-D15 + Z170A XPower G. Titanium + Kingston HyperX Savage DDR4 2x8GB + Radeon RX580 8GB DDR5 + ADATA SX8200 Pro 1 TB + Antec EDG750 80 Plus Gold Mod + Corsair 780T Graphite |
30th September 2015, 14:43 | #3 | Link | |
Registered User
Join Date: Apr 2009
Posts: 478
|
Quote:
Is there anything else I can try? |
|
30th September 2015, 15:12 | #4 | Link |
Registered User
Join Date: Dec 2002
Posts: 5,565
|
Code:
a=LSMASHAudioSource("xxxx.mp4", av_sync=true) v=LSMASHVideoSource("xxxx.mp4", fpsnum=30000, fpsden=1001) AudioDub(v, a) |
30th September 2015, 15:14 | #5 | Link |
Registered User
Join Date: Jan 2010
Posts: 709
|
You have to open it with
Code:
DirectShowSource("F:\Hybrid\vfr.mkv", fps=29.97, convertfps=true) #interframe or extract the timecode from mp4 and use some tool to convert the vfr script or avi to a cfr one like tc2cfr otherwise use normal lsmash/ffmpeg/dss2 source filter, interframe it and use the extracted timecode when encoding or muxing, but I don't know if there is a tool to easely edit timecodecs for a different framerate.
__________________
powered by Google Translator Last edited by Motenai Yoda; 30th September 2015 at 15:36. |
30th September 2015, 15:51 | #6 | Link | ||
Registered User
Join Date: Apr 2009
Posts: 478
|
Quote:
Quote:
Thanks guys will give your suggestions a go as soon as my current encode finishes. |
||
30th September 2015, 20:38 | #8 | Link |
Registered User
Join Date: May 2009
Location: Belgium
Posts: 1,748
|
Another possibility that may work : open your video in Virtual Dub with the ffmpeg plugin, convert in lossless (Lagarith for example), open this video (that should have a 29.97 CFR and be played in sync) with Avisynth and use Interframe.
Virtual Dub with the ffmpeg plugin was the only method that worked with a VFR h264 video I had to convert in CFR. https://fr.osdn.jp/projects/sfnet_vi...eginputplugin/ In Virtual Dub, go in File, open video file, files of type, choose FFMpeg supported files, select your video and open it. The problem being that a 2h10mn 1080p video in Lagarith will be huge. Last edited by Music Fan; 30th September 2015 at 20:53. |
1st October 2015, 05:40 | #9 | Link |
Registered User
Join Date: Mar 2014
Posts: 308
|
Motenai Yoda's post is, thus far, the only reply in this thread that actually makes sense. If you want to stick to AviSynth processing, you should convert to CFR first (because there's no concept of VFR within AviSynth) and then do motion interpolation. (Note: "convert", not just "assume as CFR".) Using one of those duplicate frame removing thingamajigs will probably improve results further.
This is not a perfect solution, but it's certainly an easy one. If you want the frame timings to be handled 100% properly, one way to do this is to write a script to parse the extracted timecodes, calculate the interpolation position for every frame, then dump this out in the form of an AviSynth script. Alternatively, you could run InterFrame as usual, and modify the timecodes so that you insert a new timecode between every two old timecodes by averaging them, then mux the result with these new timecodes. This is probably a bit easier than the above suggestion.
__________________
Say no to AviSynth 2.5.8 and DirectShowSource! Last edited by colours; 1st October 2015 at 05:47. |
1st October 2015, 08:25 | #10 | Link | |
Registered User
Join Date: May 2009
Location: Belgium
Posts: 1,748
|
Quote:
Mine makes sense too and works (maybe not with all videos but no solution works every time), the problem being the size of the intermediate file. But it's easy to do, no need for timecode extraction and remux. |
|
1st October 2015, 10:31 | #11 | Link |
Angel of Night
Join Date: Nov 2004
Location: Tangled in the silks
Posts: 9,562
|
Every suggestion I've seen so far will lead to broken interpolation, by duplicating or dropping frames and confusing the hell out of Interframe. How about this: Use DSS to import a Graphedit .grf instead, one in which you start with your mp4 source and connect SVP. Let the VFR be taken care of in a VFR domain instead of importing it into avisynth.
If Interframe is ever ported to VapourSynth, it would just work, since VS natively supports VFR. But it's not available yet. |
1st October 2015, 11:20 | #12 | Link | |
Registered User
Join Date: Oct 2007
Posts: 135
|
Quote:
|
|
1st October 2015, 12:56 | #13 | Link | |
Registered User
Join Date: May 2009
Location: Belgium
Posts: 1,748
|
Quote:
I don't understand why Interframe would be more confused if there is a VFR step before, it's not supposed to know it if CFR is created before the Interframe step (whatever the VFR to CFR conversion is made with Avisynth in the same script than the Interframe process or with Virtual Dub and an intermediate avi). Last edited by Music Fan; 1st October 2015 at 13:04. |
|
1st October 2015, 13:25 | #14 | Link | |||
/人 ◕ ‿‿ ◕ 人\
Join Date: May 2011
Location: Russia
Posts: 643
|
Quote:
Should you convert it 120 instead? Maybe even using so-called "null frames"? Oh, wait, we've been there before. Quote:
Avisynth can't handle VFR, and thus can't Interframe. Whatever method you use to convert it to CFR will have same result - it just won't interpolate between dublicated frames at best (and with blended frames it will be even more sad). Imagine having 10 fps video that was converted to 30 and then interpolated to 60. Quote:
If video is switching between different constant framerates it should be possible to splice those parts and use Interframe on each part separately... With v1 timecodes it shouldn't be hard. Last edited by vivan; 1st October 2015 at 13:51. |
|||
1st October 2015, 13:49 | #15 | Link | |
Registered User
Join Date: May 2009
Location: Belgium
Posts: 1,748
|
Quote:
I understand. In this case, if it doesn't work with hard coded duplicated frames, it won't work better with a VFR video. |
|
1st October 2015, 14:13 | #17 | Link | |
Registered User
Join Date: Apr 2009
Posts: 478
|
Wow, thanks for the very enlightening discussion so far guys! There's so much that I don't know. The point about using Vapoursynth is interesting. Wasn't there a way to use Avisynth plugins in Vapoursynth?
Unfortunately I haven't gotten a chance to try your suggestions yet; QTGMC'ing a Blu-Ray is no joke! Quote:
Code:
# Example for 10 consecutive frames at 25fps: 0 40.0 80.0 120 160 200 240 280 320 360 Code:
# Example for 10 consecutive frames at 50fps: 0 20 40.0 60.0 80.0 100.0 120 140 160 180 200 220 240 260 280 300 320 340 360 Once again, I appreciate everyone's input in this! It would probably help others who have to deal with VFR content as well! |
|
1st October 2015, 15:58 | #19 | Link |
Registered User
Join Date: Mar 2014
Posts: 308
|
That's the exact reason I didn't suggest VapourSynth here. The problem of writing a shim to handle VFR correctly is as hard as writing a script to output a script with pre-calculated interpolation fractions (as in the time parameter of MFlow/MFlowInter).
__________________
Say no to AviSynth 2.5.8 and DirectShowSource! |
2nd October 2015, 11:16 | #20 | Link | |
Angel of Night
Join Date: Nov 2004
Location: Tangled in the silks
Posts: 9,562
|
Quote:
If SVP really can't switch on real-time framerate -- apparently it's still tied too close to MVTools -- then I guess there are no good easy solutions. VS would require some heavy lifting, not just translating but changing the script. Like vivan says, for best quality you're stuck for now with chopping the video up with v1 timecodes and separately Interframing each. |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|