I am trying to do a C# client application to stream video files to youtube, I found the following API:
https://developers.google.com/youtube/v3/live/getting-started
But I don't see any sample code to stream the video... I only find the sample code to create the object Stream and Broadcast and then binding them. But how do I stream the video? Is there any samples about that?
If there isn't examples of that, how can I stream a video given server URL like rtmp://a.rtmp.youtube.com/live2?
Related
Is there currently a NuGet package for Xamarin Forms that allows you to play videos from a System.Io.Stream object? I have played about with the MediaManager plugin but cannot get the player to work. I am using it in the shared project and also can't find a way to procedurally generate VideoViews in the codebehind (the docs only show how to add to Xaml and bind from the codebehind which isn't what i'm looking for)
A easy way is to save the web video link in the firebase and play it with url.
If you saved the stream in the firebase, you could read the stream and save it into storage to play it with file path.
MediaManager: https://github.com/Baseflow/XamarinMediaManager
If you read the stream from Firebase Database, you could google for the Xamarin.forms firebase realtime database. You would find a lot of samples.
After saving the stream into storage (I use Xamarin.Essentials.FileSystem.AppDataDirectory for example), you could play the video like below.
The path of Xamarin.Essentials.FileSystem.AppDataDirectory:
/data/user/0/Package name/files/
The code:
private async void play_Clicked(object sender, EventArgs e)
{
string filename = "video.mp4";
var path = Path.Combine(Xamarin.Essentials.FileSystem.AppDataDirectory, filename);
await CrossMediaManager.Current.Play(path);
}
I'm currently building a "video server", it has to be able to send videos over HTTP to the client which is using an HTML( tag) website.
I have this video tag on the website:
<video src="http://<?php echo $_SERVER['SERVER_ADDR']; ?>:8080/stream/0c73f95521d163257379e8ed37839e34" autoplay controls muted></video>
And this code on my server: (ctx is my HttpListenerContext)
string file = Directory.GetFiles(
contentDirectory,
ctx.Request.RawUrl.Substring(("/stream/").Length) + ".*",
SearchOption.AllDirectories)[0];
//Console.Log(ctx.Request.Headers.GetValues("Range")[0]);
byte[] data = File.ReadAllBytes(file);
ctx.Response.OutputStream.Write(data, 0, data.Length);
ctx.Response.OutputStream.Flush();
ctx.Response.OutputStream.Close();
I have been looking for a method that works but I haven't found any.
Basically what I'm trying to do is send video over HTTP from my C# program to my website (which is hosted on another web server).
Update:
I found this answer yesterday but didn't think I worked because I used an HttpListener, when I read it a bit closer I found that he used a TcpListener.
Handle range requests with HttpListener
I hope this might help someone else!
Thank you!
I have a bitmap or lets call it a file that I want to upload to my c# server, this bitmap (file) is captured via camera and saved into the sd card, but I have to no idea how exactly should I send it to my c# server. I don't know exactly what should I send in my request and what should be my server function's parameter to receive the file. Any help would be appreciated.
I've found this which shows how to send a file to server but it's using a php server side coding so I couldn't completely understand the process.
I'm not asking for code or anything, just a direction or explanation so I understand the concept. Thanks in advance
You need to do the following
Create a api call that will accept the file and store that file somewhere on the server.
You need to upload the image to the server with the help of the api call by passing the image file in it
Uploading image to server example
How do I send a file in Android from a mobile device to server using http?
Refer this for uploading with progress bar
Doesn't need to upload the images, just convert Image into Base64 an then upload this string to the specific field.
You can easily upload and retrieve images.
Before pushing it to server, convert your bitmap to string and push it using api. and the db field should be BLOB.after uploading the string should be converted back to bitmap and then image(This conversion should be written by api guy).
public String BitMapToString(Bitmap bitmap) {
ByteArrayOutputStream baos=new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG,100, baos);
byte [] b=baos.toByteArray();
String temp=Base64.encodeToString(b, Base64.DEFAULT);
return temp;
}
I am using VLC plugin to run an rtsp stream. The stream works good. But I want to store these videos to a file destination. I use this code but does not work.
axVLCPlugin21.playlist.add("rtsp://192.168.10.222:554/h264", null, ":sout=#transcode{vcodec=theo,vb=800,acodec=flac,ab=128,channels=2,samplerate=44100}:file{dst=C:\\123.ogg,no-overwrite} :sout-keep");
axVLCPlugin21.playlist.play();
This code only plays the rtsp stream but does not store. However, the same options can be used to stream directly on the VLC player.
Try using this Option for Storing Videos and displaying videos simultaneously
original commad to play in vlc
%vlc path% vlc.exe -vvv rtsp://192.168.10.22:554/h264 :sout=#transcode{vcodec=theo,vb=800,acodec=flac,ab=128,channels=2,samplerate=44100}:duplicate{dst=file{dst=C:\\\\123.mp4},dst=display}:sout-keep
if this works try to use
:sout=#transcode{vcodec=theo,vb=800,acodec=flac,ab=128,channels=2,samplerate=44100}:duplicate{dst=file{dst=C:\\\\123.mp4},dst=display}:sout-keep
":sout=#transcode{vcodec=theo,vb=800,acodec=flac,ab=128,channels=2,samplerate=44100}:file{dst=C:\123.ogg,no-overwrite} :sout-keep
also try to work in VLC gui by using streaming option+displaylocally+dst=file
Refrence:HowTo Receive and Save a Stream
VLC does not support recording of streams via plugin. Check this Link
I got a work around for it. I record the stream by calling the VLC directly. However, the player is hidden. I use this code:
Process.Start("C://Program Files//Videolan//VLC//VLC.exe","\"rtsp://xxx.xxx.xxx.xxx:554/h264\" --qt-start-minimized --sout=#transcode{vcodec=theo,vb=800,acodec=flac,ab=128,channels=2,samplerate=44100}:file{dst=C:\\123.ogg,no-overwrite}");
i have been trying to play some sound(.wav) from a website link on windows phone 7 using the media element.
MediaElement mediaElement = new MediaElement();
mediaElement.source = new uri("http://api.microsofttranslator.com%2fwav");
mediaElement.play();
doesnt do anything.
i tried implementing handlers or even try to use the Webclient class to download the stream and play it but it has the same problem i dont hear anything.
and also i copied the uri to the browser and it played the wave i needed.
If you want to use Microsoft Translator, you can add a Service Reference to the API SOAP service. The Service Client exposes the SpeakAsync method which will return the URL of the WAV file. You can then use your WebClient or HttpWebRequest to download the stream and play it. There's example code in this blog post.