Identify and modify H264 I, P, B frames - frame

I use VLC to stream H264 video file in MPEG TS container through UDP over LAN. I capture packets in client side with Wireshark and here you can find pcap file: http://www.sendspace.com/file/w0sf36
Is it true that I need to work with MPEG PES to identify I, P or B frames? If so, how can I do that? Here is data of one MPEG PES packet: http://pastebin.com/NayLBx5w . It starts with bytes 0x00 0x00 0x00 0x01. Which bytes should I use to reach my goal?
In pcap file you can see that MPEG PES packets take only 2% of all stream and others packets are simple UDP. Is it enough to work with MPEG PES packets? What information UDP packets carry in this case?
EDIT: This is the typical output I get in Windows using ffprobe.
[PACKET]
codec_type=audio
stream_index=1
pts=54010800
pts_time=600.120000
dts=54010800
dts_time=600.120000
duration=2160
duration_time=0.024000
convergence_duration=N/A
convergence_duration_time=N/A
size=96
pos=1460384
flags=K
[/PACKET]
[PACKET]
codec_type=video
stream_index=0
pts=54012012
pts_time=600.133467
dts=54006006
dts_time=600.066733
duration=3003
duration_time=0.033367
convergence_duration=N/A
convergence_duration_time=N/A
size=207953
pos=1098672
flags=_
[/PACKET]
[PACKET]
codec_type=video
stream_index=0
pts=54009009
pts_time=600.100100
dts=54009009
dts_time=600.100100
duration=3003
duration_time=0.033367
convergence_duration=N/A
convergence_duration_time=N/A
size=145530
pos=1311676
flags=_
[/PACKET]
[PACKET]
codec_type=audio
stream_index=1
pts=54012960
pts_time=600.144000
dts=54012960
dts_time=600.144000
duration=2160
duration_time=0.024000
convergence_duration=N/A
convergence_duration_time=N/A
size=96
pos=1507948
flags=K
[/PACKET]
[PACKET]
codec_type=video
stream_index=0
pts=54018018
pts_time=600.200200
dts=54012012
dts_time=600.133467
duration=3003
duration_time=0.033367
convergence_duration=N/A
convergence_duration_time=N/A
size=46173
pos=1460572
flags=_
[/PACKET]

As long as you have the content with you in form of a file use
ffprobe -show_packets <your_file>
to get details on every packet in the stream. It can be any valid video file.
Here is an incomplete output from a file I had.
[FRAME]
media_type=video
key_frame=0
pkt_pts=2
pkt_pts_time=0.100000
pkt_dts=2
pkt_dts_time=0.100000
pkt_duration=1
pkt_duration_time=0.050000
pkt_pos=301347
width=320
height=240
pix_fmt=yuv420p
sample_aspect_ratio=N/A
pict_type=P
coded_picture_number=2
display_picture_number=0
interlaced_frame=0
top_field_first=0
repeat_pict=0
reference=0
[/FRAME]
[FRAME]
media_type=audio
key_frame=1
pkt_pts=0
pkt_pts_time=0.000000
pkt_dts=0
pkt_dts_time=0.000000
pkt_duration=1024
pkt_duration_time=0.021333
pkt_pos=306587
sample_fmt=s16
nb_samples=1024
[/FRAME]
You can write a very simple perl script or something like that to tell you the exact details for every frame.

Related

SCSI read(10) reads out weird values- USB pendrive

I am implementing USB as a host using OHCI to read the files stored in the Flashdrive. To read I implement the read(10) command in SCSI. The Logical Block address being the sector number. The following is an image of the command I send for read(10) to read LBA 0x0000-
http://i.imgur.com/ky4FHlm.png
I read 512bytes(size of one sector or 1 LBA)and the following is the output that i get for LBA 0x0000-
http://imgur.com/jL6OEjE
The bytes in the above image are not present any where on the pendrive, I checked that using HXD. Now, for testing I filled the pendrive to full capacity. If I read any other LBA, other than 0x0000, then I always get 512 bytes of 0x00.
Could anyone please tell me what the problem could be?
Am I supposed to execute some other command before I do a read(10) so that the USB sends me the right data maybe?
From my understanding I have put DPO, FUA and FUA_NV=0 and also RDPROTECT=2

New line character within at*smsm2m message string

I'm trying to send a multiline sms from an application I am creating to my phone via telnet to a GSM modem. I would like the message to be output to my phone as shown below but cannot figure out how to add new lines within the message string so that the message is output to my phone as below. I cannot find much documentation on this either and the few character codes (\r\n) I tried either terminated the telnet command were they were displayed in my code or were showing in the SMS received on my phone.
Does anybody know what character code that would give me a new line without terminating the telnet command within the message string?
at*smsm2m= “441234567891
Pinging 192.168.0.31 with 32 bytes of data:
Reply from 192.168.0.31: bytes=32 time=3ms TTL=64<br>
Reply from 192.168.0.31: bytes=32 time=1ms TTL=64<br>
Reply from 192.168.0.31: bytes=32 time=1ms TTL=64<br>
Reply from 192.168.0.31: bytes=32 time=1ms TTL=64
Ping statistics for 192.168.0.31:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
The server side of Telnet is typically just a regular shell so you can do the same things you'd do for embedded newlines as if you were typing at a command line. Try this:
echo -e "this\nhas\nmultiple\nlines" | program
(you may need to look up flags for the echo command on the server if it's not a GNU machine)

How do I get all the information regarding the header of an audio file?

How do I get all the information regarding the header of an audio file, so it can be displayed in a readable format like ASCII values?
The audio file maybe of any format, most preferably .wav format.
EDIT:- OS can be windows 8.1 or ubuntu. I actually have to understand all the properties of the file like whether it is mono or stereo, its encoding, etc. maybe specifically .wav file, i would say.
I have knowledge about the C++ language, so that would be better.
There is a very powerful command you can use in a bash script: sox.
To get all the info you need about a wav file, you just have to run:
soxi file.wav
and you'll get something like:
Input File : 'file.wav'
Channels : 1
Sample Rate : 8000
Precision : 16-bit
Duration : 00:02:08.40 = 1027236 samples ~ 9630.34 CDDA sectors
File Size : 2.05M
Bit Rate : 128k
Sample Encoding: 16-bit Signed Integer PCM
sox is available for Windows as well, although I have never used there.
You can use FFPROBE utility from FFMPEG: http://ffmpeg.org/
"ffprobe" gathers information from multimedia streams and prints it in human- and machine-readable fashion.
For example it can be used to check the format of the container used by a multimedia stream
and the format and type of each media stream contained in it.
Code
ffprobe -i <file_name>
ffprobe -i myfile.wav
Output will look something like this
Input #0, wav, from 'myfile.wav':
Duration: 00:04:16.88, bitrate: 16 kb/s
Stream #0:0: Audio: g729 ([131][0][0][0] / 0x0083), 8000 Hz, 2 channels, s16p, 16 kb/s
Output Explanation:
g729 is encoding type here.
16 kb/s is the bit-rate.
2 channels
Sample rate 8000 Hz
For detailed information
ffprobe -i <file_name> -show_streams

How can I use the value of mp2t.af.pcr as a Tshark field?

I have a wireshark capture that contains an RTP multicast stream (plus some other incidental data).
Using a Tshark command like the following, I can produce a CSV of the RTP timestamp compared with the packet capture time:
tshark.exe -r "capture.pcap" -Eseparator=, -Tfields -e rtp.timestamp -e frame.time_epoch -d udp.port==5000,rtp
This decodes the UDP packets as RTP, and successfully prints out the two fields as expected.
Now, my question: The payload of the RTP stream is an MPEG2 Transport Stream, and I also want to print the PCR value (if there is one) alongside the packet and RTP timestamps.
In wireshark, I can see the PCR being decoded correctly, however using a command like the following:
tshark.exe -r "HBO HD CZ.pcap" -Eseparator=,-Tfields -e rtp.timestamp -e frame.time_epoch -e mp2t.af.pcr -d udp.port==5000,mp2t
...only prints out a "1" if there is a PCR oresent, not the actual value. I have also checked the .pcr_flag to confirm that these two are not exchanged, but still I see the same result.
The documentation seems to call mp2t.af.pcr a "Label", does this mean that Tshark is not able to use it as a field? Is there a way to generate a CSV with these values?
(What part of the documentation calls it a "Label"? That's a somewhat odd description of a named field.)
The problem is that the value that Wireshark displays after "base(XXX)*300 + ext(YYY)" is calculated and displayed, but the field itself isn't given an integral type and is instead given a type that doesn't have a value. Arguably, it should be an FT_UINT64 field and should be given a value, so that you can filter on it and can print the value in TShark.
Please file an enhancement request for this on the Wireshark Bugzilla.

Delimiter string in Telit GL 868 Dual V3

I am using Telit modem GL 868 Dual V3. AT command AT#SCFG has 2 parameters- packet size to be used and data sending time-out for TCP. Is there any AT command which specifies that if any delimiter string is found, then that data will be sent on TCP ignoring the packet size and time-out?
There are commands #PADFWD, #PADCMD which serves the purpose of delimiter.
Below is a snapshot from AT commands reference guide for telit modem.