WFD capture and video extraction

1. The steps to manually grab tcpdump data packets are as follows:
1. Use the USED version, connect the test machine to the PC via USB
2. adb root–”adb disable-verity–>restart the phone–”after reboot, execute adb root–>adb remount and hang Download successfully –> adb shell
3. Then execute the command tcpdump -i p2p0 -w sdcard/XXX custom file name.cap in the adb shell. Do not disconnect the tcpdump data packet capture, and then perform the screen projection operation 4. There is a blurry
screen Finally, export the "XXX custom file name.cap" tcpdump file just captured in the mobile phone and record the time when the problem occurred

2. Video extraction in data packets

Select wireshark Version 1.2.15 (the new version does not support selecting the type of saved file)
to open the TCP dump file Select
the earlier UDP packet or RTSP packet according to the timestamp
Select the menu "Analyze -> Decode As", select the RTP data type
Select the menu "Telephony -> RTP -> Stream Analyze", after this step is completed, you can see the RTP packet loss rate, delay and other information reports.
Select "Save payload" and save it as xxx.ts file, then you can play the video.

 

Wireshark captures a packet
(trying to spy on the technical implementation, but how)
downloads the latest wireshark: https://www.wireshark.org/download.html
Capture packet: Oh, the whole is a rtsp-rtp-tcp-mpegts stream
based on A single tcp transmission, rtsp negotiation, rtp load mpegts stream to achieve audio and video transmission, (basically copied a set of android mobile screen projection, that is, Miracast Android WifiDisplay, remember this is Mui12.5.4+ Mui2.3.0.951 wind client, I don’t know if I will do some private optimization in the future)

Take a look at this rtsp information in detail: (standard rtps wifidisplay)

 

Paste the data directly

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-
simply extract the mpeg-ts in the captured packet to see:
wireshark comes over rtp, phone->Rtp->stream analysis->save->asynchronous forward Audio -> raw format

 

Save the extracted data directly as the mpeg-ts stream, which can be played directly with a video player such as potplayer, including video and audio. :
You can also use the streamEye software to directly view the encoding information:
h264 encoding, High: 5.1
resolution 1080x2340,
the actual playback frame rate is 60
gop 1s

 

Guess you like

Origin blog.csdn.net/chanimei_11/article/details/124820730
Recommended