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.
    http://www.plugincafe.com/forum/forum_posts.asp?TID=10877
    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?


  • Global Moderator

    Hello,

    unfortunately there is an issue in Cinema 4D R19 with setting the value of RDATA_SAVEOPTIONS. See [Render settings] File format Options R19

    It is only possible to set these values in R20 and using GetImageSettingsDictionary() / SetImageSettingsDictionary().

    Also, QuickTime isn't supported on Windows for a while now. It is only available on macOS.

    best wishes,
    Sebastian



  • @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/Cinema4DCPPSDK/html/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.


  • Global Moderator

    Hi dmp,

    You can find an example about GetImageSettingsDictionary() / SetImageSettingsDictionary() with OpenExr in the imagesettingsdictionary.py example.

    In order to find the correct maxon.InternedId you have to browse the C++ documentation MEDIASESSION.

    Note also it makes usage of the Maxon API which is for the moment not documented. So if you have any questions, please let me know!

    Cheers,
    Maxime.



  • @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/Cinema4DCPPSDK/html/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/Cinema4DCPPSDK/html/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.


  • Global Moderator

    Hi @dmp, sadly as you already figurate out datarate want a BytesValue, which is not yet implemented in the maxon API (as it's been said, currently the python maxon API is still on progress and they are some flaws or missings class like this one, which will be fixed in futures release).
    And I'm afraid there is no workaround for it except switching to C++.

    With that said. For all other parameters, maxon API also introduces some new types like maxon.Int (which point to maxon.Int64 if available or maxon.Int32).
    According your issue with custom samplerate and audio kilobitrate, only few values are accepted.

    MAXON_ATTRIBUTE(Int, AUDIO_SAMPLERATE, "net.maxon.mediasession.mf.export.audio.samplerate",
    	RESOURCE_DEFINE(ENUM_32000, 32000)
    	RESOURCE_DEFINE(ENUM_44100, 44100)
    	RESOURCE_DEFINE(ENUM_48000, 48000));
    
    MAXON_ATTRIBUTE(Int, AUDIO_KILOBITRATE, "net.maxon.mediasession.mf.export.audio.kilobitrate",
    	RESOURCE_DEFINE(ENUM_96, 96)
    	RESOURCE_DEFINE(ENUM_112, 112)
    	RESOURCE_DEFINE(ENUM_128, 128)
    	RESOURCE_DEFINE(ENUM_160, 160)
    	RESOURCE_DEFINE(ENUM_192, 192)
    	RESOURCE_DEFINE(ENUM_224, 224)
    	RESOURCE_DEFINE(ENUM_256, 256)
    	RESOURCE_DEFINE(ENUM_320, 320));
    

    If you have any question left, please let me know.
    Cheers,
    Maxime.