Stream from frames in YUV422

Topics: Question
Mar 13, 2015 at 8:29 PM
Hello,

I have a capture card that provides frames in YUV422 format. Is it possible to create a stream server using you library and pass this type of frames as a source.

Thanks,
Mikhail
Coordinator
Mar 13, 2015 at 8:35 PM
Edited Mar 13, 2015 at 8:36 PM
Sure is.

Raw format or uncompressed isn't really implemented but is documented, would only need a small amount of work to support both packetization and depacketization.

I plan on adding more support for this once I get the rest of the image and audio classes up.

In short you can do this jpeg is acceptable as an output, the rfc 2435 class supports any format via Image.

Soon I'll have my own image classes and the ability to support more formats across all platforms.
Marked as answer by juliusfriedman on 3/13/2015 at 1:35 PM
Mar 15, 2015 at 1:54 PM
Thank for answer.

I read your article (http://www.codeproject.com/Articles/507218/Managed-Media-Aggregation-using-Rtsp-and-Rtp) it looks very impressive.

Could you please give me some hints on how to use your library?

I downloaded source code and I am able to compile the most part of it. Having issues only with test project.
.... net7mma-sln\Tests\Program.cs(80,32,80,54): error CS0117: 'RtpClientUnitTests' does not contain a definition for 'TestInterleavedFraming'
.... net7mma-sln\Tests\Code\RtpClientUnitTests.cs(193,25,193,32): error CS1061: 'Media.Rtp.RtpClient' does not contain a definition for 'Connect' and no extension method 'Connect' accepting a first argument of type 'Media.Rtp.RtpClient' could be found (are you missing a using directive or an assembly reference?)

I suppose I can ignore these issues for now.

Using the code examples from codeproject's article I create RTSP server but VLC is not able to connect. I tried to change endpoint but with no success. Do you have any working examples that you could share ?
Coordinator
Mar 15, 2015 at 2:19 PM
What release are you using? I would use the Container Release, as the Alpha release for Formats may have some quirks as I am re-factoring the API, it will be stable eventually.

The errors you cite I don't get when I build either the Container or Formats release, make sure your using .Net 4.5.2.

I am revising the unit tests into a new format and they will be redone soon anyway.

I am not sure what you mean that you couldn't change the end point, is that in the RtspServer? why couldn't you? It's passed to the constructor when creating a RtspServer.

The examples in the UnitTests folder should work fine, there is a TestRtspServer which does indeed work with any player.

Please note VLC uses live 555 for some things and ffmpeg for others, both of which have bugs related to RTSP that my server and client doesn't, with that being said I have worked around them previously and I will ensure that when the Formats release is stable that there is no such issue, in the mean time use Container.

It would also help to know what protocol your using in the player (I imagine TCP) UDP seems to have less issues so you may consider trying that protocol and additionally reporting the issue to the VLC or LIVAB or FFMPEG teams. (As you will notice from looking at the Codec Information in VLC, the player is receiving data from my server, what it's doing with it is another question ...)

Let me know if you need anything else!
Marked as answer by juliusfriedman on 3/15/2015 at 7:19 AM
Mar 15, 2015 at 2:42 PM
What release are you using?
I went to SOURCE CODE on your codeplex page and pressed Download. This gave me an archive with code sources that I unzipped and then opennd media.sln with Visual Studio. I have DotNet v 4.5.0.

I am not sure what you mean that you couldn't change the end point, is that in the RtspServer?
My bad. It looks like I did not explain correctly. I wanted to say that VLC is not able to connect to server. I changed endpoint settings in the RtspServer but VLC keeps saying that is not able to connect.

__It would also help to know what protocol your using in the
Not sure if I understand your question correctly. On VLC side I just setup connection to network stream. (Media -> Open Network Stream and provide network URL.. in my case on server side I have :
RtspServer server = new RtspServer(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 8888));

so in VLC : rtsp://127.0.0.1:8888
)

I'll try to look into your tests to find what I need. My final goal is to stream frames from my capture card and receive them in client.
Mar 15, 2015 at 3:53 PM
To give you an idea on what is happening.

I took some code from your test project and created command line application. Please see code below.

Executing this code gives me next result
Pics in folder :10
Server UDP enabled False
Rtp / Udp Test Failed: Unable to get options, See InnerException.
InnerException : See Tag for Response.
What I am doing wrong ?
using System;
using System.IO;
using System.Linq;
using System.Net;
using System.Threading;
using System.Threading.Tasks;
using Media.Rtsp;
using Media.Rtsp.Server.MediaTypes;

namespace RSPServerTest
{
    class Program
    {
        static void Main(string[] args)
        {
            RtspServer server = new RtspServer(IPAddress.Any, 554);

            var picsPath = Path.Combine(Environment.CurrentDirectory,"Bandit");

            Console.WriteLine("Pics in folder :" + Directory.GetFiles(picsPath).Count());
            
            var source = new RFC2435Media("PicsTcp", picsPath) { Loop = true };

            server.TryAddMedia(source);
            server.Start();

            Console.WriteLine("Server UDP enabled " + server.UdpEnabled);

            Task.Factory.StartNew(() =>
            {
                using (RtspClient udpClient = new RtspClient("rtspu://127.0.0.1/live/PicsTcp"))
                {
                    try
                    {
                        udpClient.AllowAlternateTransport = true;

                        udpClient.StartPlaying();

                        while (udpClient.Client.TotalRtpBytesReceieved <= 1024) { Thread.Sleep(10); }

                        Console.WriteLine("Test passed");
                    }
                    catch (Exception ex)
                    {
                        Console.BackgroundColor = ConsoleColor.Red;
                        Console.WriteLine("Rtp / Udp Test Failed: " + ex.Message);
                        if (ex.InnerException != null)
                        {
                            Console.WriteLine("InnerException : " + ex.InnerException.Message);
                        }
                        Console.BackgroundColor = ConsoleColor.Black;
                    }
                }
            });
        }
    }
}
Coordinator
Mar 15, 2015 at 4:03 PM
Edited Mar 15, 2015 at 4:05 PM
'rtspu' requires enable udp transport to be called On the rtsp server.

Try with 'rtsp' or 'rtspt' and the client will connect.

If you want rtspu just call the method on the server with the appropriate end point but be aware only few rtsp players support rtsp over udp including my server and client.

If you need anything else let me know.
Marked as answer by juliusfriedman on 3/15/2015 at 9:03 AM
Mar 15, 2015 at 5:06 PM
Edited Mar 15, 2015 at 5:16 PM
Thank you. RTSP is working RtspClient can connect.

I keep trying to run your tests...

In code below.. If I run application as shown in code below I am able to connect with VLC and it plays video. (Connection URL is rtsp://127.0.0.1/live/Alpha)
But if I use RFC2435Media as source VLC can nonnect but shows nothing. (Connection URL is rtsp://127.0.0.1/live/Bandit)

What I am doing wrong ?

What media source should be used to stream video file from disk ?
        static void Main(string[] args)
        {
            var server = new RtspServer(IPAddress.Any, 554);

            var source = new RtspSource("Alpha", "rtsp://quicktime.uvm.edu:1554/waw/wdi05hs2b.mov", RtspClient.ClientProtocolType.Tcp);

            var picsPath = Path.Combine(Environment.CurrentDirectory,"Bandit");
            var source2 = new RFC2435Media("Bandit", picsPath) { Loop = true };

            server.TryAddMedia(source);
            //server.TryAddMedia(source2);
            server.Start();

            Console.WriteLine("Server UDP enabled " + server.UdpEnabled);

        }
Coordinator
Mar 15, 2015 at 5:21 PM
check vlc's logs, and the codec information window.

Ensure you are using the container release and not the formats alpha if you have to use vlc or another player. that's one version behind the current release.

Also try mplayer and quick time, etc you may have better luck.

If you need anything else let me know.
Marked as answer by juliusfriedman on 3/15/2015 at 10:21 AM
Mar 15, 2015 at 5:25 PM
Thank you for answer. I'll do what you say.

Is there a way to stream video file from disk ? What media source should be used in that case ?

P.S. Sorry for so many questions... I jumped into a new domain...
Coordinator
Mar 15, 2015 at 5:32 PM
It's no worries @ all.

Using the RtpDump format yes both reading and writing, if you need to read from other containers it can be done but is not completely implemented, some work needs to be done to complete that functionality depending on if you want to do it via byte ranges for http or via track time scale via Rtsp (live or archived)

I have plans for implementing all containers eventually for writing I just haven't had enough time.

The same with playback.

If you have any further questions let me know!

(I plan on having another release by the end of week which should be Beta or Stable hopefully for Formats and will help alleviate confusion)
Marked as answer by juliusfriedman on 3/15/2015 at 10:32 AM
Mar 15, 2015 at 7:46 PM
If I understand you correctly there is no way to read AVI containers ?
Coordinator
Mar 15, 2015 at 9:31 PM
Edited Mar 15, 2015 at 9:34 PM
.... read them how and for what?

The RiffReader can read any complaint avi or riff file including but not limited to wave.

You can also read from any implemented container such as mp4 or ts.

What you are doing with the data you read is up to you as of now, if you just need to be able to take data from a container and make a packet then the logic is there.

If the data from a sample needs to be put into multiple packets then that would depend on the codec and rtp profile defined.

I am working on doing this automatically with some abstractions but there's nothing stopping anyone from doing this manually, everything you need should be there.

In fact most containers currently count samples when they return a Track using GetTracks, seeing how that is done should provide you enough insight to packetize the samples also.
Marked as answer by juliusfriedman on 3/15/2015 at 2:31 PM