As Christopher Maynard explained, you can only select a maximum of 512 packets at once with editcap. This thread on Wireshark mailing list has a bit more information.
If you don't want to change editcap's sources, you could select packets in batches. The following script generates 10000 random numbers and then select packets by batches of 512. The resulting .pcap files are merged into a single .pcap file at the end.
#!/bin/bash
large_number=150000
smaller_number=10000
selected_pkt_numbers=$(shuf -i 0-"$large_number" -n "$smaller_number")
for j in `seq 0 512 $smaller_number`; do
endrange=$((j+512))
if [ "$endrange" -gt "$smaller_number" ]; then
endrange=$smaller_number
fi
# Selects numbers $j to $endrange from the generated random numbers:
echo "$j - $endrange"
pkt_numbers=$(echo $selected_pkt_numbers | awk -v start="$j" -v end="$endrange" '{ out=""; for (i=start+1; i<=end; i++) out=out" "$i; print out}')
editcap -r $1 $2-$j.pcap $pkt_numbers
done
mergecap -w $2.pcap `ls $2-*.pcap`
To use it:
$ ./pcap-random.sh input-file.pcap output-file
0 - 512
512 - 1024
[...]
9216 - 9728
9728 - 10000
$
$
$ capinfos output-file.pcap
File name: output-file.pcap
File type: Wireshark/... - pcapng
File encapsulation: Ethernet
File timestamp precision: microseconds (6)
Packet size limit: file hdr: (not set)
Packet size limit: inferred: 58 bytes
Number of packets: 10 k
[...]
That script will take more time to execute than if you modify editcap's sources. I haven't measured how much. With the parameters you gave it took ~11s to execute.