Has anyone a sample of saving video with libVLC from a remote camera?
It would be interesting too, capture video from a local camera to a file.
thanks in advanced.
Advanced samples with LIBVLC?
-
- Posts: 64
- Joined: Jul 15, 2009 12:41
-
- Posts: 64
- Joined: Jul 15, 2009 12:41
I proved introduce remote stream but...
Like no one that knows about vlc is near, I proved introduce remote stream and a marquee, but the marquee seems that don't works.
It would be interesting to save the stream as it is played....?
Must of the code is taken from a previous post in the forum.
It would be interesting to save the stream as it is played....?
Must of the code is taken from a previous post in the forum.
Code: Select all
#include once "vlc/vlc.bi"
#LibPath "c:\videos"
function lockCB cdecl (byval image as any ptr, byval pPlanes as any ptr ptr) as any ptr
if (image=0) then ' we use the the FBGFX screen as target so we must lock it
screenlock : pPlanes[0]=screenptr() ' get the address of the screen pixel buffer
else ' we use any RGB image get the address of the pixel buffer
Imageinfo(image,,,,,pPlanes[0])
end if
return 0
end function
sub unlockCB cdecl (byval image as any ptr, byval pPicture as any ptr, byval pPlanes as any const ptr ptr)
if (image=0) then screenunlock ' if we use the FBGFX screen we must unlock it
end sub
sub displayCB cdecl (byval image as any ptr, byval pPicture as any ptr)
' if we use the screen all rendering are done and we can go out here
if (image=0) then return
' use the decoded image for what ever here I blit on screen
put (0,0),image,PSET
end sub
'
' main
'
'dim as zstring ptr VIDEO = @"c:\videos\video4.mp4"
dim as zstring ptr VIDEO = @"http://207.210.131.138/mjpg/video.mjpg"
dim as any ptr image
' make it the current path
chdir exepath()
const SCR_W = 1280
const SCR_H = 800
screenres SCR_W,SCR_H,32
' we use an image here (if you comment it out the screen will be used)
image=imagecreate(SCR_W\4, SCR_H\4)
dim as integer frameW,frameH,frameP
if image=0 then ' we use the screen
screeninfo frameW,frameH,,,frameP
else ' we use an image
imageinfo image,frameW,frameH,,frameP
end if
var instance = libvlc_new (0,NULL)
'var media = libvlc_media_new_path(instance, VIDEO)
var media = libvlc_media_new_location(instance, VIDEO)
var player = libvlc_media_player_new_from_media(media)
libvlc_media_release(media)
'libvlc_video_set_format(player,@"BGRA", frameW, frameH, frameP)
'libvlc_video_set_format(player,@"RV32", frameW, frameH, frameP)
'libvlc_video_set_callbacks(player, @lockCB, @unlockCB, @displayCB, image)
' start the video/audio decoder stream
var result = libvlc_media_player_play(player)
if (result<>0) then
print "error: play ! ..."
libvlc_media_player_release(player)
libvlc_release(instance)
beep : sleep : end 2
end If
' throw up a marquee
libvlc_video_set_marquee_int(player, libvlc_marquee_Enable, 1)
libvlc_video_set_marquee_string(player, libvlc_marquee_Text, "Hello- Marquee")
libvlc_video_set_marquee_int(player, libvlc_marquee_Opacity, 50)
libvlc_video_set_marquee_int(player, libvlc_marquee_X, 50)
libvlc_video_set_marquee_int(player, libvlc_marquee_Y, 50)
libvlc_video_set_marquee_int(player, libvlc_marquee_Timeout, 4000) ' 4 secs
libvlc_video_set_marquee_int(player, libvlc_marquee_Size, 180)
libvlc_video_set_marquee_int(player, libvlc_marquee_Color, &h00FF0000)
print "decoding video/audio stream ..."
libvlc_audio_set_volume(player,80)
dim as libvlc_state_t PlayerState
while (inkey()="") and (PlayerState<>libvlc_Ended)
PlayerState = libvlc_media_player_get_state(player)
sleep 100
wend
if (PlayerState<>libvlc_Ended) then libvlc_media_player_stop(player) : sleep 500,1
libvlc_media_player_release(player)
libvlc_release(instance)