1. Join Now

    AVForums.com uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

offline FFDShow MAXIMUM DVD quality??

Discussion in 'Desktop & Laptop Computers Forum' started by stuthemong, Oct 27, 2004.

  1. stuthemong

    stuthemong
    Active Member

    Joined:
    Dec 31, 2002
    Messages:
    431
    Products Owned:
    0
    Products Wanted:
    0
    Trophy Points:
    18
    Ratings:
    +6
    Guys(/girls?),

    occured to me last night, we worry about getting damnned FFD show to give us best PQ, tweaking settings whilst watching our CPU usage like hawks to get smooth playbak on the fly.

    why dont we pre-process DVD's, or does someone already have software that does that?????

    Rather than playing a DVD and trying to resize with lancos 4 , NR, and a sharpen why dont we just do this offline. We can crank up the lancos settings, get the best filters to do all the work, and re-compress a film (well we'd start off with a 6 gig DVD, and end up with a 20 gig file or so) then play back the MAXIMUM quality upscaled version.

    OK it may take the PC 4 hours to do, but we can leave it overnight - this way we get better qiuality than just using FFDshow et al. on the fly.



    my current PC isnt quite fast enough 2.7 ghz to do decent ffding on the fly, but i am certian it could playback the equiv of 2 DVDs at once in terms of playing a 20 gig file over 2 hours.

    any comments? anyone know how to do this?
    stu
     
  2. KraGorn

    KraGorn
    Active Member

    Joined:
    Aug 30, 2003
    Messages:
    4,740
    Products Owned:
    0
    Products Wanted:
    0
    Trophy Points:
    68
    Location:
    Warrington
    Ratings:
    +27
    First big problem I see is how do you store it? You've taken a lossy compressed MPEG, decoded it (adding artifacts), resized it and now presumably are going to re-encode it in another lossy encoder .. only to have to decode it again (adding artifacts) to play-back.

    Seems more than likely some (much?) of the increased PQ achieved by FFD will be lost by the time you get to view it.

    IMHO the only way it's viable is if it's possible to capture the video as a stream, along the lines of the .TS hi-defs, maybe something like VLC can be used, I don't know.
     
  3. stuthemong

    stuthemong
    Active Member

    Joined:
    Dec 31, 2002
    Messages:
    431
    Products Owned:
    0
    Products Wanted:
    0
    Trophy Points:
    18
    Ratings:
    +6
    nah, it will be fine. :)

    using dvdshrink to re-encode a DVD to save space is great, all your doing is doing it the other way - making it bigger. I concede that some FFD will be usefull after, maybe a shade of sharpening or something. Yes if you keep on saving a JPeG image, over a few tries it gets worse and worse, but youll find the first 3-4 times you wont see any difference as long as you have a high enough setting.

    basically the massive CPU hit is resize, and this can definitely be done offline.
     
  4. KraGorn

    KraGorn
    Active Member

    Joined:
    Aug 30, 2003
    Messages:
    4,740
    Products Owned:
    0
    Products Wanted:
    0
    Trophy Points:
    68
    Location:
    Warrington
    Ratings:
    +27
    But if you use DVDShrink you're re-encoding lossyly (is that a word? :) ) thereby undoing some (much) of the good work FFD did in the first place I'd have thought.

    Anyhow, it still begs the question, how do you store the output from the FFD stage on disk for re-processing?
     
  5. stuthemong

    stuthemong
    Active Member

    Joined:
    Dec 31, 2002
    Messages:
    431
    Products Owned:
    0
    Products Wanted:
    0
    Trophy Points:
    18
    Ratings:
    +6
    OK. you seem to be slightly missing my point ;)

    I dont propose we actually have to use DVD shrink, or FFDshow. Both programs prove that;

    a) it is possible to re-encode on the fly. In DVDShrinks case, we decrese quality, but there is no reason why you have to make the file smaller!

    b)We can use lancos to upscale an image, and it looks better than a bilinear/bicubic transform that a video card does on its own. Noise reduction is also usefull, though reencoding a noise reduced sample may prove useless, as you rightly say that this process can add more noise.

    So my question losely asked is basically why cant we do something using DVDshrinks idea, with a FFDShow's idea to pre-process DVD's to get them to a much less CPU demanding format for maximum quality playback?
     
  6. iforgot

    iforgot
    Guest

    Products Owned:
    0
    Products Wanted:
    0
    Ratings:
    +0
    You can.

    Use your fav dvd decoder,rip the files to your hdd.

    Useing Dvd2avi or newer versions open up the vobfiles, make a que of them all save a project file.

    Then with avisynth and a handfull of plugins you can do whatever u like to the video.

    A basic script along the lines of: (# denotes end of line)

    LoadPlugin("C:\temp\MPEG2DEC.DLL")#
    LoadPlugin("C:\temp\VAGUEDENOISER.DLL.dll")#
    Video = mpeg2source("C:\YOURPROJECTFILE.d2v")#
    Video = ConvertToYUY2 (Video)#
    Video = Lanczos4Resize(YOURRESxYOURRES)#
    Video = VagueDenoiser(threshold=0.8,method=1,nsteps=6,chroma= true)#

    Save and load up in v.dubmod save as possibly uncompressed or huffy lossless codec and add in the ac3 soundtrack.

    Notice as time is not a factor i would do a resize first then playabout with other filters.

    Do simple crop's to remove any hardcoded blackbars.

    We could even work with filters to produce progressive images rather than let the display device do it.

    for instance we could sove the following problems:

    PAL
    1) progressive with phase shifts and or swapped fields (fields in a reversed order) (Telecide from the Decomb plugin)
    2) trully interlaced (KernelDeint plugin)
    3) bad NTSC to PAL conversions (blended fields) (Depends on what u want to do with this rubbish.)

    NTSC
    1) telecined material (29.97 fps) (InVerse TeleCine (IVTC))
    2) trully interlaced (29.97 fps) (KernelDeint plugin)
    3) phase shifts and or swapped fields (29.97 fps) (Telecide (from the Decomb plugin))

    Avisynth and virtualdubmod,with some plugins and support app's, are simply the best video editing and processing tools avalible.
     
  7. stuthemong

    stuthemong
    Active Member

    Joined:
    Dec 31, 2002
    Messages:
    431
    Products Owned:
    0
    Products Wanted:
    0
    Trophy Points:
    18
    Ratings:
    +6
    iforgot, thankyou for that, slightly above my head at the moment, but i shall do some research, and post back in a couple of days when i have had a look :)

    cheers,

    stu
     
  8. iforgot

    iforgot
    Guest

    Products Owned:
    0
    Products Wanted:
    0
    Ratings:
    +0
    Not a problem, its also possible to write small avisynth scrips inside ffdshow and use that if you like.

    If you want any help / pointers give us a shout, always glad :)
     
  9. Madders

    Madders
    Active Member

    Joined:
    Jan 30, 2002
    Messages:
    2,303
    Products Owned:
    0
    Products Wanted:
    0
    Trophy Points:
    51
    Location:
    London
    Ratings:
    +49
    Very interesting thread! I hadn't thought of doing this. I'm with Stu at the moment about it being over my head, will have to do some research.

    The problem I have with FFDShow, is that even with a 3.2 P4, when I resize with FFDShow I get juddery playback, I'm guessing that this is due to software decoding of my audio at the same time.

    Can anyone suggest a good starting point for my research?

    Thanks,

    Steve
     
  10. iforgot

    iforgot
    Guest

    Products Owned:
    0
    Products Wanted:
    0
    Ratings:
    +0
    I would start with:

    1) Decoding dvd's to hdd, your going to need to remove css to play with the video without a software dvd player. http://www.dvddecrypter.com/

    2) DGMPGDec , formally known as dvd2avi is the best mpeg2 decoder avalible. Find it play with it. http://www.doom9.net/

    3) AviSynth 2.55 - probably the most powerful video editing tool based on scripting, again get and install, have a look at some basic scripts see offical website. http://www.avisynth.org/

    4) Some plugins for avisynth....mpeg2dec3dg vob decoding libary, used to open a dvd2avi project (DGMPGDec)

    Then you just need to decide what your going to do with the video....You can just get avisynth to return the video to be displayed, or feed the avisynth script into virtualdub/virtualdubmod, and add the audio. (use DGMPGDec to extract)

    Once you have the video feeding to vdub, and save as Huffy YUV which is a lossless codec eg saves everybit of detail with no discard.

    Then your free to either use virtualdub or avisynth to resize, filter, crop, denoise,colour correct, sharpen, anything...

    If your going to use virtualdub as the filtersystem, a basic script such as:

    LoadPlugin("C:\temp\MPEG2DEC.DLL")#
    mpeg2source("C:\YOURPROJECTFILE.d2v")#

    would allow vdub to open it, or you can get creative with virtualdub :



    ***this is not my script..its off the avisynth website** but its an look at what can be done.

    Here's one guy's script using a main core and then refrance code, he's set it up to be able to quickly change from widescren, he also allows himself to quickly change one aspect of the script to call diffrent procedures depending on the aspect of the video. This scipt also deals with sound, and the frame rate is adjusted as well as sound to playback at 24fps.

    Now this script is used for playback....because you dont have the worry about realtime playback....you can make the resolution whatever u want using highquality scalling, and filter / sharpen the heck out of it.

    **


    Import ("C:\Videos\DVD's\DVD AVS's\Core.avs")# Import the Core code
    SetMemoryMax (64)# Set 64 Mb memory for operation

    Folder = "C:\Videos\DVD's\The Matrix Reloaded"# For SetWorkingFolder later on
    VideoName = "Upgrades"# Video name (The Upgrades Scene)
    AudioName = ""# Alternate audio track if found
    AudioDelay = -40# delay in milliseconds (converted to seconds later)
    MusicName = ""# Optional Music track
    MusicDelay = 0# delay in milliseconds (converted to seconds later)
    MusicGain = 0.1# Music is often louder than dvd audio, so turn the music volume down
    TrackMix = 1# 1=Audio, 2=Music, 3=Audio and music mixed

    Start = 758# Start frame
    End = 3157# End frame
    TopBar = 75# Number of lines in top black matte
    BottomBar = 75# Number of lines in bottom black matte
    VideoHeight = 576 - (TopBar + BottomBar)# Extract Number for Video's height
    DisplayMode = "Nil"# Default 'null transform' mode

    Effects = 0# Sets the Effects variable to 0
    Gamma = 1.4# Default Gamma for levels boost, but it can change
    Speed = 30# For chipmonk video!

    DisplayMode = "Anamorphic"# Sets up core for anamorphic function
    # DisplayMode = "Widescreen"# Sets up core for widescreen function
    # DisplayMode = "Fullscreen"# Sets up core for fullscreen function
    # DisplayMode = "TV"# Sets up core to simulate TV

    # Effects work on an additive process to provide a single number (in this case from 0 to 31)
    # The core will reverse this process to discover which effects are wanted

    Effects = (DisplayMode == "TV") ? Effects : Effects + 1 # Boost Levels
    # Effects = Effects + 2 # Show Delta Data
    # Effects = Effects + 4 # Swap Colour Channels
    Effects = (DisplayMode == "TV") ? Effects : Effects + 8 # Change Speed
    Effects = Effects + 16 # Flip Horizontal

    # Since TV mode will use the speed and gamma options, they are discounted when TV mode is being used

    # All necessary data has now been noted
    # Now pass it on to the core

    LoadVOB (VideoName, AudioName, AudioDelay, MusicName, MusicDelay, MusicGain, TrackMix, Folder)
    CreateFilm (Start, End, TopBar, VideoHeight)# Crop, Trim and slow to 24 fps
    (DisplayMode != "TV") ? ApplyEffects (Effects, Speed, Gamma) : Last# Apply effects before enlarging
    Eval (DisplayMode + "()")# Loads the function that has the same name as DisplayMode.
    (DisplayMode == "TV") ? ApplyEffects (Effects, Speed, Gamma) : Last# Apply effects after shrinking


    Above is a refrance script, the "core" script could be:

    Function LoadVOB (string VideoName, string AudioName, int AudioDelay, string MusicName, int MusicDelay, float MusicGain, int TrackMix, string Folder) {
    # Loads the VOB and WAV files and mixes them together
    # Output: YV12 Video @ 720 x 576, 25 fps, 50000 Khz 16 bit stereo

    SetWorkingDir (Folder)

    Video = (Exist (VideoName + ".d2v") == True) ? MPEG2Source (VideoName + ".d2v", idct = 5) : Subtitle(BlankClip (Width = 720, Height = 576, fps = 25), "Couldn't find video")
    # Loads video if it exists, or an error message

    Audio1 = (Exist (VideoName + ".wav") == True) ? WAVSource (VideoName + ".wav") : BlankClip (Audio_Rate = 50000, Stereo = True)
    Audio1 = (Exist (AudioName + ".wav") == True) ? WAVSource (AudioName + ".wav") : Audio1
    Audio1 = DelayAudio(Audio1, AudioDelay/1000)
    # Loads alternate audio track over original audio (if alternate exists), or a blank track if neither is found

    Audio2 = (Exist (MusicName + ".wav") == True) ? WAVSource (MusicName + ".wav") : BlankClip (Audio_Rate = 50000, Stereo = True)
    Audio2 = Amplify (Audio2, MusicGain)
    Audio2 = ResampleAudio (Audio2, 48000)
    Audio2 = AssumeSampleRate(Audio2, 50000)
    Audio2 = DelayAudio(Audio2, MusicDelay/1000)
    # Fiddle with the music track so that it is the same format as the audio and sped up to 25 fps.

    Audio3 = MixAudio (Audio1, Audio2)
    # Create mixed track

    Eval ("Video = AudioDub (Video, Audio" + String (TrackMix) + ")")
    # Use the audio track with the TrackMix number on the end.
    Video = ConvertToYUY2 (Video)
    # Convert the video so it is more compatible when cropping. and YUY2 is faster than YV12 on my PC for some reason...
    Return Video

    }

    Function CreateFilm (clip Video, int Start, int End, int TopBar, int VideoHeight) {
    # Slows PAL DVD's to 24 fps and 48000 Khz, trims the video, and crops black bars
    # Output: YUY2 Video @ 720 x xxx, 24 fps, 48000 Khz 16 bit stereo

    Video = AssumeFPS (Video, 24, True)# Slow to film rate. Audio slows to 48 Khz
    Video = Trim (Video, Start, End)# Trim out the parts you don't want
    Video = Crop (Video, 0, TopBar, 720, VideoHeight)# Crop off the black bars

    Return Video

    }

    Function Nil (clip Video) {
    # Null Transform
    # Output: Input
    # Does nothing. Used as default if all other DisplayMode functions are not enabled
    Return Video

    }

    Function Anamorphic (clip Video) {
    # Horizontal resize to 1024 pixels
    # Output: 1024 x xxx Video

    Video = LancZosResize (Video, 1024, Video.Height)
    Video = Sharpen (Video, 0.78)#

    Return Video

    }

    Function Widescreen (clip Video) {
    # Resize video to 16:9 Academy Widescreen
    # Output: 960 x 540 Video

    NLeft = Round (360 - (0.625 * Video.Height))
    NWidth = Round (720 - (2 * NLeft))
    NHeight = Video.Height
    Video = LancZosResize (Video, 960, 540, NLeft, 0, NWidth, Video.Height)
    Video = Sharpen (Video, Int (1.25 * ((Video.Width / NWidth) - 1)))

    # This cuts off some of the sides and enlarges it so that you get a near full screen 16:9 widescreen image

    Return Video

    }

    Function Fullscreen (clip Video) {
    # Resize video to 4:3 Fullscreen
    # Output: 768 x 576 Video

    NLeft = Round (360 - (0.46875 * Video.Height))
    NWidth = Round (720 - (2 * NLeft))
    NHeight = Video.Height
    Video = LancZosResize (Video, 768, 576, NLeft, 0, NWidth, Video.Height)
    Video = Sharpen (Video, Int (1.25 * ((Video.Width / NWidth) - 1)))

    # This cuts off more of the sides and enlarges it so that you get a near 4:3 fullscreen image

    Return Video

    }

    Function TV (clip Video) {
    # Resize video to SDTV
    # Output: 648 x xxx Video

    Video = BilinearResize (Video, 576, Round (45 * Video.Height / 64), 72, 0, 576, Video.Height)
    Video = Limiter (Video, 16, 235, 16, 240)
    Video = ApplyEffects (Video, 9, 25, 1.4)

    # Reduces the resolution and removes part of the sides to simulate a TV look. also increases the gamma and changes speed to 25 fps.
    # When in this mode, it uses ApplyEffects to control speed and gamma (why they are deactivated in the reference script)

    Return Video

    }

    Function ApplyEffects (clip Video, int Effects, float Speed, float Gamma) {

    Video = (Effects >= 16) ? FlipHorizontal(Video) : Video
    Effects = (Effects >= 16) ? Effects - 16 : Effects
    Video = (Effects >= 8) ? AssumeFPS (Video, Speed, True) : Video
    Effects = (Effects >= 8) ? Effects - 8 : Effects
    Video = (Effects >= 4) ? SwapUV(Video) : Video
    Effects = (Effects >= 4) ? Effects - 4 : Effects
    Video = (Effects >= 2) ? Subtract (Trim (Video, 1, 0), Video) : Video
    Effects = (Effects >= 2) ? Effects - 2 : Effects
    Video = (Effects >= 1) ? Levels (Video, 0, Gamma, 255, 0, 255) : Video
    Effects = (Effects >= 1) ? Effects - 1 : Effects

    # Uses the reverse process to work out what functions to use. speed and gamma options are also brought in.

    Return Video

    }

    Function HQ_Widescreen (clip Video) {
    # Resize video to 16:9 Academy Widescreen
    # Output: 1024 x 576 Video

    NLeft = Round (360 - (0.625 * Video.Height))
    NWidth = Round (720 - (2 * NLeft))
    NHeight = Video.Height
    Video = LancZosResize (Video, 1024, 576, NLeft, 0, NWidth, Video.Height)
    Video = Sharpen (Video, Int (1.25 * ((Video.Width / NWidth) - 1)))

    # Same as Widescreen except it gives a larger image. my computer can't handle this at runtime, so i only use it to grab high quality frames for backgrounds or the like

    Return Video

    }

    Function HQ_Fullscreen (clip Video) {
    # Resize video to 4:3 Fullscreen
    # Output: 1024 x 768 Video

    NLeft = Round (360 - (0.46875 * Video.Height))
    NWidth = Round (720 - (2 * NLeft))
    NHeight = Video.Height
    Video = LancZosResize (Video, 1024, 768, NLeft, 0, NWidth, Video.Height)
    Video = Sharpen (Video, Int (1.25 * ((Video.Width / NWidth) - 1)))

    # It gives a larger fullscreen image. my computer can't handle this, so i only use it to grab high quality frames

    Return Video

    }
     
  11. stuthemong

    stuthemong
    Active Member

    Joined:
    Dec 31, 2002
    Messages:
    431
    Products Owned:
    0
    Products Wanted:
    0
    Trophy Points:
    18
    Ratings:
    +6
    awesome iforgot. I am sooo busy at the moment, but i will look at this stuff over the next few days/weeks.

    This seems like such a good idea for my system - i think some pretty darn good quality images can be obtained !!!!!!

    (i would also expect the re-encoding to be almost realtime speed. Given the PC doesnt have to do all the displaying of hte video, and just encoding, it will save the PC sooooooo much overhead, so it can just concentrate on making the video pretty :)
     
  12. probedb

    probedb
    Banned

    Joined:
    Aug 20, 2003
    Messages:
    2,653
    Products Owned:
    0
    Products Wanted:
    1
    Trophy Points:
    86
    Location:
    Sheffield
    Ratings:
    +181
    i think the only problem i see with this is that you're going to be better trying to do as little compression as possible which means rather a lot of disc space :) but it's definitely a good idea as machines which are too slow to use ffdshow and resize are more than capable of playing back 1080p wmv-hd with 5.1 surround :)
     
  13. stuthemong

    stuthemong
    Active Member

    Joined:
    Dec 31, 2002
    Messages:
    431
    Products Owned:
    0
    Products Wanted:
    0
    Trophy Points:
    18
    Ratings:
    +6
    well, i was hoping for a soln much like it seems iforgot posted. If i want to watch a film one night, ill set it to go. 2 hours later, granted ill have a 30 gig file on my HDD, but i can delete it after watching :)
     
  14. iforgot

    iforgot
    Guest

    Products Owned:
    0
    Products Wanted:
    0
    Ratings:
    +0
    As for real time, encoding, your need a hell of a system....

    Its a dam lot easier for the computer,to dump that raw data, to the vga card, and use hardware to render and display it, on the otherhand it takes tons of cpu cycles to encode a single frame, lossless, or even loads of hddtime to save it uncompressed.

    Uncompressed your looking at guessing 30-50gb files.

    WMV HD....arrrgh, i so dispise it....microsoft using its money to buy support for ther lacking products.

    But like i said the lareg script above was just an example.

    Personally i would't bother processing audio in a script. If it was me, i would do:
    dvd -> harddrive -> dvd2avi project -> avisynth -> virtualdubmod.

    And use avisynth(really simple script, just load plugins, load the video,crop any black bars, resize,denoise,sharpen) use dvd2avi to mux out the ac3 sound, then use virtualdubmod, on a quick compress mode, to save it lossless avi.

    I would then use mediaplayerclassic as playback device...dvi output at 1280x720 (720p) to sanyo z2 :)

    Of course you could resize to 1080, and then do not de-interlace, setup the dvi output to 1080i, and wolla, however im doubtfull if it would be any bennifit.

    My script would go:

    LoadPlugin("C:\temp\MPEG2DEC.DLL")#
    LoadPlugin("C:\temp\VAGUEDENOISER.DLL.dll")#
    LoadPlugin("C:\temp\ASHARP.DLL")#
    Video = mpeg2source("C:\dvd1.d2v")#
    Video = ConvertToYUY2 (Video)#
    Video = Lanczos4Resize(1280x720)#
    Video = VagueDenoiser(threshold=0.8,method=1,nsteps=6,chro ma= true)#
    Video = asharp(2)

    Or perhaps use the pixydust denoise filter which is also very good.
     
  15. stuthemong

    stuthemong
    Active Member

    Joined:
    Dec 31, 2002
    Messages:
    431
    Products Owned:
    0
    Products Wanted:
    0
    Trophy Points:
    18
    Ratings:
    +6
    damn, yuour right, for some reason the writing to HDD didnt figure in my mind. Doh. Still, worth a play i think. whats 50 gigs between friends ? ;)
     
  16. Madders

    Madders
    Active Member

    Joined:
    Jan 30, 2002
    Messages:
    2,303
    Products Owned:
    0
    Products Wanted:
    0
    Trophy Points:
    51
    Location:
    London
    Ratings:
    +49
    Awesome. Thank's Iforgot!

    I still think that it's going to take a while to get my head around this but definitely worth a bit of reading up!

    Cheers,

    Steve
     

Share This Page

Loading...