I am able to stream an rtsp on windows 7 64 bit machine through C# Winform application. This is the library i used - VLCDotNet and here is the code sample to play the RTSP stream:
LocationMedia media = new LocationMedia(#"rtsp://192.168.137.73:554/live.sdp");
vlcControl1.Media = media;
vlcControl1.Play();
I would like to store the streams to a file in my PC on a button click and stop the same with another button. How do i achieve this?
Here is the code:
Vlc.DotNet.Core.Medias.MediaBase media1
= new Vlc.DotNet.Core.Medias.PathMedia("rtsp://192.168.137.73:554/live.sdp");
media.AddOption(":sout=#transcode{vcodec=theo,vb=800,
scale=1,acodec=flac,ab=128,channels=2,samplerate=44100}:std{access=file,mux=ogg,
dst=D:\\123.mp4}");
VlcControl control = new VlcControl();
control.Media = media;
control.Play();
VlcContext.StartupOptions.IgnoreConfig = true;
VlcContext.StartupOptions.LogOptions.LogInFile = true;
VlcContext.StartupOptions.LogOptions.ShowLoggerConsole = true;
VlcContext.StartupOptions.LogOptions.Verbosity = VlcLogVerbosities.Debug;
// Disable showing the movie file name as an overlay
// VlcContext.StartupOptions.AddOption("--no-video-title-show");
// VlcContext.StartupOptions.AddOption("--no-audio");
VlcContext.StartupOptions.AddOption("--rtsp-tcp"); //this line was important to make this work
As of Vlc.DotNet.Core 2.1.62, The way to do this is use the extra opts param of the .Play on the vlc control.
var opts = new string[] { #":sout=file/ogg:C:\video.ogg" };
vlc.MediaPlayer.Play(new Uri(videoURI), opts);
`
Related
Why xamarin MediaPlayer (on Xamarin.Android) can play audio as a stream from a link like this (mediaUrl1) :
https://ia800806.us.archive.org/15/items/Mp3Playlist_555/AaronNeville-CrazyLove.mp3
But can't do it from a link like this (mediaUrl2):
http://api-streaming.youscribe.com/v1/products/2919465/documents/3214936/audio/stream
private MediaPlayer player;
//..
player = new MediaPlayer();
player.SetAudioStreamType(Stream.Music);
//..
await player.SetDataSourceAsync(ApplicationContext, Android.Net.Uri.Parse(mediaUrl));
//..
player.PrepareAsync();
//..
Is there a way to play the link above (mediaUrl2) without (of course) downloading the file first?
Here is the full source of the sample i am using. Any help would be appreciated.
http://api-streaming.youscribe.com/v1/products/2919465/documents/3214936/audio/stream
That is an HTTP mpga stream and is not directly supported by any of the Android APIs that I know of and thus is not supported by MediaPlayer (consult the Android Support Media Formats for further reading).
You can review the logcat output of your MediaPlayer code and you will see output like:
[MediaPlayerNative] start called in state 4, mPlayer(0x8efb7240)
[MediaPlayerNative] error (-38, 0)
[MediaPlayer] Error (-38,0)
[MediaHTTPConnection] readAt 1161613 / 32768 => java.net.ProtocolException
[MediaHTTPConnection] readAt 1161613 / 32768 => java.net.ProtocolException
[MediaPlayerNative] error (1, -2147483648)
[MediaPlayer] Error (1,-2147483648)
Google's Android ExoPlayer can stream that media format properly.
This is a really simple and very crude example of ExoPlayer, but it will show you that it does play that stream:
ExoPlayer Example:
var mediaUrl = "http://api-streaming.youscribe.com/v1/products/2919465/documents/3214936/audio/stream";
var mediaUri = Android.Net.Uri.Parse(mediaUrl);
var userAgent = Util.GetUserAgent(this, "ExoPlayerDemo");
var defaultHttpDataSourceFactory = new DefaultHttpDataSourceFactory(userAgent);
var defaultDataSourceFactory = new DefaultDataSourceFactory(this, null, defaultHttpDataSourceFactory);
var extractorMediaSource = new ExtractorMediaSource(mediaUri, defaultDataSourceFactory, new DefaultExtractorsFactory(), null, null);
var defaultBandwidthMeter = new DefaultBandwidthMeter();
var adaptiveTrackSelectionFactory = new AdaptiveTrackSelection.Factory(defaultBandwidthMeter);
var defaultTrackSelector = new DefaultTrackSelector(adaptiveTrackSelectionFactory);
exoPlayer = ExoPlayerFactory.NewSimpleInstance(this, defaultTrackSelector);
exoPlayer.Prepare(extractorMediaSource);
exoPlayer.PlayWhenReady = true;
Note: exoPlayer is a class-level variable of SimpleExoPlayer type
Note: this is using the Xamarin.Android binding libraries from the Xam.Plugins.Android.ExoPlayer package
ExoPlayer Docs:
https://developer.android.com/guide/topics/media/exoplayer
I'm using Websocket sharp (https://github.com/sta/websocket-sharp) for a console program, how do I output all debug/trace information that are displayed on the console to a text file?
For example:
using (var ws = new WebSocket(WebAddr))
{
ws.Log.Level = LogLevel.Debug;
ws.OnOpen += (ss, ee) =>
{
System.IO.File.WriteAllText(#"C:\log.txt", ws.Log.ToString());
};
But the output for this is "WebSocketSharp.Logger".
I would expecting something like this:
Screenshot
Set the property File:
using (var ws = new WebSocket(WebAddr))
{
ws.Log.Level = LogLevel.Debug;
ws.Log.File = #"C:\log.txt";
}
You will need to provide alot more information (which data?, how often? etc.) but you can use the System.IO.File methods for easy writing to a file;
// To create a new file
System.IO.File.WriteAllText(#"FileNameToWriteTo.txt", aString);
System.IO.File.WriteAllLines(#"FileNameToWriteTo.txt", listOfStrings);
// To add to the end of an existing file
System.IO.File.AppendAllText(#"FileNameToWriteTo.txt", aString);
System.IO.File.AppendAllLines(#"FileNameToWriteTo.txt", listOfStrings);
I'm trying to print labels with a dynamic content. The print works fine but the problem is that the printing itself (the font) is 90 degrees twisted. It looks like this:
But it should look like this:
I cannot change the settings of the printer because other labels do print correct. So I think it must be something in the code. You can watch the C# code here:
System.Drawing.Printing.PrinterSettings printerSettings = new System.Drawing.Printing.PrinterSettings();
printerSettings.PrinterName = #"\\server\printer";
printerSettings.Copies = Convert.ToInt16((Convert.ToInt16(row.Cells["Counter"].Value.ToString()) - 1));
System.Drawing.Printing.PrintController standardPrintController = new System.Drawing.Printing.StandardPrintController();
Telerik.Reporting.Processing.ReportProcessor reportProcessor = new Telerik.Reporting.Processing.ReportProcessor();
reportProcessor.PrintController = standardPrintController;
Telerik.Reporting.InstanceReportSource instanceReportSource = new Telerik.Reporting.InstanceReportSource();
instanceReportSource.ReportDocument = myReport;
reportProcessor.PrintReport(instanceReportSource, printerSettings);
Does anyone know such a problem or a possible solution?
Suggestion very appreciated :)
I've had the same problem once, but never used Telerik for anything. I was trying to print a XPS file with the PrintServer object, and came up with this solution to rotate the print.
Basicly I change the page orientation of the queue before I print for the user, and then change it back afterwards.
It might be usefull to you as well.
PrintServer ps = new PrintServer("\\\\somePrintServer");
var queue = ps.GetPrintQueue("printerShareName");
var oldOrientation = queue.UserPrintTicket.PageOrientation;
queue.UserPrintTicket.PageOrientation = PageOrientation.Landscape;
//print job here
queue.UserPrintTicket.PageOrientation = oldOrientation;
I use directx 9 to build model.
I want to save it to bmp file. I found the function D3DXSaveSurfaceToFile()
But I do not know how to use it in C#.
How can I use it?
Unfortunately, there is no such function in c#.
Try the following code instead:
try
{
// initialize D3D device
PresentParameters presentParams = new PresentParameters();
presentParams.Windowed = true;
presentParams.SwapEffect = SwapEffect.Discard;
Device myDevice = new
Device(0,DeviceType.Hardware,this,CreateFlags.SoftwareVertexProcessing,presentParams);
// create a surface the size of screen,
// format had to be A8R8G8B8, as the GetFrontBufferData returns
// only memory pool types allowed are Pool.Scratch or Pool.System memory
Surface mySurface =
myDevice.CreateOffscreenPlainSurface(SystemInformation.PrimaryMonitorSize.Width,SystemInformation.PrimaryMonitorSize.Height,Format.A8R8G8B8,Pool.SystemMemory);
//Get the front buffer.
myDevice.GetFrontBufferData(0,mySurface);
//saves surface to file
SurfaceLoader.Save("surface.bmp",ImageFileFormat.Bmp,mySurface);
}
catch
{
//whatever
}
I'm working with a motorolla MC55 which scans and beeps on a successful scan, I need to disable that feature so that it doesn't play any sounds at all on a scan.
Any ideas how I can accomplish this?
Scan the following barcodes to enable/disable the beep.
Try this:
Symbol.Barcode.Reader reader = new Symbol.Barcode.Reader();
// Other initialization
reader.Parameters.Feedback.Success.BeepTime = 0;
You may want to just adjust the level of the sound:
Symbol.Audio.Device MyDevice = (Symbol.Audio.Device)Symbol.StandardForms.SelectDevice.Select(
Symbol.Audio.Controller.Title,
Symbol.Audio.Device.AvailableDevices);
Symbol.Audio.StandardAudio MyAudioDevice = new Symbol.Audio.StandardAudio(MyDevice);
// set the volume of the audio from the settings file.
MyAudioDevice.BeeperVolume = NewLevel;
// set the audio device to nothing
MyAudioDevice.Dispose();
MyAudioDevice = null;
MyDevice = null;