Premik / blender_rhubarb_lipsync_ng

Blender Rhubarb Lipsync is an addon for Blender integrating Rhubarb Lip Sync to automatically generate mouth-shape keyframes from a pose library.
MIT License
29 stars 1 forks source link

Not working with Rigs in Linked Libraries with proposed Fix #7

Closed KaijuKoder closed 11 months ago

KaijuKoder commented 1 year ago

Thanks for porting BlenderRhubarb to work under the new poselib-less system. I was about to do this myself, and lo and behold, you've already done it, and with improved usablity.

However I've found a problem. When the rig is Appended from the Asset Library, it works, but when it is linked-and-overriden (Linked from the Asset Library, then Make Override) it only gets as far as 'Initialize mapping list'. When I hit that button, I get this error message:

Traceback (most recent call last):
  File "C:\Users\guest\AppData\Roaming\Blender Foundation\Blender\3.6\scripts\addons\rhubarb_lipsync\blender\mapping_operators.py", line 36, in execute
    mprops.build_items(context.active_object)
  File "C:\Users\guest\AppData\Roaming\Blender Foundation\Blender\3.6\scripts\addons\rhubarb_lipsync\blender\mapping_properties.py", line 112, in build_items
    item: MappingItem = self.items.add()
TypeError: bpy_prop_collection.add(): not supported for this collection
Error: Python: Traceback (most recent call last):
  File "C:\Users\guest\AppData\Roaming\Blender Foundation\Blender\3.6\scripts\addons\rhubarb_lipsync\blender\mapping_operators.py", line 36, in execute
    mprops.build_items(context.active_object)
  File "C:\Users\guest\AppData\Roaming\Blender Foundation\Blender\3.6\scripts\addons\rhubarb_lipsync\blender\mapping_properties.py", line 112, in build_items
    item: MappingItem = self.items.add()
TypeError: bpy_prop_collection.add(): not supported for this collection

Here's the mapping_properties.py code in question, error line marked:

    def build_items(self, obj: bpy.types.Object) -> None:
        # log.trace("Already buil")  # type: ignore
        if len(self.items) > 0:
            return  # Already built (assume)
        log.trace("Building mapping list")  # type: ignore
        t1: NlaTrackRef = self.nla_track1
        t2: NlaTrackRef = self.nla_track2
        t1.object = obj
        t2.object = obj
        for msi in MouthShapeInfos.all():
            item: MappingItem = self.items.add() # <----- ERROR HERE
            item.key = msi.key

I used old-Blender-Rhubarb with linked-overriden rigs since 2.8 without any problems.

If you haven't used linked-overriden rigs before:

  1. Create a rig 'myrig' in a file mylib.blend
  2. Create a new .blend file, then File -> Link -> mylib.blend -> Objects -> myrig -> Link Button.
  3. Select myrig in outliner. Then right-click -> Library Override -> Make -> Selected
  4. myrig should now work like a normal rig.

    Searched around, and the problem seems to be this: "Library Override: can't add to Collection properties #82118" https://projects.blender.org/blender/blender/issues/82118 This seemed to fix it:

class MappingProperties(PropertyGroup):
    """Mapping of all the mouth shape types to action(s)"""

    items: CollectionProperty(type=MappingItem, name="Mapping items",
        options={'LIBRARY_EDITABLE'},
        override={'LIBRARY_OVERRIDABLE', 'USE_INSERTION'})
    ...

However found all the other properties in the 'RLPS: Cue Making and Baking' were greyed out. Found adding this to all the other properties - there are many - fixed it:

,
        options={'LIBRARY_EDITABLE'},
        override={'LIBRARY_OVERRIDABLE'}

After this, it seems to be working. Couldn't find any documentation on USE_INSERTION (Not alone! https://blender.stackexchange.com/questions/254730/what-is-the-safe-way-to-add-library-overridable-custom-properties ) but I assume it's something collection specific so not needed for the other properties?

Granted, making Addon authors add those lines after every Property seems a silly requirement which will break many addons, but could you please do that for Rhubarb NG so they at least work with it? I've attached the two files I modded (file extension renamed so Github is happy). Seems to work though you might prefer to make the changes yourself in case I accidentally broke something.

mapping_properties.py.txt strip_placement_properties.py.txt

Thanks for your effort.

Premik commented 1 year ago

Hi Kaiju, Thanks for reporting troubleshooting and finding fix for this issue :) I managed to reproduce the problem and apply your fix in the v1.0.0 release.

So now I can see the overrides in the Properties when I change value of any of the overridable-properties. So far so good. But each time I save the blend file all the overrides are gone and all the mapping properties of the Object got reset to the original values coming from the linked file. Actually similar thing is described at the very bottom of the /82118 issue you linked above. Is that something you faced too or is saving working for you just fine?

image After hitting ctrl+s all above is gone..

nizarfadlan commented 1 year ago

Hi Kaiju, Thanks for reporting troubleshooting and finding fix for this issue :) I managed to reproduce the problem and apply your fix in the v1.0.0 release.

So now I can see the overrides in the Properties when I change value of any of the overridable-properties. So far so good. But each time I save the blend file all the overrides are gone and all the mapping properties of the Object got reset to the original values coming from the linked file. Actually similar thing is described at the very bottom of the /82118 issue you linked above. Is that something you faced too or is saving working for you just fine?

image After hitting ctrl+s all above is gone..

Can languages other than English be used?

KaijuKoder commented 1 year ago

Hi Kaiju, Thanks for reporting troubleshooting and finding fix for this issue :) I managed to reproduce the problem and apply your fix in the v1.0.0 release.

So now I can see the overrides in the Properties when I change value of any of the overridable-properties. So far so good. But each time I save the blend file all the overrides are gone and all the mapping properties of the Object got reset to the original values coming from the linked file. Actually similar thing is described at the very bottom of the /82118 issue you linked above. Is that something you faced too or is saving working for you just fine?

image After hitting ctrl+s all above is gone..

Hi @Premik. Darn it! You are right! I didn't notice because when I tested it I did it all in one go, and once you've generated the animation, you're fine. But yes! If I save (ctrl-s), it strangely resets the overriden properties, except for the dropdowns (Mapping c/d/e/etc.), but when you reload the file it turns out they haven't been saved either. I can't think why it would do this. Your Blender Python skills are better than mine, but when MappingProperties is created, would it be possible to add the options={'LIBRARY_EDITABLE'}, override={'LIBRARY_OVERRIDABLE'} code as in the case of the other properties? It's also possible it should work as is and this is a bug or quirk of Overrides. See https://blender.community/c/rightclickselect/k795

@nizarfadlan, Yes, Rhubarb can do languages other than English. Use the other recognizer. See https://github.com/DanielSWolf/rhubarb-lip-sync#recognizers

Premik commented 1 year ago

@KaijuKoder

would it be possible to add the options={'LIBRARY_EDITABLE'}, override={'LIBRARY_OVERRIDABLE'} code as in the case of the other properties

Indeed more of these flags were required also for several PointerProperties. Just released the v1.0.1 where the overrides seems to stick. Only issue is with the Mapping Item List which still gets wiped out on reload. But for that there is a simple workaround. Just open the linked library file and initialize the mapping list there. If the linked object already has the list initialized from the library it is possible to set/override the Actions and they got saved correctly: image

ACMOIDRE commented 1 year ago

Do you guys made tutorial it really hard to work with this addon witout any video. I don't understand even after follow what is going wrong :(

ACMOIDRE commented 1 year ago

help me

Premik commented 11 months ago

Do you guys made tutorial it really hard to work with this addon witout any video. I don't understand even after follow what is going wrong :(

@ACMOIDRE There is now some video tutorial linked from the main readme: https://github.com/Premik/blender_rhubarb_lipsync_ng/tree/master#video-tutorials

KaijuKoder commented 10 months ago

Hi Premik,

Sorry for the long delay in replying! Just tested the latest version and it's (mostly!) working nicely!

  1. Just one problem (and not a major one) you already discussed:

EDIT: Turns out it is fine! Got confused because I'd accidently selected the character mesh instead of the character rig. When I selected the character rig, the mapping was there, all good!

  1. Nice to have: I found the Dialog File really helps Rhubarb to a better job, but the correspondng RLSP control not easy to find (in the dropdown next to the big 'Capture' button - I had to go code diving to find it). Would be nice if that control (where you set the Dialog File) was next to the Sound File, or better, when the code processed MySoundFile.wav it looked to see if there was a MySoundFile.txt file stored alongside it, and automatically picked that as the Dialog File. (i.e. 'Automatic Dialog File Detection').

  2. Wishlist for the future: I used to use a modded-version of the old Rhubarb addon which combed the VideoSequencer for sound files (named in such a way you could tell which rig/character it applied to), then automatically process these one by one, selecting the appropriate rig for each as it went. It let you do an entire scene, with multiple characters saying multiple lines to each other, with a single-button push. Perhaps the same thing would be possible with RLSP if there was a similar loop scanning the Video Sequencer, automatically selecting the sound setup and cues capture, mapping and baking, through the list.

  3. Seems lots of people want a video, but I had no problem with following your written instructions.

  4. Finally, where did you learn to write Blender/Python addons like this? IME most addons are mess internally, but yours is really nicely designed.

  5. Thanks. RLSP is awesome!

Premik commented 10 months ago
2. Nice to have: I found the Dialog File really helps Rhubarb to a better job, but the correspondng RLSP control not easy to find

I find myself struggling to find things is Blender all the time :-) . But I admit that it might not be obvious the down-arrow beside the Capture button is clickable. And you are actually not the first one looking for this dialog/transcription option. At the same time, I'm trying to avoid cluttering the UI too much by displaying oo many options simultaneously. For now:

3. Wishlist for the future: I used to use a modded-version of the old Rhubarb addon which combed the VideoSequencer for sound files (named in such a way you could tell which rig/character it applied to), then automatically process these one by one, selecting the appropriate rig for each as it went. It let you do an entire scene, with multiple characters saying multiple lines to each other, with a single-button push. Perhaps the same thing would be possible with RLSP if there was a similar loop scanning the Video Sequencer, automatically selecting the sound setup and cues capture, mapping and baking, through the list.

I've a created dedicated issue #10 to cover this request. If you could provide any additional details to that new ticket it would be helpful. Or even better provided/reference the original scripts. For example, how the script knows which sequence track/strip belongs to which rig? Is there some naming convention or registration process?

4. Seems lots of people want a video, but I had no problem with following your written instructions.

Indeed. And there a video tutorial linked directly from the main readme. I'd like to add more in the future to cover shape-keys and better auto-it integration (wip).

5. Finally, where did you learn to write Blender/Python addons like this? IME most addons are mess internally, but yours is really nicely designed.

Thank you. Yeah, this plugin is quite over-engineered for what it does :). I wanted to learn Blender plugin development so that was my motivation to do it properly. For me the best source of information were the existing plugins. Then Blender (python) sources and some samples snippets I found on internet. The python console in Blender and an IDE with debugger/auto completion also helps. I was putting some random dev-related notes into the dev.md along the way.