I want to get video of an IP camera and stream it to another IP by libVLC. I write these codes based on examples of libvlc docs. The video streamed successfully and video showed without any problem in destination.But in my display, only first frame was shown. After some search I guessed this problem will be solve by adding RTP over TCP option. But after this change my problem didn't solve yet.
I use Microsoft visual C++ and my codes are:
#include <stdio.h>
#include <stdlib.h>
#include <vlc/vlc.h>
#include <Windows.h>
int main(int argc, char* argv[])
{
libvlc_instance_t * inst;
libvlc_media_player_t *mp;
libvlc_media_t *m;
char *myarg0 = "--sout=#transcode{vcodec=h264,scale=Auto,acodec=mpga,ab=128,channels=2,samplerate=44100}:duplicate{dst=display,dst=rtp{sdp=http://rtspdestinationIP:Port}}";
char *myarg1="--rtsp-tcp";
char *myargs[2] = {myarg1, myarg0};
/* Load the VLC engine */
inst = libvlc_new (2, myargs);
/* Create a new item */
char *input="http://user:pass@CameraIP//axis-cgi//mjpg//video.cgi";
m = libvlc_media_new_location (inst,input );
/* Create a media player playing environement */
mp = libvlc_media_player_new_from_media (m);
/* No need to keep the media now */
libvlc_media_release (m);
/* play the media_player */
libvlc_media_player_play (mp);
Sleep (10000000); /* Let it play a bit */
/* Stop playing */
libvlc_media_player_stop (mp);
/* Free the media_player */
libvlc_media_player_release (mp);
libvlc_release (inst);
return 0;
}
Aucun commentaire:
Enregistrer un commentaire