Find the answer to your Linux question:
Results 1 to 5 of 5
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Question audio over socket

    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:
    nc -l 1234 | play -r 8k -t flac -
    and on sending:
    rec -r 8k -t flac - | nc 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?

  2. #2
    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
    Turtle Island West
    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
  5. #4
    actually i've made some progress here. it looks like it's more buffering than codec issue (but raw audio is indeed slightly faster)
    rec --buffer 18 -r 64k -c 1 -t ul - | nc 12345
    nc -l 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 07:45 PM.

  6. #5
    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 > (previously

Posting Permissions

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