from scapy.all import *
from scapy.layers.inet import IP, TCP
pkts = rdpcap("path/to/pcap_file")
pkt1 = pkts[0] # Get first packet
ip_hdr = pkt1[IP]
tcp_hdr = ip_hdr[TCP]
src_port = tcp_hdr.sport # Get source port
dst_port = tcp_hdr.dport # Get destination port