I have a video stream over a udp connection that I'm transferring using ncat. I'm piping this into mplayer to play it. I'm doing this just on the normal command line. Everything works fine.The command I'm running is:
ncat -l -p 5000 --udp | mplayer -vo direct3d -cache 1028 -
What I want to do is change the pipe to send it to mplayer AND to another ncat process that fowards it to another computer. My research led me first to a Windows implementation of tee, but that doesn't work because it tee's to a file and to the next command in the pipe instead of to two commands.
So then I was reading about using PowerShell and I think that's the only way to do it without having to write code. I'm a proficient programmer so I can write a program to do this if needed, but I was hoping I could just write a script and make this happen. However, I'm not getting very far...
My first attempt was modeled after this example I found here:
PS > "123" | % {
$_.Replace( "1", "a"),
$_.Replace( "2", "b" )
}
Seems to work for this simple example, but it's not working for what I want to do. Seems this is processing an item at a time, but I have a continuous stream.
I tried to replicate my existing ncat to mplayer example and couldn't even get that to work. For whatever reason, I don't get any output to the console from mplayer and the mplayer video window never starts. I'm not really sure why though.
Another issue that I came across was that PowerShell doesn't seem to pipe bytes as straight bytes. That confused me a bit because it seems restrictive, but I guess most people use PowerShell for text processing so it kind of makes sense. This led me to find
a Get-ProcessOutputAsBinary command here that I tried to make work. I was able to finally get some mplayer output to the console, however it only happened
after I killed the ncat process. Here's what I tried:
.\Get-ProcessOutputAsBinary.ps1 "ncat.exe" "-l -p 5000 --udp" | mplayer -vo direct3d -cache 1028 -Maybe it's because I'm a programmer and don't write scripts very often, but this seems overly complicated. I guess I can think of a ton of reasons you'd want to pipe output (binary or otherwise) to two (or more) other commands and I don't understand why it's so difficult. I'm also not understand why I can't even replicate what I can do on a standard windows command line. Am I just missing something?