You were using a closing ) instead of a closing >.
)
>
Here is the corrected line:
preg_match_all('/<(video|audio)[^>]+src="([^"]+)">/', $str, $matches);