pcap-extract.sh 549 B

123456789101112131415161718
  1. #!/bin/bash
  2. pcap=$1
  3. shift
  4. law=$1
  5. shift
  6. if [ -z $pcap ] ; then echo "usage $0 <pcap file> [<mu-law|a-law>]"; exit 255 ; fi
  7. if [ -z $law ] ; then law="mu-law" ; fi
  8. for ssrc in $(tshark -n -r $pcap -Y rtp -T fields -e rtp.ssrc -Eseparator=, | sort -u) ; do
  9. rm -f $pcap.$ssrc.raw $pcap.$ssrc.wav
  10. sudo tshark -n -r $pcap -Y "rtp && rtp.ssrc == $ssrc" -T fields -e rtp.payload | sed "s/:/ /g" | perl -ne 's/([0-9a-f]{2})/print chr hex $1/gie' >> $pcap.$ssrc.raw
  11. sox -t raw -r 8000 -v 4 -c 1 -e $law $pcap.$ssrc.raw $pcap.$ssrc.wav
  12. done