Piping video device over SSH or tcptunnel?











up vote
1
down vote

favorite












I want to attach an analog camera to an old linux computer and directly pipe the /dev/video0 to another computer, where I can use it as a device again (so /dev/video0 should go to /dev/remote0, for example)



(Reason for doing this is that the computer does not have enough power to encode the video)



Is that possible? I've seen people can pipe the data directly from the device over ssh into mplayer, but I need to have some sort of reference point for Zoneminder.




  • Edit: As Phil Hannent said: SSH would probably also be too resource intensive for the hardware as it has to encrypt the data it sends. So is this also possible over a program like tcptunnel?


  • Edit2: On the Unix & Linux stackexchange site I found a question that uses this for piping over ssh: ssh localhost dd if=/dev/video0 | mplayer tv://device=/dev/stdin can that be done over tcptunnel?











share|improve this question




























    up vote
    1
    down vote

    favorite












    I want to attach an analog camera to an old linux computer and directly pipe the /dev/video0 to another computer, where I can use it as a device again (so /dev/video0 should go to /dev/remote0, for example)



    (Reason for doing this is that the computer does not have enough power to encode the video)



    Is that possible? I've seen people can pipe the data directly from the device over ssh into mplayer, but I need to have some sort of reference point for Zoneminder.




    • Edit: As Phil Hannent said: SSH would probably also be too resource intensive for the hardware as it has to encrypt the data it sends. So is this also possible over a program like tcptunnel?


    • Edit2: On the Unix & Linux stackexchange site I found a question that uses this for piping over ssh: ssh localhost dd if=/dev/video0 | mplayer tv://device=/dev/stdin can that be done over tcptunnel?











    share|improve this question


























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I want to attach an analog camera to an old linux computer and directly pipe the /dev/video0 to another computer, where I can use it as a device again (so /dev/video0 should go to /dev/remote0, for example)



      (Reason for doing this is that the computer does not have enough power to encode the video)



      Is that possible? I've seen people can pipe the data directly from the device over ssh into mplayer, but I need to have some sort of reference point for Zoneminder.




      • Edit: As Phil Hannent said: SSH would probably also be too resource intensive for the hardware as it has to encrypt the data it sends. So is this also possible over a program like tcptunnel?


      • Edit2: On the Unix & Linux stackexchange site I found a question that uses this for piping over ssh: ssh localhost dd if=/dev/video0 | mplayer tv://device=/dev/stdin can that be done over tcptunnel?











      share|improve this question















      I want to attach an analog camera to an old linux computer and directly pipe the /dev/video0 to another computer, where I can use it as a device again (so /dev/video0 should go to /dev/remote0, for example)



      (Reason for doing this is that the computer does not have enough power to encode the video)



      Is that possible? I've seen people can pipe the data directly from the device over ssh into mplayer, but I need to have some sort of reference point for Zoneminder.




      • Edit: As Phil Hannent said: SSH would probably also be too resource intensive for the hardware as it has to encrypt the data it sends. So is this also possible over a program like tcptunnel?


      • Edit2: On the Unix & Linux stackexchange site I found a question that uses this for piping over ssh: ssh localhost dd if=/dev/video0 | mplayer tv://device=/dev/stdin can that be done over tcptunnel?








      linux ubuntu video ssh video-capture






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Aug 11 '11 at 10:03

























      asked Aug 11 '11 at 9:14









      skerit

      43111530




      43111530






















          3 Answers
          3






          active

          oldest

          votes

















          up vote
          3
          down vote



          accepted










          You can use netcat.



          cat /dev/video0 | nc -l 1234


          This will open a server on one host listening on port 1234 and sending uncompressed and unencrypted data from /dev/video0 to any client that connects. You can receive the data on other host by invoking:



          nc videohost 1234 | mplayer tv://device=/dev/stdin


          where videohost is the host sending data from /dev/video0.






          share|improve this answer





















          • Nice! Is it possible to pipe the data into a /dev/file first, and then separately opening it in mplayer?
            – skerit
            Aug 12 '11 at 11:25










          • I think creating device would be too complicated, but if you need something file-like you could try a fifo pipe (mknod /tmp/videofifo p) write the stream to it and pipe it's contents to mplayer using cat. Not sure how the pipe would behave if you don't read the data from it though.
            – Paweł Nadolski
            Aug 12 '11 at 11:42










          • I'll give it a try tonight. Very interested to see how it'll turn out!
            – skerit
            Aug 12 '11 at 11:50










          • I'd also like to point out ipusb: it probably works even better than this. It lets you mount a usb device over the network.
            – skerit
            Sep 7 '11 at 21:51










          • "nc videohost 1234 | mplayer tv://device=/dev/stdin" output error "Playing tv://device=/dev/stdin. The filename option must be an integer: dev/stdin Struct tv, field filename parsing error: dev/stdin". I think this problem in my webcam or in my mplayer. "nc videohost 1234 | vlc - " work for me.
            – user3439968
            Feb 22 '16 at 20:24


















          up vote
          2
          down vote













          I would seriously advise you against this. I recently tried streaming avi videos over an ssh:// file access and its painful. You have to remember that the video is being encrypted and then decrypted during this process.



          If your computer cannot handle compressing the stream then it certainly will not be able to handle encrypting it.



          Really you want to just have a tcp tunnel the raw data:



          http://www.vakuumverpackt.de/tcptunnel/






          share|improve this answer





















          • Right, I forgot about that. But how would you pipe device data over this?
            – skerit
            Aug 11 '11 at 9:31


















          up vote
          0
          down vote













          The netcat solution didn't work for me. It either shows a pipe error, or cat reporting Invalid input.



          This is the only solution that worked for me:



          ssh user@host "ffmpeg  -r 14 -s 640x480 -f video4linux2 -i /dev/video0 -f matroska -" | mplayer - -idle


          This has the benefit of it being encoded, so you save bandwidth as a bonus.





          Combine with tee and you can watch and record at the same time:



          ssh user@host "ffmpeg  -r 14 -s 640x480 -f video4linux2 -i /dev/video0 -f matroska -" | tee $(date +%Y-%m-%d_%H-%M-%S)_recording.mkv | mplayer - -idle


          This will open mplayer for live streaming and save it to a file containing the current datetime at the same time (example filename: 2018-11-22_01-22-10_recording.mkv).






          share|improve this answer























            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "3"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














             

            draft saved


            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f321787%2fpiping-video-device-over-ssh-or-tcptunnel%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            3 Answers
            3






            active

            oldest

            votes








            3 Answers
            3






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            3
            down vote



            accepted










            You can use netcat.



            cat /dev/video0 | nc -l 1234


            This will open a server on one host listening on port 1234 and sending uncompressed and unencrypted data from /dev/video0 to any client that connects. You can receive the data on other host by invoking:



            nc videohost 1234 | mplayer tv://device=/dev/stdin


            where videohost is the host sending data from /dev/video0.






            share|improve this answer





















            • Nice! Is it possible to pipe the data into a /dev/file first, and then separately opening it in mplayer?
              – skerit
              Aug 12 '11 at 11:25










            • I think creating device would be too complicated, but if you need something file-like you could try a fifo pipe (mknod /tmp/videofifo p) write the stream to it and pipe it's contents to mplayer using cat. Not sure how the pipe would behave if you don't read the data from it though.
              – Paweł Nadolski
              Aug 12 '11 at 11:42










            • I'll give it a try tonight. Very interested to see how it'll turn out!
              – skerit
              Aug 12 '11 at 11:50










            • I'd also like to point out ipusb: it probably works even better than this. It lets you mount a usb device over the network.
              – skerit
              Sep 7 '11 at 21:51










            • "nc videohost 1234 | mplayer tv://device=/dev/stdin" output error "Playing tv://device=/dev/stdin. The filename option must be an integer: dev/stdin Struct tv, field filename parsing error: dev/stdin". I think this problem in my webcam or in my mplayer. "nc videohost 1234 | vlc - " work for me.
              – user3439968
              Feb 22 '16 at 20:24















            up vote
            3
            down vote



            accepted










            You can use netcat.



            cat /dev/video0 | nc -l 1234


            This will open a server on one host listening on port 1234 and sending uncompressed and unencrypted data from /dev/video0 to any client that connects. You can receive the data on other host by invoking:



            nc videohost 1234 | mplayer tv://device=/dev/stdin


            where videohost is the host sending data from /dev/video0.






            share|improve this answer





















            • Nice! Is it possible to pipe the data into a /dev/file first, and then separately opening it in mplayer?
              – skerit
              Aug 12 '11 at 11:25










            • I think creating device would be too complicated, but if you need something file-like you could try a fifo pipe (mknod /tmp/videofifo p) write the stream to it and pipe it's contents to mplayer using cat. Not sure how the pipe would behave if you don't read the data from it though.
              – Paweł Nadolski
              Aug 12 '11 at 11:42










            • I'll give it a try tonight. Very interested to see how it'll turn out!
              – skerit
              Aug 12 '11 at 11:50










            • I'd also like to point out ipusb: it probably works even better than this. It lets you mount a usb device over the network.
              – skerit
              Sep 7 '11 at 21:51










            • "nc videohost 1234 | mplayer tv://device=/dev/stdin" output error "Playing tv://device=/dev/stdin. The filename option must be an integer: dev/stdin Struct tv, field filename parsing error: dev/stdin". I think this problem in my webcam or in my mplayer. "nc videohost 1234 | vlc - " work for me.
              – user3439968
              Feb 22 '16 at 20:24













            up vote
            3
            down vote



            accepted







            up vote
            3
            down vote



            accepted






            You can use netcat.



            cat /dev/video0 | nc -l 1234


            This will open a server on one host listening on port 1234 and sending uncompressed and unencrypted data from /dev/video0 to any client that connects. You can receive the data on other host by invoking:



            nc videohost 1234 | mplayer tv://device=/dev/stdin


            where videohost is the host sending data from /dev/video0.






            share|improve this answer












            You can use netcat.



            cat /dev/video0 | nc -l 1234


            This will open a server on one host listening on port 1234 and sending uncompressed and unencrypted data from /dev/video0 to any client that connects. You can receive the data on other host by invoking:



            nc videohost 1234 | mplayer tv://device=/dev/stdin


            where videohost is the host sending data from /dev/video0.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Aug 12 '11 at 8:06









            Paweł Nadolski

            922410




            922410












            • Nice! Is it possible to pipe the data into a /dev/file first, and then separately opening it in mplayer?
              – skerit
              Aug 12 '11 at 11:25










            • I think creating device would be too complicated, but if you need something file-like you could try a fifo pipe (mknod /tmp/videofifo p) write the stream to it and pipe it's contents to mplayer using cat. Not sure how the pipe would behave if you don't read the data from it though.
              – Paweł Nadolski
              Aug 12 '11 at 11:42










            • I'll give it a try tonight. Very interested to see how it'll turn out!
              – skerit
              Aug 12 '11 at 11:50










            • I'd also like to point out ipusb: it probably works even better than this. It lets you mount a usb device over the network.
              – skerit
              Sep 7 '11 at 21:51










            • "nc videohost 1234 | mplayer tv://device=/dev/stdin" output error "Playing tv://device=/dev/stdin. The filename option must be an integer: dev/stdin Struct tv, field filename parsing error: dev/stdin". I think this problem in my webcam or in my mplayer. "nc videohost 1234 | vlc - " work for me.
              – user3439968
              Feb 22 '16 at 20:24


















            • Nice! Is it possible to pipe the data into a /dev/file first, and then separately opening it in mplayer?
              – skerit
              Aug 12 '11 at 11:25










            • I think creating device would be too complicated, but if you need something file-like you could try a fifo pipe (mknod /tmp/videofifo p) write the stream to it and pipe it's contents to mplayer using cat. Not sure how the pipe would behave if you don't read the data from it though.
              – Paweł Nadolski
              Aug 12 '11 at 11:42










            • I'll give it a try tonight. Very interested to see how it'll turn out!
              – skerit
              Aug 12 '11 at 11:50










            • I'd also like to point out ipusb: it probably works even better than this. It lets you mount a usb device over the network.
              – skerit
              Sep 7 '11 at 21:51










            • "nc videohost 1234 | mplayer tv://device=/dev/stdin" output error "Playing tv://device=/dev/stdin. The filename option must be an integer: dev/stdin Struct tv, field filename parsing error: dev/stdin". I think this problem in my webcam or in my mplayer. "nc videohost 1234 | vlc - " work for me.
              – user3439968
              Feb 22 '16 at 20:24
















            Nice! Is it possible to pipe the data into a /dev/file first, and then separately opening it in mplayer?
            – skerit
            Aug 12 '11 at 11:25




            Nice! Is it possible to pipe the data into a /dev/file first, and then separately opening it in mplayer?
            – skerit
            Aug 12 '11 at 11:25












            I think creating device would be too complicated, but if you need something file-like you could try a fifo pipe (mknod /tmp/videofifo p) write the stream to it and pipe it's contents to mplayer using cat. Not sure how the pipe would behave if you don't read the data from it though.
            – Paweł Nadolski
            Aug 12 '11 at 11:42




            I think creating device would be too complicated, but if you need something file-like you could try a fifo pipe (mknod /tmp/videofifo p) write the stream to it and pipe it's contents to mplayer using cat. Not sure how the pipe would behave if you don't read the data from it though.
            – Paweł Nadolski
            Aug 12 '11 at 11:42












            I'll give it a try tonight. Very interested to see how it'll turn out!
            – skerit
            Aug 12 '11 at 11:50




            I'll give it a try tonight. Very interested to see how it'll turn out!
            – skerit
            Aug 12 '11 at 11:50












            I'd also like to point out ipusb: it probably works even better than this. It lets you mount a usb device over the network.
            – skerit
            Sep 7 '11 at 21:51




            I'd also like to point out ipusb: it probably works even better than this. It lets you mount a usb device over the network.
            – skerit
            Sep 7 '11 at 21:51












            "nc videohost 1234 | mplayer tv://device=/dev/stdin" output error "Playing tv://device=/dev/stdin. The filename option must be an integer: dev/stdin Struct tv, field filename parsing error: dev/stdin". I think this problem in my webcam or in my mplayer. "nc videohost 1234 | vlc - " work for me.
            – user3439968
            Feb 22 '16 at 20:24




            "nc videohost 1234 | mplayer tv://device=/dev/stdin" output error "Playing tv://device=/dev/stdin. The filename option must be an integer: dev/stdin Struct tv, field filename parsing error: dev/stdin". I think this problem in my webcam or in my mplayer. "nc videohost 1234 | vlc - " work for me.
            – user3439968
            Feb 22 '16 at 20:24












            up vote
            2
            down vote













            I would seriously advise you against this. I recently tried streaming avi videos over an ssh:// file access and its painful. You have to remember that the video is being encrypted and then decrypted during this process.



            If your computer cannot handle compressing the stream then it certainly will not be able to handle encrypting it.



            Really you want to just have a tcp tunnel the raw data:



            http://www.vakuumverpackt.de/tcptunnel/






            share|improve this answer





















            • Right, I forgot about that. But how would you pipe device data over this?
              – skerit
              Aug 11 '11 at 9:31















            up vote
            2
            down vote













            I would seriously advise you against this. I recently tried streaming avi videos over an ssh:// file access and its painful. You have to remember that the video is being encrypted and then decrypted during this process.



            If your computer cannot handle compressing the stream then it certainly will not be able to handle encrypting it.



            Really you want to just have a tcp tunnel the raw data:



            http://www.vakuumverpackt.de/tcptunnel/






            share|improve this answer





















            • Right, I forgot about that. But how would you pipe device data over this?
              – skerit
              Aug 11 '11 at 9:31













            up vote
            2
            down vote










            up vote
            2
            down vote









            I would seriously advise you against this. I recently tried streaming avi videos over an ssh:// file access and its painful. You have to remember that the video is being encrypted and then decrypted during this process.



            If your computer cannot handle compressing the stream then it certainly will not be able to handle encrypting it.



            Really you want to just have a tcp tunnel the raw data:



            http://www.vakuumverpackt.de/tcptunnel/






            share|improve this answer












            I would seriously advise you against this. I recently tried streaming avi videos over an ssh:// file access and its painful. You have to remember that the video is being encrypted and then decrypted during this process.



            If your computer cannot handle compressing the stream then it certainly will not be able to handle encrypting it.



            Really you want to just have a tcp tunnel the raw data:



            http://www.vakuumverpackt.de/tcptunnel/







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Aug 11 '11 at 9:20









            Phil Hannent

            8501714




            8501714












            • Right, I forgot about that. But how would you pipe device data over this?
              – skerit
              Aug 11 '11 at 9:31


















            • Right, I forgot about that. But how would you pipe device data over this?
              – skerit
              Aug 11 '11 at 9:31
















            Right, I forgot about that. But how would you pipe device data over this?
            – skerit
            Aug 11 '11 at 9:31




            Right, I forgot about that. But how would you pipe device data over this?
            – skerit
            Aug 11 '11 at 9:31










            up vote
            0
            down vote













            The netcat solution didn't work for me. It either shows a pipe error, or cat reporting Invalid input.



            This is the only solution that worked for me:



            ssh user@host "ffmpeg  -r 14 -s 640x480 -f video4linux2 -i /dev/video0 -f matroska -" | mplayer - -idle


            This has the benefit of it being encoded, so you save bandwidth as a bonus.





            Combine with tee and you can watch and record at the same time:



            ssh user@host "ffmpeg  -r 14 -s 640x480 -f video4linux2 -i /dev/video0 -f matroska -" | tee $(date +%Y-%m-%d_%H-%M-%S)_recording.mkv | mplayer - -idle


            This will open mplayer for live streaming and save it to a file containing the current datetime at the same time (example filename: 2018-11-22_01-22-10_recording.mkv).






            share|improve this answer



























              up vote
              0
              down vote













              The netcat solution didn't work for me. It either shows a pipe error, or cat reporting Invalid input.



              This is the only solution that worked for me:



              ssh user@host "ffmpeg  -r 14 -s 640x480 -f video4linux2 -i /dev/video0 -f matroska -" | mplayer - -idle


              This has the benefit of it being encoded, so you save bandwidth as a bonus.





              Combine with tee and you can watch and record at the same time:



              ssh user@host "ffmpeg  -r 14 -s 640x480 -f video4linux2 -i /dev/video0 -f matroska -" | tee $(date +%Y-%m-%d_%H-%M-%S)_recording.mkv | mplayer - -idle


              This will open mplayer for live streaming and save it to a file containing the current datetime at the same time (example filename: 2018-11-22_01-22-10_recording.mkv).






              share|improve this answer

























                up vote
                0
                down vote










                up vote
                0
                down vote









                The netcat solution didn't work for me. It either shows a pipe error, or cat reporting Invalid input.



                This is the only solution that worked for me:



                ssh user@host "ffmpeg  -r 14 -s 640x480 -f video4linux2 -i /dev/video0 -f matroska -" | mplayer - -idle


                This has the benefit of it being encoded, so you save bandwidth as a bonus.





                Combine with tee and you can watch and record at the same time:



                ssh user@host "ffmpeg  -r 14 -s 640x480 -f video4linux2 -i /dev/video0 -f matroska -" | tee $(date +%Y-%m-%d_%H-%M-%S)_recording.mkv | mplayer - -idle


                This will open mplayer for live streaming and save it to a file containing the current datetime at the same time (example filename: 2018-11-22_01-22-10_recording.mkv).






                share|improve this answer














                The netcat solution didn't work for me. It either shows a pipe error, or cat reporting Invalid input.



                This is the only solution that worked for me:



                ssh user@host "ffmpeg  -r 14 -s 640x480 -f video4linux2 -i /dev/video0 -f matroska -" | mplayer - -idle


                This has the benefit of it being encoded, so you save bandwidth as a bonus.





                Combine with tee and you can watch and record at the same time:



                ssh user@host "ffmpeg  -r 14 -s 640x480 -f video4linux2 -i /dev/video0 -f matroska -" | tee $(date +%Y-%m-%d_%H-%M-%S)_recording.mkv | mplayer - -idle


                This will open mplayer for live streaming and save it to a file containing the current datetime at the same time (example filename: 2018-11-22_01-22-10_recording.mkv).







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Nov 22 at 3:22

























                answered Nov 21 at 23:59









                confetti

                1,1582724




                1,1582724






























                     

                    draft saved


                    draft discarded



















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f321787%2fpiping-video-device-over-ssh-or-tcptunnel%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    flock() on closed filehandle LOCK_FILE at /usr/bin/apt-mirror

                    Mangá

                    Eduardo VII do Reino Unido