Hello all.
I wrote an mlt-based video editor that is working quite
well. Now,
I am trying to write a program to extract thumbnails from a
video clip,
but nothing works as expected... and it is strange because
I am
using the same code snippets of the previous (video editor)
program.
I am getting crazy because there must be something I am
overlooking,
but the code is so simple, I don't know what else to try
or debug.
The code is in pascal, but should be similar enough to C to
be
understandable:
------------------------------------------
mltrepo := mlt_factory_init(''); // <- parameter=empty string
mltprofile := mlt_profile_init('');
consumer := mlt_factory_consumer
(mltprofile, 'sdl2', '320x240');
mlt_properties_set_int
(mlt_consumer_properties(consumer), 'audio_off', 1);
//
mlt_properties_set_int(mlt_consumer_properties(consumer), 'real_time',
1);
// mlt_properties_save(mlt_consumer_properties(consumer),
'/tmp/tbe_consfirst.txt');
producer := mlt_factory_producer
(mltprofile, 'avformat', thefilename);
// reopen to make mlt read
always the correct length (?)
mlt_profile_from_producer(mltprofile,
producer);
mlt_producer_close(producer);
producer :=
mlt_factory_producer(mltprofile, 'avformat', thefilename);
duration :
= mlt_properties_get_int(mlt_producer_properties(producer), 'length');
mlt_consumer_connect(consumer, mlt_producer_service(producer));
mlt_consumer_start(consumer);
------------------------------------------
By executing the code
above, an SDL window opens and the first frame
of the video shows up. I
have a trackbar (widget) which does the
following:
mlt_producer_seek
(producer, tbPos.Position);
By moving the tbPos cursor, the correct
seeks are made and the SDL window correctly and quickly shows the right
video frames.
But if I, instead, execute the following line:
mlt_producer_set_speed(producer, 1);
the video does not play and the
trackbar tbPos ceases to work.
I have another problem. What I really
want is not to play the video,
but to extract a thumbnail after a seek
is done. The code is:
------------------------------------------
srv := mlt_producer_service(producer);
mlt_producer_seek(producer,
tbPos.Position);
frame := NIL; // it seems better to clear frame to
NULL
if mlt_service_get_frame(srv, frame, 0)=0 then begin
image :
= NIL;
if mlt_frame_get_image(frame, @image, @iformat, @iwidth,
@iheigth, 0)=0 then begin
framenum := mlt_properties_get_int
(mlt_frame_properties(frame), '_position');
case iformat of
mlt_image_yuv422: ... (not implemented yet: extract from
yuv422)
mlt_image_rgb24: ... (not implemented yet: extract
from rgb24)
end;
// mlt_frame_close(frame); // closing the
frame seems worse than not doing it
end
------------------------------------------
If, after a seek(), I try
to get the image with the above code, I obtain
the correct iformat,
iwidth and iheight, but the SDL window stops to work.
The frame remains
untouched.
I am forgetting something? The same chunks of code posted
here work
quite well in my other program, the video editor, included
the routines
which extract audio and images frame by frame.
Thank you
and regards,
linuxfan
_______________________________________________
Mlt-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mlt-devel