Find the answer to your Linux question:
Results 1 to 5 of 5
hi. I'm trying to create simple p2p voice-chat script. my first attempt was to establish one way communication using sox and netcat: on receiving computer: Code: nc -l 0.0.0.0 1234 ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jan 2013
    Posts
    3

    Question audio over socket


    hi.
    I'm trying to create simple p2p voice-chat script.
    my first attempt was to establish one way communication using sox and netcat:

    on receiving computer:
    Code:
    nc -l 0.0.0.0 1234 | play -r 8k -t flac -
    and on sending:
    Code:
    rec -r 8k -t flac - | nc 192.168.1.11 1234
    audio from default input in one computer is played on second box, but there's over 4 second lag...
    can someone recommend any solution?
    maybe some other recording and playback software or different codec?
    TIA

  2. #2
    Linux Newbie
    Join Date
    Jun 2012
    Posts
    100
    Why not use the UDP switch in netcat?

    Quote Originally Posted by man nc
    -u UDP mode

  3. #3
    Linux Enthusiast
    Join Date
    Dec 2011
    Location
    Turtle Island West
    Posts
    521
    I have a guess that the flac compression is slowing things down, both on send and recieve. Try raw audio.

    I think I'll try it myself.

  4. $spacer_open
    $spacer_close
  5. #4
    Just Joined!
    Join Date
    Jan 2013
    Posts
    3
    actually i've made some progress here. it looks like it's more buffering than codec issue (but raw audio is indeed slightly faster)
    using
    Code:
    rec --buffer 18 -r 64k -c 1 -t ul - | nc 192.168.1.11 12345
    and
    Code:
    nc -l 0.0.0.0 12345 | play --buffer 18 -r 64k -c 1 -t ul -
    , lag is small enough.
    but there's still that buffer problem. i need to use very high sample rate in order to "overflow" buffer quickly, but that seams like a waste of bandwidth.
    anyone know recording/playback program with "unbuffered" mode?
    Last edited by patryk; 02-03-2013 at 08:45 PM.

  6. #5
    Linux Newbie
    Join Date
    Mar 2010
    Posts
    152
    Have you considered GStreamer? It can be fairly complicated (it's able to do a lot) but is reportedly quite good.

    Audio-specific example here, loads more examples for various things here.
    Programming and other random guff: cat /dev/thoughts > blogspot.com (previously prognix.blogspot.com)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •