Getting Codec Info with MovieSaver Choose [SOLVED]
-
On 02/12/2014 at 15:46, xxxxxxxx wrote:
I'm trying to save out a Quicktime movie with the H.264 codec. I'd like to set the codec in my code without user-intervention. My first thought was to use MovieSaver.Choose() to manually pick the settings I want, and then work out what's being stored in the container so that I automatically choose those setting in my movie saver.
However, when I try to run this
example code
[URL-REMOVED] from the docs as a script:"""Print Codec Container Prints the container for the codec the user selects. """ import c4d from c4d import gui #Welcome to the world of Python def main() : ms = c4d.bitmaps.MovieSaver() data = c4d.BaseContainer() action = ms.Choose(c4d.FILTER_MOVIE, data) if action == False: return #is True if the user canceled the dialog print data if __name__=='__main__': main()
I get the following error:
"IOError: movie saver object is not open yet."Any thoughts on how to open the MovieSaver without valid codec info?
[URL-REMOVED] @maxon: This section contained a non-resolving link which has been removed.
-
On 02/12/2014 at 16:22, xxxxxxxx wrote:
Okay, I've answered my own question. Feel free to use any of the code you like below:
"""Print Compression Container Prompts user to select Quicktime compression settings, then prints the container for the codec the user selects. If you want to get compression settings for an AVI adjust the file_type variable in USER INPUT section. """ #IMPORTS import c4d from c4d import gui #USER INPUT file_type = c4d.FILTER_MOVIE #Use c4d.FILTER_AVI if you'd prefer not to use QuickTime' #UTILS def print_compression_container(bc) : """Print the contents of a MovieSaver compression container `bc` in such a way that you can recreate the container using the printed statements.""" codec_ids = { c4d.AVISAVER_FCCTYPE: "c4d.AVISAVER_FCCTYPE", c4d.AVISAVER_FCCHANDLER: "c4d.AVISAVER_FCCHANDLER", c4d.AVISAVER_LKEY: "c4d.AVISAVER_LKEY", c4d.AVISAVER_LDATARATE: "c4d.AVISAVER_LDATARATE", c4d.AVISAVER_LQ: "c4d.AVISAVER_LQ", c4d.QTSAVER_COMPRESSOR: "c4d.QTSAVER_COMPRESSOR", c4d.QTSAVER_QUALITY: "c4d.QTSAVER_QUALITY", c4d.QTSAVER_TEMPQUAL: "c4d.QTSAVER_TEMPQUAL", c4d.QTSAVER_FRAMERATE: "c4d.QTSAVER_FRAMERATE", c4d.QTSAVER_KEYFRAMES: "c4d.QTSAVER_KEYFRAMES", c4d.QTSAVER_PLANES: "c4d.QTSAVER_PLANES", c4d.QTSAVER_DATARATE: "c4d.QTSAVER_DATARATE", c4d.QTSAVER_FRAMEDURATION: "c4d.QTSAVER_FRAMEDURATION", c4d.QTSAVER_MINQUALITY: "c4d.QTSAVER_MINQUALITY", c4d.QTSAVER_MINTEMPQUAL: "c4d.QTSAVER_MINTEMPQUAL", c4d.QTSAVER_FIXEDFRAMERATE: "c4d.QTSAVER_FIXEDFRAMERATE" } print "To recreate %s use:" % (str(bc),) print "compression_bc = c4d.BaseContainer()" for index, value in bc: id = "" if index in codec_ids: id = codec_ids[index] print "compression_bc[%s] = %s" % (id, str(value)) else: print "compression_bc[%s] = %s" % (str(index), str(value)) def main() : """Get user input & print to screen. """ # get target path path = c4d.storage.SaveDialog(title="Save preview") # get render data doc = c4d.documents.GetActiveDocument() rd = doc.GetActiveRenderData().GetData() # prepare bitmap xres = int(rd[c4d.RDATA_XRES]) yres = int(rd[c4d.RDATA_YRES]) bmp = c4d.bitmaps.BaseBitmap() bmp.Init(x=xres, y=yres, depth=24) #Try to create a movie saver ms = c4d.bitmaps.MovieSaver() compression_container = c4d.BaseContainer() fps = 30 ms.Open(path, bmp, fps, file_type, compression_container, c4d.SAVEBIT_0) #Use the MovieSaver to retrieve the codec info action = ms.Choose(file_type, compression_container) if action == False: return #is True if the user canceled the dialog print_compression_container(compression_container) if __name__=='__main__': main()
And for those looking to create an H.264 @ medium quality, use:
To recreate <c4d.BaseContainer object at 0x126855500> use: compression_bc = c4d.BaseContainer() compression_bc[c4d.QTSAVER_COMPRESSOR] = 1635148593 compression_bc[c4d.QTSAVER_PLANES] = 24 compression_bc[c4d.QTSAVER_QUALITY] = 512 compression_bc[c4d.QTSAVER_FRAMERATE] = 30 compression_bc[c4d.QTSAVER_FIXEDFRAMERATE] = 1966080 compression_bc[c4d.QTSAVER_TEMPQUAL] = 511 compression_bc[c4d.QTSAVER_KEYFRAMES] = 30 compression_bc[c4d.QTSAVER_DATARATE] = 0 compression_bc[c4d.QTSAVER_FRAMEDURATION] = 83 compression_bc[c4d.QTSAVER_MINQUALITY] = 256 compression_bc[c4d.QTSAVER_MINTEMPQUAL] = 256
-
On 13/05/2016 at 08:43, xxxxxxxx wrote:
Hi,
I know this is quite an old thread. But my question fits in here quite well.
What I'm trying to do is to create a script that sets the Quicktime Movie options for me, so that I won't have to do that every time.
I already got the options working for openEXR by using the following script, thanks to S_Bach:
>
> 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()But I can't seem to convert this method for a c4d.FILTER_MOVIE
My scripting knowledge is probably to blame, because I've got the feeling the answer is somewhere in this posts above.Hope someone can help me out.
Cheers,
Bas
-
On 23/05/2016 at 00:57, xxxxxxxx wrote:
Hello,
if you want to configure and obtain a properly set up settings container for the Quick Time format you can use the MovieSaver class to obtain the information as shown above. The setting IDs are also defined here.
That BaseContainer containing the Quick Time settings has to be merged with the RDATA_SAVEOPTIONS container instance.
Best wishes,
Sebastian