$re = '/(?<=m=video)(?s)(.*)(a=sendrecv)/m';
$str = 'v=0
o=- 582127838 582127838 IN IP4 172.17.217.8
s=Commend
c=IN IP4 172.17.217.8
t=0 0
m=audio 16882 RTP/AVP 8 107 9 0
a=rtpmap:8 PCMA/8000
a=rtpmap:107 opus/48000/2
a=fmtp:107 useinbandfec=1
a=rtpmap:9 G722/8000
a=rtpmap:0 PCMU/8000
a=ptime:20
a=maxptime:20
a=sendrecv
m=video 15132 RTP/AVP 99
a=rtpmap:99 H264/90000
a=sendrecv
';
$subst = "$1a=sendonly";
$result = preg_replace($re, $subst, $str);
echo "The result of the substitution is ".$result;
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php