ffdshow

Questions and comments specific to a particular plugin should go here.
prostetnic
Posts: 28
Joined: Fri Apr 18, 2008 6:52 pm
Location: Sweden

Re: ffdshow

Post by prostetnic » Tue Sep 30, 2008 5:59 pm

No I had not. That fixed the problem.
I thought it would be something simple :)
Could be a good idea to include that information in the description of the plugin.
Thanks a lot.

User avatar
Luca Brasi
Experienced User
Posts: 262
Joined: Sat Oct 11, 2008 12:39 pm

Re: ffdshow

Post by Luca Brasi » Sat Oct 11, 2008 12:47 pm

Hi, first of all, great plugin. Thank you for that. But I have a Problem with it. Is my assumption right, that the plugin only is capable of controlling der ffdshow Video options? If so I'm stuck because I would love to switch between audio profiles. Any chance to do that? Thanks for your help in advance. Luca
Win10 x64 Prof. / Eventghost latest / MCE Plugin / MCE RC6 Receiver / Logitech Harmony Hub / MediaPortal / kodi

Bartman
Plugin Developer
Posts: 881
Joined: Sun Feb 12, 2006 9:03 am

Re: ffdshow

Post by Bartman » Sat Oct 11, 2008 3:52 pm

AFAIK the audio part does not support the remote control interface of the video part. So there is no way to do this remotely.

User avatar
Luca Brasi
Experienced User
Posts: 262
Joined: Sat Oct 11, 2008 12:39 pm

Re: ffdshow

Post by Luca Brasi » Sat Oct 11, 2008 4:05 pm

Thanks for your reply bartman. I couldn't find the settings for the keyboard/mouse input in audio config, so i didn't
expect too much. But it sucks, would have helped me a lot. I'll give it a try and write the guys of the ffdshow project.
Win10 x64 Prof. / Eventghost latest / MCE Plugin / MCE RC6 Receiver / Logitech Harmony Hub / MediaPortal / kodi

jonnybee
Posts: 5
Joined: Wed Jul 08, 2009 9:14 pm

Re: ffdshow

Post by jonnybee » Wed Jul 08, 2009 9:56 pm

First of all, this is a great plugin. I have been using FFDShow for quite a long time in connection with Girder, but I have switched to EG and I am very pleased that there is a plugin which simplifies the work with EG+FFDShow.

It would be very useful (at least for me) to have the following functions added:
(1) change the size of the subtitles (I personally use Autosize option and play with Scale (X and Y) parameters, since the absolute value of the font is dependent of the video resolution);
(2) change the vertical position of the subtitles;
(3) switch between multiple subtitles;
(4) change the color and font of the subtitles.

Apart from (2), I don't think that any other command can be achieved by Keyboard shortcuts.
Thank you!

cesarius
Posts: 5
Joined: Wed Aug 26, 2009 2:23 pm

Re: ffdshow

Post by cesarius » Fri Aug 28, 2009 3:58 pm

Hello,

may be someone can help me with this issue. I would like to fastforward/rewind the video with the ffdshow plugin. I´ve already tried the way without the plugin, by emulating keystrokes with eventghost but it didnt work (See Thread http://www.eventghost.org/forum/viewtop ... f=2&t=1841 ).
First, I must confess that I am not a coder, a totally beginner in this...
The original ffdshow plugin doesn't support the fastforward/backward, so I tried to put those two commands to the python script of the plugin :

Code: Select all

WPRM_SETPARAM_ID = 0 # lParam - parameter id to be used by WPRM_PUTPARAM, 
                     # WPRM_GETPARAM and COPY_PUTPARAMSTR
WPRM_PUTPARAM = 1    # lParam - new value of parameter, returns TRUE or FALSE
WPRM_GETPARAM = 2    # lParam - unused, return the value of parameter
WPRM_GETPARAM2 = 3   # lParam - parameter id
WPRM_STOP = 4
WPRM_RUN = 5
WPRM_GETSTATE = 6    # returns playback status
                     #  -1 - if not available
                     #   0 - stopped
                     #   1 - paused
                     #   2 - running
WPRM_GETDURATION = 7 # returns movie duration in seconds
WPRM_GETCURTIME = 8  # returns current position in seconds
WPRM_PREVPRESET = 11
WPRM_NEXTPRESET = 12 
WPRM_SETCURTIME = 13 # Set current time in seconds
//Changes
WPRM_FASTFORWARD = 15
WPRM_FASTREWIND = 16
//end of Changes
According to the ffdshow api ( FFDShowAPI.cs in https://ffdshow-tryout.svn.sourceforge. ... FDShowAPI/) the ID´s for fastforward and rewind are 15 and 16.
After that I added the two actions:

Code: Select all

#aType, aGroup, aClsName, aName, aDescription, aValue, aOptions
CMDS = (
    (WParamAction, None, "Run", "Run", None, 5, None),
    (WParamAction, None, "Stop", "Stop", None, 4, None),
    //Changes
    (WParamAction, None, "FASTFORWARD", "FASTFORWARD", None, 15, None),
    (WParamAction, None, "FASTREWIND", "FASTREWIND", None, 16, None),
    //end of Changes    

    #deprecated actions
    (GetIntAction, "deprecated", "GetSubtitleDelay", "Get Subtitle Delay", None, 812, None),
    (SetIntAction, "deprecated", "SetSubtitleDelay", "Set Subtitle Delay", None, 812, None),
    (ChangeIntAction, "deprecated", "ChangeSubtitleDelay", "Change Subtitle Delay", None, 812, None),

    #CropNzoom
    (IntegerAction, "CropNzoom", "CropNzoomMagnificationX", "Crop: Magnification X", None, 714, (0, 100, True, 1)),
    (IntegerAction, "CropNzoom", "CropNzoomMagnificationY", "Crop: Magnification Y", None, 720, (0, 100, True, 1)),
    (ToggleAction, "CropNzoom", "CropNzoomMagnificationLock", "Crop: Magnification Lock", None, 721, None),
    
    #DeBand
    (IntegerAction, "GradFun", "GradFunThreshold", "DeBand: Threshold", None, 1156, (101, 2000, True, 100)),
    
    #Deinterlacing
    (ToggleAction, "Deinterlace", "DeinterlaceSwapFields", "Deinterlacing: Swap fields", None, 1409, None),
    (SelectAction, "Deinterlace", "DeinterlaceMethod", "Deinterlacing: Method", None, 1403,
        ( (12, "Bypass"),
            (0, "Linear interpolation"),
            (1, "Linear blending"),
            (2, "Cubic interpolation"),
            (3, "Cubic blending"),
            (4, "Median"),
            (5, "TomsMoComp"),
            (6, "DGBob"),
            (7, "Framerate doubler"),
            (8, "ffmpeg deinterlacer"),
            (9, "DScaler plugin"),
            (10, "5-tap lowpass"),
            (11, "Kernel deinterlacer"),
            (13, "Kernel bob" ))),
    
    #Presets
    (WParamAction, "Presets", "PreviousPreset", "Previous Preset", None, 11, None),
    (WParamAction, "Presets", "NextPreset", "Next Preset", None, 12, None),

    #subtitle actions
    (IntegerAction, "Subtitles", "SubtitleDelay", "Subtitle: Delay", None, 812, None),

)


Can someone tell me why this additions don't work? They are called exactly in the same manner as the Stop and Run commands.
They appear in Eventghost and I can put them in the macro, but they don't control ffdshow.

Many thanks in advance!
Michael

Samcek
Posts: 14
Joined: Sat Oct 03, 2009 4:52 pm

Re: ffdshow

Post by Samcek » Tue Mar 02, 2010 7:40 pm

Now this one is interesting. Intended directly for Bitmonster.

FFDShow plugin has a bug. Well, maybe we could call it a feature, but it is not a nice one. It is driving me nuts.

What I'm trying to do is switch active profile using ffdshow plugin (of course, on a running graph). I'm trying to use it as a part of ChrisTV setup (an app for watching live tv), but that is a minor point.

The problem is, switching active profiles via WM_COPYDATA mechanism method doesn't work, however, all other ffdshow plugin actions, like "next preset" or "prev. preset" work perfectly. (This means that the FFDShow is running, with remote API enabled as it should be, and that SendMessage mechanism is doing its job as intended.) But when it comes to switching presets by using a preset name, it doesn't work. Of course, the mechanism in this case is a bit different than in other actions, because it must transfer a string (and here the trouble starts).

I've been looking into this to see if I can fix it myself. I can't, because I'm not any good as a Phython programmer , but at least I think I found the source of the bug. I would be really grateful if Bitmonster (or someone else knowledgable enough with Python) could fix it or post a solution below.

The problem is, I believe, in (improper) handling of Unicode strings.

I'm running a FFDShow version that is unicode-compiled, the about dialog states the following:
ffdshow tryouts version revision 2228 Oct 17 2008 19:07:17 (msvc 2003, x86, unicode)

The strings passed through SendMessage mechanism by EG's ffdshow plugin are, if I can read the source correctly, basically 8-bit character arrays (well, pointers to them, anyway). But, on the receiving end, the way FFDShow decodes and interprets the string passed by SendMessage mechanism depends on how the ffdshow is compiled - ascii or unicode. In my case it's unicode-compiled and the strings that come out the other side look nothing like the strings that were passed in by the EG plugin. So, in effect, if you have a FFDShow preset named "test" and you put "test" as a parameter in the EG plugin, it will come out garbled on the other side and nothing will happen - because the received string won't be equal to any preset name.

I found this out by editing the plugins code - I substituted a constant named COPY_SETACTIVEPRESET (which equals to 10) by number 19 (which is the FFDShowAPI's id for displaying OSD message) and checked what came out by looking at the OSD. Instead of original string, some garbled characters are displayed.

Now, the source code for the receiving side (FFDShowApi) looks like this:

Code: Select all

  482      public String ActivePreset
  483         {
  484             get
  485             {
  486                 string tmpStr = getStringParam(FFDShowConstants.FFDShowDataId.IDFF_OSDcurPreset);
  487                 if (tmpStr != null && !tmpStr.Equals(""))
  488                 {
  489                     return tmpStr;
  490                 }
  491                 else
  492                 {
  493                     return DefaultVideoPreset;
  494                 }
  495             }
  496             set
  497             {
  498                 if (IsFFDShowActive)
  499                 {
  500                     PlayState playState = getState();
  501                     if (playState == PlayState.PlayState || playState == PlayState.FastForwardRewind)
  502                         pauseVideo();
  503                     Win32.COPYDATASTRUCT cd = new Win32.COPYDATASTRUCT();
  504                     cd.dwData = new UIntPtr((uint)FFDSM_SET_ACTIVE_PRESET_STR);
  505 #if UNICODE
  506                     cd.lpData = Marshal.StringToHGlobalUni(value);
  507 #else
  508                     cd.lpData = Marshal.StringToHGlobalAnsi(value);
  509 #endif
  510                     cd.cbData = (uint)Win32.GlobalSize(cd.lpData);
  511                     if (receiver == null)
  512                         receiver = new FFDShowReceiver(Thread.CurrentThread);
  513                     receiver.ReceivedString = null;
  514                     receiver.ReceivedType = 0;
  515                     //receiver.ParentThread = Thread.CurrentThread;
  516                     Win32.SendMessage(new IntPtr(ffDShowInstanceHandle), Win32.WM_COPYDATA, receiver.Handle.ToInt32(), ref cd);
  517                     if (playState == PlayState.PlayState || playState == PlayState.FastForwardRewind)
  518                         startVideo();
  519                 }
  520                 DefaultVideoPreset = value;
  521             }
  522         }
Notice the lines 505 through 509 - they switch between decoding the passed sequence of bytes in two ways - either by treating it as unicode or as ascii.


Now, the only remaining question for the author(s) of the ffdshow plugin is, how do I pass the correctly encoded sequence of bytes to the SendMessage mechanism, so that the FFDShow will decode it properly? Without that I'm unable to select the appropriate preset, which means I can't switch through different aspect ratios (16:9,4:3,smart stretch, etc..) when watching TV. And I would really like to do that. :)

So, how do i modify the plugin code, which is currently:

Code: Select all

    
        cds = COPYDATASTRUCT()
        cds.dwData = COPY_SETACTIVEPRESET
        cds.lpData = cast(c_char_p(preset), PVOID)
        cds.cbData = len(preset) + 1
        SendMessage(hwnd, WM_COPYDATA, eg.messageReceiver.hwnd, addressof(cds))
   
to pass a properly encoded unicode sequence (in cds.lpData) to the other side?

Bartman
Plugin Developer
Posts: 881
Joined: Sun Feb 12, 2006 9:03 am

Re: ffdshow

Post by Bartman » Wed Mar 03, 2010 1:40 pm

could you do some research if non unicode builds are created anymore?

Samcek
Posts: 14
Joined: Sat Oct 03, 2009 4:52 pm

Re: ffdshow

Post by Samcek » Wed Mar 03, 2010 6:56 pm

I checked and I couldn't find any non-unicode build. I remember downloading FFDShow from free-codecs site (not the usual sourceforge site) a couple of years ago, but can't remember whether I intentionally downloaded a unicode version or whether that was already the only option then. Right now, I couldn't find any non-unicode builds of FFDShow.

But, on the upside, I think I found a solution to my own problem. Although the source code change is quite small, for me it was a quest into understanding of Win32 API, SendMessage mechanism, C/C++ pointers and python datatypes. Eventually, what I found out to be working, is this code:

Code: Select all

        cds = COPYDATASTRUCT()
        cds.dwData = COPY_SETACTIVEPRESET
        cds.lpData = cast(c_wchar_p(preset), PVOID)
        cds.cbData = len(preset)*2 + 1
        return SendMessage(hwnd, WM_COPYDATA, eg.messageReceiver.hwnd, addressof(cds))
The two changes are small but significant: first, we use a c_wchar_p instead of c_char_p. The original c_char_p is a null-terminated string of 8-bit chars, and the new c_wchar_p is a null-terminated string of wide chars (16-bit). Second, we must correctly calculate the length of the passed data string, which is calculated in bytes, not chars. This means multiplying the string length by 2, because each char is represented by two bytes.

It seems that this solution works. I'm not absolutely sure if this is the way it is supposed to be done, but being a Java developer and not having the word pointer in my vocabulary this is my best effort concerning such problem.

Bartman
Plugin Developer
Posts: 881
Joined: Sun Feb 12, 2006 9:03 am

Re: ffdshow

Post by Bartman » Wed Mar 03, 2010 8:45 pm

I guess ansi builds were dropped with Win9x support
Windows 98/ME support has been dropped starting with revision 2353.
I will update to beta7 now and check your fix. I don't get any problems I will commit the change.

edit:
somehow seems to work unrealible. Does it work for you every time?

Samcek
Posts: 14
Joined: Sat Oct 03, 2009 4:52 pm

Re: ffdshow

Post by Samcek » Thu Mar 04, 2010 7:05 pm

You're right, it is unreliable, because of a bug. I posted my half-cooked solution right after finding it, and didn't realize that it isn't perfect. After a day of using it, I too have stumbled upon this. In some cases, it doesn't work. After some testing with OSD function (instead of presets), I found out that sometimes the decoded string is a little bit longer than the sent one. Curious. Some trials and errors later, it seems that the correct way to calculate the length of the copied char array is this:

Code: Select all

        cds.cbData = (len(preset) + 1)*2
It seems that the NUL terminator is encoded in two bytes, too. Funny. I'm not a C developer, and that seems odd to me. But judging by the result, it is exactly what is happening. Maybe someone with better understanding of C types can explain this better. I thought that the NUL character is appended after the string is converted to the 16-bit form, but it seems this is not the case.

Anyhow, after some testing of this fix, I couldn't repeat the odd behaviour. Please test it yourself and confirm if it works for you too.

Samcek
Posts: 14
Joined: Sat Oct 03, 2009 4:52 pm

Re: ffdshow

Post by Samcek » Thu Mar 04, 2010 7:09 pm

One other thing, regarding the presets. About the GetPresets action, which should return the list of available presets. How does it work, really? There is no direct return value from the SendMessage, it seems that the reply is asynchronous callback. But, I can't find the way to access this callback.

Code: Select all

SendMessage(hwnd, WM_COPYDATA, [b]eg.messageReceiver.hwnd[/b], addressof(cds))
It seems that the parameter eg.messageReceiver.hwnd is the callback target, but, by what means can I access the returned value?

Bartman
Plugin Developer
Posts: 881
Joined: Sun Feb 12, 2006 9:03 am

Re: ffdshow

Post by Bartman » Sun Mar 21, 2010 5:22 pm

Totally forgot about the topic
with the change it works fine for me too and committed it to the svn

I have not looked into the other thing though. The eg.messageReceiver is probably the right thing to start

tEhHoLLoW
Posts: 2
Joined: Tue Jun 29, 2010 1:09 pm

Re: ffdshow

Post by tEhHoLLoW » Tue Jun 29, 2010 1:15 pm

I can't get this plugin to work. Everytime I want to use a command I get the same error message. "Application is not running!"

I installed many different Versions of ffdshow but nothing seems to work. Do I have to configure anything in the plugin like the path or so ?

User avatar
Luca Brasi
Experienced User
Posts: 262
Joined: Sat Oct 11, 2008 12:39 pm

Re: ffdshow

Post by Luca Brasi » Tue Jun 29, 2010 2:13 pm

Have you set up ffdshow like this:
Attachments
Screenshot - 2010-06-29 - 001.jpg
Win10 x64 Prof. / Eventghost latest / MCE Plugin / MCE RC6 Receiver / Logitech Harmony Hub / MediaPortal / kodi

Post Reply