See the manual page for mpileup and the -r option
(...)
-r STR Only generate pileup in region STR
(...)
e.g:
samtools mpileup -C50 -gf ref.fasta -r chr3:1,000-2,000 in1.bam in2.bam
Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
And the -l option if you have many regions....