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