Awesome! That will save me some time. =) I just tested the function, and it works great.
void mlt_frame_write_ppm( mlt_frame frame )On Wed, Dec 22, 2010 at 10:22 PM, Dan Dennedy <firstname.lastname@example.org> wrote:
> On Wed, Dec 22, 2010 at 8:25 PM, Jonathan Thomas
> <email@example.com> wrote:
>> Do you have any code snippets or examples that I can use when debugging MLT
>> to save an image buffer to a file, so I can view what the image looks like
>> at various places inside MLT? For example, during filter processing (i.e.
>> the affine filter), image buffers are passed around and modified, and
>> debugging this kind of bug is quite tricky without seeing what is happening.
> Nothing exists now other than the consumers and carefully constructing
> melt commands. However, ppm is easy to write, and it would be possible
> to add a mlt_frame function to write a frame's image as ppm. You can
> see code for reading ppm in src/modules/core/producer_ppm.c.
mlt_image_format format = mlt_image_rgb24;
if ( mlt_frame_get_image( frame, &image, &format, &width, &height, 0 ) == 0 )
sprintf( filename, "frame-%05d.ppm", mlt_frame_get_position( frame ) );
file = fopen( filename, "wb" );
if ( !file )
fprintf( file, "P6\n%d %d\n255\n", width, height);
fwrite( image, width * height * 3, 1, file );
fclose( file );