Now my method is:
libvlc_video_set_callbacks //set the lock,unlock,display callback functions
libvlc_media_player_set_position //goto the snap time
libvlc_media_player_play //start playing
then in unlock callback function invoke 'libvlc_media_player_stop'
to stop the play, and save the data which provider by display callback function.
This method had succeeded some times, but more times it will take my whole program crash.
I know it looks a bit stupid, but I cannot found any frame by frame control function in the libvlc
include files.
Actually, the libvlc
has a really poor handling of frame by frame since it is not the way it handles streams. Therefore, frame by frame - when there is some - is quite hacky and can be rather ugly. Going forward or backward one frame is often achieved by computing the length between two frames, and jumping to the corresponding datetime.
The only frame-related function in the library is libvlc_media_player_next_frame
which seems to be conditionally supported and it also seems that some development is being done to later support libvlc_media_player_previous_frame
.
Therefore, your method is probably as fine as any other would be. An alternative would be to replace libvlc_media_player_set_position
by libvlc_media_player_set_time
if you want to be able to set your time to the wanted millisecond. Yet another one would be to slow the playback down before snapping. None of these methods is really efficient though, but there does not seem to be any cleaner way to do so.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With