WFD抓包及视频提取

一、手动抓取tcpdump数据包信息步骤如下:
1、使用USED版本,USB连接测试机和PC
2、adb root–》adb disable-verity–>重启手机–》重启后执行adb root–>adb remount 挂载成功–>adb shell
3、然后在adb shell中执行命令 tcpdump -i p2p0 -w sdcard/XXX自定义的文件名.cap 进行tcpdump数据包抓取不要断开,然后进行投屏操作
4、出现花屏后,导出手机里刚才抓取到的“XXX自定义的文件名.cap” tcpdump文件 并记录问题发生时间点

二、数据包中视频提取

选择wireshark Version 1.2.15(新的版本不支持选择保存文件的类型)
打开TCP dump 文件
根据时间戳选中较早的 UDP 报文或者 RTSP报文
选择 菜单“Analyze -> Decode As",选中RTP数据类型
选择菜单 “Telephony -> RTP -> Stream Analyze”,此步完成后可以看到RTP数据包丢包率,延迟等信息报告
选择“Save payload” 保存成 xxx.ts文件,就可以播放该视频了。

wireshark抓个包
(企图窥探一下技术实现,奈何)
下载个最新的wireshark:https://www.wireshark.org/download.html
抓包:哦,整个就是一个 rtsp-rtp-tcp-mpegts流
全程基于单个的tcp传输,rtsp协商,rtp负载mpegts流来实现音视频传输,(基本将android手机投屏的一套照搬了过来,也就是Miracast Android WifiDisplay 记一下这是Mui12.5.4+ Mui2.3.0.951 wind客户端,不知道后面会不会做一下私有的优化)

详细看一下这个rtsp信息:(标准的rtps wifidisplay)

直接贴上数据吧

OPTIONS * RTSP/1.0
Date: Sat, 12 Jun 2021 02:52:56 +0000
Server: 
CSeq: 1
Require: org.wfa.wfd1.0
 
RTSP/1.0 200 OK
Date: Sat, 12 Jun 2021 02:52:36 +0800
User-Agent: stagefright/1.1 (Linux;Android 4.1)
CSeq: 1
Public: org.wfa.wfd1.0, GET_PARAMETER, SET_PARAMETER
 
OPTIONS * RTSP/1.0
Date: Sat, 12 Jun 2021 02:52:36 +0800
User-Agent: stagefright/1.1 (Linux;Android 4.1)
CSeq: 1
Require: org.wfa.wfd1.0
 
RTSP/1.0 200 OK
Date: Sat, 12 Jun 2021 02:52:56 +0000
Server: 
CSeq: 1
Public: org.wfa.wfd1.0, SETUP, TEARDOWN, PLAY, PAUSE, GET_PARAMETER, SET_PARAMETER
 
GET_PARAMETER rtsp://localhost/wfd1.0 RTSP/1.0
Date: Sat, 12 Jun 2021 02:52:56 +0000
Server: 
CSeq: 2
Content-Type: text/parameters
Content-Length: 99
 
wfd_content_protection
wfd_video_formats
wfd_audio_codecs
wfd_client_rtp_ports
wfd_tcp_enable
RTSP/1.0 200 OK
Date: Sat, 12 Jun 2021 02:52:36 +0800
User-Agent: stagefright/1.1 (Linux;Android 4.1)
CSeq: 2
Content-Type: text/parameters
Content-Length: 207
 
wfd_audio_codecs: AAC 00000001 00
wfd_video_formats: 00 00 02 0F 000FFFFF 05157FFF 00000FFF 00 0001 0000 11 none none
wfd_client_rtp_ports: RTP/AVP/TCP;interleaved mode=play
wfd_content_protection: none
SET_PARAMETER rtsp://localhost/wfd1.0 RTSP/1.0
Date: Sat, 12 Jun 2021 02:52:56 +0000
Server: 
CSeq: 3
Content-Type: text/parameters
Content-Length: 246
 
wfd_video_formats: 98 00 02 02 00080000 00000000 00000000 00 0000 0000 00 none none
wfd_audio_codecs: AAC 00000001 00
wfd_presentation_URL: rtsp://192.168.137.108/wfd1.0/streamid=0 none
wfd_client_rtp_ports: RTP/AVP/TCP;interleaved mode=play
RTSP/1.0 200 OK
Date: Sat, 12 Jun 2021 02:52:36 +0800
User-Agent: stagefright/1.1 (Linux;Android 4.1)
CSeq: 3
Content-Type: text/parameters
Content-Length: 0
 
SET_PARAMETER rtsp://localhost/wfd1.0 RTSP/1.0
Date: Sat, 12 Jun 2021 02:52:56 +0000
Server: 
CSeq: 4
Content-Type: text/parameters
Content-Length: 27
 
wfd_trigger_method: SETUP
RTSP/1.0 200 OK
Date: Sat, 12 Jun 2021 02:52:36 +0800
User-Agent: stagefright/1.1 (Linux;Android 4.1)
CSeq: 4
Content-Type: text/parameters
Content-Length: 0
 
SETUP rtsp://192.168.137.108/wfd1.0/streamid=0 RTSP/1.0
Date: Sat, 12 Jun 2021 02:52:36 +0800
User-Agent: stagefright/1.1 (Linux;Android 4.1)
CSeq: 2
Transport: RTP/AVP/TCP;interleaved=0-1
 
RTSP/1.0 200 OK
Date: Sat, 12 Jun 2021 02:52:56 +0000
Server: 
CSeq: 2
Session: 1638754794;timeout=30
Transport: RTP/AVP/TCP;interleaved=0-1;
 
PLAY rtsp://192.168.137.108/wfd1.0/streamid=0 RTSP/1.0
Date: Sat, 12 Jun 2021 02:52:36 +0800
User-Agent: stagefright/1.1 (Linux;Android 4.1)
CSeq: 3
Session: 1638754794
 
RTSP/1.0 200 OK
Date: Sat, 12 Jun 2021 02:52:56 +0000
Server: 
CSeq: 3
Session: 1638754794;timeout=30
Range: npt=now-
干脆把抓的包里面的mpeg-ts提取出来看看:
wireshark过来rtp,电话->Rtp->流分析->save->不同步的正向音频->raw格式

保存提取的数据,直接是mpeg-ts的流,用视频播放器比如 potplayer 直接可以播放,包含视频和音频。:
也可以用streamEye软件直接查看其中的编码信息:
h264编码,High:5.1
分辨率1080x2340
实际播放的帧率60
gop 1s

猜你喜欢

转载自blog.csdn.net/chanimei_11/article/details/124820730