MiniComa
MiniComa

Reputation: 23

Identify and modify H264 I, P, B frames

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]

Upvotes: 2

Views: 3868

Answers (1)

av501
av501

Reputation: 6739

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.

Upvotes: 1

Related Questions