Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login
    1. Maxon Developers Forum
    2. dmp
    3. Posts
    D
    • Profile
    • Following 0
    • Followers 0
    • Topics 2
    • Posts 6
    • Best 0
    • Controversial 0
    • Groups 0

    Posts made by dmp

    • RE: Setting Quicktime Options

      @m_adam said in Setting Quicktime Options:

      MEDIASESSION

      Awesome! Thanks for your help. I got pretty far in coding the Quicktime settings. But there are a few settings that I am having trouble with. (Datarate, Audio Samplerate and Audio Bitrate)

      import c4d
      from c4d import bitmaps
      import maxon
      
      def main():
          
          QUICKTIME_FORMAT_NUMBER = 1073784596
      
          # Retrieves render data and its container
          renderData = doc.GetActiveRenderData()
          bc = renderData.GetDataInstance()
      
          # Gets image filters options
          saveOptions = bc.GetContainerInstance(c4d.RDATA_SAVEOPTIONS)
      
          # Sets Quicktime Mov output format
          bc[c4d.RDATA_FORMAT] = QUICKTIME_FORMAT_NUMBER # c4d.FILTER_MOVIE sets format to mp4 not mov, so I used the call command instead
      
          # Defines Quicktime settings
          compressionmethodID = maxon.InternedId('net.maxon.mediasession.mf.export.codec')
          datarateID = maxon.InternedId('net.maxon.mediasession.export.datarate')  # Problems here needs BytesValue
          keyframesID = maxon.InternedId('net.maxon.mediasession.export.keyframes')  # Asks for Int32 and works
          audiocodecID = maxon.InternedId('net.maxon.mediasession.mf.export.audio.codec')
          audiosamplerateID = maxon.InternedId('net.maxon.mediasession.mf.export.audio.samplerate')  # Problems here asks for Int but doesn't like it'
          audiobitrateID = maxon.InternedId('net.maxon.mediasession.mf.export.audio.kilobitrate')  # Problems here asks for Int but doesn't like it'
          
      
          # Configures Quicktime format options with a maxon.DataDictionary
          exportSettings = maxon.DataDictionary()
          exportSettings.Set(compressionmethodID, maxon.Id("H.264"))  # works
          
          exportSettings.Set(datarateID, 2)  # does not work
          exportSettings.Set(keyframesID, 2)  # works
           
          exportSettings.Set(audiocodecID, maxon.Id("mp3")) # works
          
          exportSettings.Set(audiosamplerateID, 96) # does not work (adds new fake setting)
          
          exportSettings.Set(audiobitrateID, 320) # does not work (adds new fake setting, notice no kBit)
          
          # Stores settings in render data container
          bitmaps.SetImageSettingsDictionary(exportSettings, saveOptions, QUICKTIME_FORMAT_NUMBER)
      
          # Updates Cinema 4D
          c4d.EventAdd()
      
      if __name__=='__main__':
          main()
      

      Datarate, Audio Samplerate and Audio Bitrate are not being set.

      Keyframes, which asks for an Int32, does get set successfully.

      Datarate asks for BytesValue. I can't figure this out. What is a BytesValue, what does it look like in python, and do I need to import it?
      https://developers.maxon.net/docs/cpp/2023_2/namespacemaxon_1_1_m_e_d_i_a_s_e_s_s_i_o_n_1_1_e_x_p_o_r_t.html

      Audio Samplerate and Audio Bitrate ask for an int. I include an int, but it doesn't work. It actually adds a new fake value to the bottom of the pull down which is not correct. How is this different than an Int32?
      https://developers.maxon.net/docs/cpp/2023_2/namespacemaxon_1_1_m_e_d_i_a_s_e_s_s_i_o_n_1_1_m_f_1_1_e_x_p_o_r_t.html

      Thanks for your help.

      posted in Cinema 4D SDK
      D
      dmp
    • RE: Setting Quicktime Options

      @s_bach said in Setting Quicktime Options:

      GetImageSettingsDictionary()

      Ok. R20 is fine. Could I see a code example for SetImageSettingsDictionary() in python?

      I've tried to follow the C++ code example:
      https://developers.maxon.net/docs/cpp/2023_2/page_manual_renderdata.html
      But I can't seem to create a DataDictionary in python. And there is no information on them in python.

      And I don't know what the settings are called.
      The standard "drag attribute to console" gets me:
      foo[1852142638,1835104367,1848536421,1684627827,1702065001,1869491823,1885695589,2020748901,2020634482,1949198433,1818650220,1868657664,c4d.MEDIASESSION_PROPS_NET_MAXON_MEDIASESSION_OPENEXR_EXPORT_HALFFLOAT]

      Ultimately I'm mainly interested in setting the Quicktime or Avi settings. But would be happy to get the EXR working as a start.

      Thank you.

      posted in Cinema 4D SDK
      D
      dmp
    • Setting Quicktime Options

      How do you set Quicktime options. (like ProRes, h264, data rate, etc.)

      I've tried using this older code with EXRs. But it doesn't seem to work for EXRs anymore.

      import c4d
      rd = doc.GetActiveRenderData()
      container = rd.GetData()
      
      # OpenEXR
      container[c4d.RDATA_FORMAT] = c4d.FILTER_EXR
      
      saveOptions = container.GetContainerInstance(c4d.RDATA_SAVEOPTIONS)
      
      # OpenEXR options
      bc = c4d.BaseContainer()
      bc[0] = 3 # ZIP
      bc[1] = True # clamp to half float
      
      # save OpenEXR options
      saveOptions.SetContainer(0,bc)
      
      # save render data
      rd.SetData(container)
      
      c4d.EventAdd()
      

      The above doesn't set the zip or half float.

      I've also looked into using the MovieSaver class.
      https://developers.maxon.net/forum/topic/8337
      But still couldn't get where I needed to go. The code in that post also didn't seem to work.

      How do I set the Quicktime options with Python?

      posted in Cinema 4D SDK python r19
      D
      dmp
    • RE: RemoveUserData does not fully remove User Data

      This worked. Thank you.

      posted in Cinema 4D SDK
      D
      dmp
    • RE: RemoveUserData does not fully remove User Data

      Here's a simple test to run in the script editor:
      Add a Cube to the scene.

      import c4d
      current_doc = c4d.documents.GetActiveDocument()  
      cube = current_doc.SearchObject('Cube')
      
      def AddStringDataType(obj):
        if obj is None: return
      
        bc = c4d.GetCustomDataTypeDefault(c4d.DTYPE_STRING) 
        bc[c4d.DESC_NAME] = "String"           
      
        element = obj.AddUserData(bc)  
        obj[element] = 'bob'       
        c4d.EventAdd()             
        
      def AddFloatDataType(obj):
        if obj is None: return
        bc = c4d.GetCustomDataTypeDefault(c4d.DTYPE_REAL)
        bc[c4d.DESC_NAME] = "Float"
        element = obj.AddUserData(bc)
        obj[element] = 22.2
        c4d.EventAdd()
        
      AddStringDataType(cube)
      cube.RemoveUserData(1)
      AddFloatDataType(cube)
      
      posted in Cinema 4D SDK
      D
      dmp
    • RemoveUserData does not fully remove User Data

      If I add a string field with AddUserData.
      And then I delete that string field with DeleteUserData.
      And then try to add a float field with AddUser Data:
      I get
      TypeError: setitem expected str, not float
      And if I try to get the value before EventAdd, I get the old, deleted value

      Anyone know any workarounds? Like how to flush the memory of the user data?

      posted in Cinema 4D SDK python
      D
      dmp