只有第一帧显示在RTSP流与libvlc



我想通过libVLC获得IP摄像机的视频并将其流式传输到另一个IP。我基于libvlc文档的示例编写这些代码。视频传输成功,视频在目的地显示无任何问题。但在我的展示中,只显示了第一帧。经过一番搜索,我猜这个问题将通过添加RTP over TCP选项来解决。但是在这个改变之后,我的问题仍然没有解决。

我使用Microsoft visual c++,我的代码是:

#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=rtsp://destinationIP: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;
 }

这是如何访问RTSP流与QT和LIBVLC,这是工作得很好!

libvlc_instance_t *_vlcinstance;
libvlc_media_player_t *_mp;
libvlc_media_t *_m;
const char * const vlc_args[] = {
       //   "--verbose=2", //be much more verbose then normal for debugging purpose
    "--network-caching=100",
};
//create a new libvlc instance
_vlcinstance=libvlc_new(sizeof(vlc_args) / sizeof(vlc_args[0]), vlc_args);  //tricky calculation of the char space used
// Create a media player playing environement
_mp = libvlc_media_player_new (_vlcinstance);

/* Create a new LibVLC media descriptor */
_m = libvlc_media_new_location(_vlcinstance, "rtsp://admin:admin@192.168.1.83:554/live0.264");
libvlc_media_player_set_media (_mp, _m);
/* Get our media instance to use our window */
int windid = ui->frame->winId();
libvlc_media_player_set_xwindow (_mp, windid );
/* Play */
libvlc_media_player_play (_mp);

其中"ui->frame"是目标对象,在我的应用程序中,它是一个简单的QFrame(但可以是一切)

要编译它,您需要#include并在项目设置LIBS += -lvlc

相关内容

  • 没有找到相关文章

最新更新