// libvlcTutorial.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include "vlc/vlc.h" // vlc command line /* vlc -vvv --extraintf logger --logfile vlc_server.log dshow:// :dshow-vdev= :dshow-adev= :sout="#duplicate{dst=display, dst='transcode{vcodec=h264,vb=8,fps=30,width=320,height=240,scale=1,acodec=none} :rtp{dst=127.0.0.1,mux=ts,port=1234,caching=100}'}" */ int _tmain(int argc, _TCHAR* argv[]) { libvlc_instance_t * inst; libvlc_media_player_t *mp; libvlc_media_t *m; libvlc_log_t *log; /* Load the VLC engine */ inst = libvlc_new (0, NULL); // logging log = libvlc_log_open (inst); libvlc_set_log_verbosity (inst, 2); unsigned int level = libvlc_get_log_verbosity (inst); printf ("vlc log verbosity level = %d\n", level); /* Create a new item */ // m = libvlc_media_new_path (inst, "f:\\downloads\\sample.avi"); m = libvlc_media_new_path (inst, "dshow://// :dshow-vdev= :dshow-adev="); // media option const char *options[] = { ":no-audio", ":video-title-position=4", ":sout=#duplicate{dst=display,dst=\'transcode{venc=x264{profile=baseline},vcodec=h264,vb=10,width=320,height=240,fps=10,scale=1}:rtp{dst=127.0.0.1,port=1234,mux=ts}\'}", ":sout-udp-caching=1", ":sout-rtp-caching=1", ":sout-mux-caching=1", ":sout-ts-dts-delay=60" }; for (int i = 0; i < sizeof(options) / sizeof(options[0]); i++) libvlc_media_add_option (m, options[i]); /* 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); #if 0 /* This is a non working code that show how to hooks into a window, * if we have a window around */ libvlc_media_player_set_xdrawable (mp, xdrawable); /* or on windows */ libvlc_media_player_set_hwnd (mp, hwnd); /* or on mac os */ libvlc_media_player_set_nsobject (mp, view); #endif /* play the media_player */ libvlc_media_player_play (mp); while (!_kbhit()) Sleep (100); /* Let it play a bit */ /* Stop playing */ libvlc_media_player_stop (mp); /* Free the media_player */ libvlc_media_player_release (mp); libvlc_release (inst); printf ("message in log = %d\n", libvlc_log_count (log)); system("pause"); return 0; }