How to retrieve H263/H264 data from a pcap file. - linux

I have tried tools like videosnarf that takes a pcap file as input and creates a raw .h264 file , which could be later encoded with ffmpeg , and finally can be played with vlc player. But videosnarf can only handle h264 data.
I'm not able to find a similar tool that can dump h263 data from a pcap file. I tried to decode h263 stream from wireshark but I have had no luck so far.
I can program in perl/python but I don't know what exact steps to follow to retrieve h263 raw data from a pcap file as I haven't played with pcap capture files before.

sjd,
You can try setting up a sniffer using Twisted Python library (Twisted) this would allow you to capture the raw data coming in over your network as long as you can tell Twisted what port to listen to (or listen all), and where to dump the file to, etc and then do something with that new file (like send it into ffmpeg to test saving to .mov).
You would have to generate the .sdp file for ffmpeg, so unless you automate that step of the process, it is really annoying. I am currently working on the automation portion but am struggling just as much.
I'm using EventMachine for Ruby with FFMPEG, and .sdp from SIP.
Hope this helps a little.

Related

Linux: how to dump audio output PCM bit stream like tcpdump

I am trying to do some audio debugging on my Linux system.
I learned how to record the sound of the current playing media but how can I get the PCM data without DAC/ADC?
I mean, just like wireshark or tcpdump tool, is there some sort of alsadump that I can make use of?
I want to do bit-exact comparison of the output PCM data to make sure the audio processing algorithm (which is an executable binary) worked correctly.
Thanks a lot.

mpeg-dash with live stream

I would like to use MPEG-DASH technology in situations where I am constantly receiving a live video stream from a client. The Web server gets a live video stream, keeps generating the m4s file, and declares it in mpd. So the new segment can be played back constantly.
(I'm using FFMPEG's ffserver. So the video stream continues to accumulate in /tmp/feed1.ffm file.)
Using MP4Box seems to be able to generate mpd, init.mp4, m4s for already existing files. But it does not seem to support live streaming.
I want fragmented mp4 in segment format rather than mpeg-ts.
A lot of advice is needed!
GPAC maintainer here. The dashcast project (and likely its dashcastx replacement from our Signals platform should help you). Please open issues on github if you have any issues.
Please note that there are some projects like this one using FFmpeg to generate some HLS and then GPAC to ingest the TS segments to produce MPEG-DASH. This introduces some latency but proved to be very robust.
Below information may be useful.
latest ffmpeg supports the live streaming and also mp4 fragmenting.
Example command
ffmpeg -re -y -i <input> -c copy -f dash -window_size 10 -use_template 1 -use_timeline 1 <ClearLive>.mpd

decoding .raw voip data to opus

I have got this capture file (pcap) with RTP packets seems to be encoded by opus. In wireshark, analyzed the stream and saved as raw file.
Now I have got the .raw file of the audio. Using the opus tool from http://www.opus-codec.org/downloads/
I cannot decode it direct to wav because the file is raw,not .opus. I cannot encode it to .opus because this raw data is the extract of already encoded stream.
I just need to play this voice back. Any suggestions Please
As far as I know you won't be able to decode Opus stream extracted that way - framing information is lost. You need either write Wireshark module that would be able to decode opus or write another tool to extract stream from RTP into another container (typically OGG is used).
http://xiph.org/~giles/2012/rtpopus.c seems to be tool that you need.
Old question, but if anyone needs to decode Opus RTP packets, here is the solution:
PJSIP comes with a tool (pjsip-apps/src/samples/pcaputil.c) that does just that. It gets compiled by default, just make sure you have libopus-dev installed before you build PJSIP. Simply feed a pcap file with RTP packets to pcaputil and specify the codec on the command line (e.g. "opus/48000"). You will get the decoded audio as a PCM WAV file.
pcaputil can also decrypt SRTP packets (if given the key), however I could not get that to work and instead used srtp-decrypt to decrypt the packets, followed by Wireshark to convert the .txt output back to .pcap for feeding to PJSIP's pcaputil (see also https://www.acritelli.com/hacking-voip-decrypting-sdes-protected-srtp-phone-calls/).

Converting from .opus to .wav

Hello I am supposed to write a utility that will extract an opus encoded audio payload from RTP packets which I will read from a pcap dumpfile. The utility should also have the functionality that can be used to decode the payload that I am extracting from the rtp packets and convert it to a .wav file.
Currently I have written a code that extracts the payload from the rtp packets and dumps it into a file "log.opus". However I am stuck at this point. How should I proceed with writing the decoder logic?
I am working on Windows platform and am using winpcap library and libopus.
I suggest you have a look at this trivial example I created to show how to use Opus:
http://git.xiph.org/?p=opus.git;a=blob;f=doc/trivial_example.c
You'll want to keep just the decoder part. There's also the API documentation for more details:
http://www.opus-codec.org/docs/html_api-1.1.0/index.html

How can I concatenate ATSC streams from DVB card?

I'm trying to make a simple "TV viewer" using a Linux DVB video capture card. Currently I watch TV using the following process (I'm on a Raspberry Pi):
Tune to a channel using azap -r TV_CHANNEL_HERE. This will supply bytes to
device /dev/dvb/adapter0/dvr0.
Open OMXPlayer omxplayer /dev/dvb/adapter0/dvr0
Watch TV!
The problem comes when I try to change channels. Even if I set the player to cache incoming bytes (tried with MPlayer also), the player can't withstand a channel change (by restarting azap with a new channel.
I'm thinking this is because of changes in the MPEG TS stream metadata.
Looking for a C library that would let me do the following:
Pull cache_size * mpeg_ts_packet_size from DVR device.
Evaluate each packet and rewrite metadata (PID, etc) as needed.
Populate FIFO with resulting packet.
Set {OMXPlayer,MPlayer} to read from FIFO.
The other thing I was thinking would be to use a program that converts MPEG TS into MPEG PS and concatenate the bytes that way.
Thoughts?
Indeed, when you want to tune on an other channel, some metadata can potentially change and invalid previously cached data.
Unfortunately I'm not familiar with the tools you are using but your point 2. makes me raise an eyebrow: you will waste your time trying to rewrite Transport Stream data.
I would rather suggest to stop and restart process on zapping since it seems to work fine at start.
P.S.:
Here are some tools that can help. Also, I'm not sure at which level your problem is but VLC can be installed on Raspberry PI and it handles TS gracefully.

Resources