LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   how to easily create a stream that could be seen on a terminal? (https://www.linuxquestions.org/questions/linux-software-2/how-to-easily-create-a-stream-that-could-be-seen-on-a-terminal-4175543788/)

eantoranz 05-27-2015 07:15 PM

how to easily create a stream that could be seen on a terminal?
 
As a network experiment, I'd like to be able to stream some content to people that connected to a certain port of my computer, as if it were aa or caca output.

I know it's possible to use mplayer to be able to see video on the terminal of the local computer and so I thought that it shouldn't be too difficult to try to stream it into the network.

How can that be easily achieved?

Thanks in advance.

Sefyir 05-27-2015 09:19 PM

Try using netcat (nc)?

On server side (sending out the stream)
Code:

nc -l portnumber
on client side (recieving stream)
Code:

nc ip-addr portnumber
with mplayer

Code:

nc ip-addr portnumber | mplayer -
This will only work on a 1:1 basis rather then 1:multi.
You'll need something like icecast for that which is more "suited" but increases in complexity.

eantoranz 05-27-2015 09:32 PM

I thought of netcat but I would have to feed it the multimedia stream.... and my question was pointed more or less in that direction. Say, something along the lines of:

Code:

multimedia-encoder --whatever-options-to-produce-the-stream-content sourcefile.avi | nc -l 4567
And then someone be able to see the content by doing this:

Code:

telnet ip-address 4567
But then it would only work for the first client that connects, right? How about producing content for anyone that connects?

Sefyir 05-27-2015 10:28 PM

Quote:

But then it would only work for the first client that connects, right? How about producing content for anyone that connects?
Then it'd have to create a new connection for that user.

Use something designed for broadcasting media to multiple users

http://mpd.wikia.com/wiki/Icecast2


This example would not work
Code:

multimedia-encoder --whatever-options-to-produce-the-stream-content sourcefile.avi | nc -l 4567
You can't both save and pipe the file. Since it is being saved as sourcefile.avi, nothing is sent to stdout and nc has nothing to send to a user.
IF you want to both save a file and send it out, tee does this.
Code:

multimedia-encoder --whatever-options-to-produce-the-stream-content - | tee sourcefile.avi | nc -l 4567
This would cause the output to be saved as sourcefile.avi and piped to nc.
This can have unexpected consequences if the multimedia-encoder depends on the file extension to determine how to encode it (like ffmpeg/avconv) which can be overridden by manually defining the format.

eantoranz 05-27-2015 10:31 PM

I understand what you mean.... but actually, in my example, sourcefile.avi is what you would like to stream out.

Sefyir 05-27-2015 10:48 PM

I suggest experimenting. A common method of outputting a file into a program is with cat.
Code:

cat file | program
You can try it with just cat file too and see what happens.
(Ctrl + c will cancel any output the cat command does)


All times are GMT -5. The time now is 09:10 AM.