diff --git a/wp-includes/media.php b/wp-includes/media.php
index 974aa79..216f6fc 100644
--- a/wp-includes/media.php
+++ b/wp-includes/media.php
@@ -1571,9 +1571,19 @@ function wp_audio_shortcode( $attr, $content = '' ) {
 		$attr_strings[] = $k . '="' . esc_attr( $v ) . '"';
 	}
 
-	$html = '';
-	if ( 'mediaelement' === $library && 1 === $instances )
-		$html .= "<!--[if lt IE 9]><script>document.createElement('audio');</script><![endif]-->\n";
+	/**
+	 * Filters the HTML added inside the audio shortcode output.
+	 *
+	 * Give the possibility to insert some HTML code before the <audio> tag 
+	 * generated by an audio shortcode.
+	 *
+	 * @since 4.0.0
+	 *
+	 * @param string $html      Empty variable to be replaced with the HTML snippet to insert before the <audio> tag.
+	 * @param string $library   Media library used for the audio shortcode.
+	 * @param int    $instances Unique numeric ID of this audio shortcode instance.
+	 */
+	$html = apply_filters('wp_audio_shortcode_pre_html', '', $library, $instances);
 	$html .= sprintf( '<audio %s controls="controls">', join( ' ', $attr_strings ) );
 
 	$fileurl = '';
@@ -1588,8 +1598,20 @@ function wp_audio_shortcode( $attr, $content = '' ) {
 		}
 	}
 
-	if ( 'mediaelement' === $library )
-		$html .= wp_mediaelement_fallback( $fileurl );
+	/**
+	 * Filters the HTML added inside the audio shortcode output.
+	 *
+	 * Give the possibility to insert some HTML code inside the <audio> tag 
+	 * generated by an audio shortcode.
+	 *
+	 * @since 4.0.0
+	 *
+	 * @param string $html    Empty variable to be replaced with the HTML snippet to append into the <audio> tag.
+	 * @param string $library Media library used for the audio shortcode.
+	 * @param string $fileurl The URL of the audio file.
+	 * @param int    $post_id Post ID.
+	 */
+	$html .= apply_filters('wp_audio_shortcode_inside_html', '', $library, $fileurl, $post_id);
 	$html .= '</audio>';
 
 	/**
@@ -1607,6 +1629,20 @@ function wp_audio_shortcode( $attr, $content = '' ) {
 }
 add_shortcode( 'audio', 'wp_audio_shortcode' );
 
+function wp_mediaelement_audio_shortcode_pre_html($html, $library, $instances) {
+	if ( 'mediaelement' === $library && 1 === $instances )
+		$html .= "<!--[if lt IE 9]><script>document.createElement('audio');</script><![endif]-->\n";
+	return $html;
+}
+add_filter('wp_audio_shortcode_pre_html', 'wp_mediaelement_audio_shortcode_pre_html', 10, 3);
+
+function wp_mediaelement_audio_shortcode_inside_html($html, $library, $fileurl, $post_id) {
+	if ( 'mediaelement' === $library )
+		$html .= wp_mediaelement_fallback( $fileurl );
+	return $html;
+}
+add_filter('wp_audio_shortcode_inside_html', 'wp_mediaelement_audio_shortcode_inside_html', 10, 4);
+
 /**
  * Return a filtered list of WP-supported video formats
  *
@@ -1711,11 +1747,30 @@ function wp_video_shortcode( $attr, $content = '' ) {
 		}
 	}
 
-	$yt_pattern = '#^https?://(:?www\.)?(:?youtube\.com/watch|youtu\.be/)#';
+	/**
+	 * Filters the default external video providers patterns used for the video shortcode.
+	 *
+	 * @since 4.0.0
+	 *
+	 * @param array $patterns An associative array listing the external video providers.
+	 */
+	$ext_providers_patterns = apply_filters( 'wp_video_external_providers', array(
+		'youtube' => array(
+			'pattern' => '#^https?://(:?www\.)?(:?youtube\.com/watch|youtu\.be/)#',
+			'mimetype'    => 'video/youtube',
+		),
+	));
 
 	$primary = false;
+	$match = false;
 	if ( ! empty( $src ) ) {
-		if ( ! preg_match( $yt_pattern, $src ) ) {
+		foreach($ext_providers_patterns as $provider) {
+			if( preg_match( $provider['pattern'], $src ) ) {
+				$match = true;
+				break;
+			}
+		}
+		if ( ! $match ) {
 			$type = wp_check_filetype( $src, wp_get_mime_types() );
 			if ( ! in_array( strtolower( $type['ext'] ), $default_types ) ) {
 				return sprintf( '<a class="wp-embedded-video" href="%s">%s</a>', esc_url( $src ), esc_html( $src ) );
@@ -1788,9 +1843,19 @@ function wp_video_shortcode( $attr, $content = '' ) {
 		$attr_strings[] = $k . '="' . esc_attr( $v ) . '"';
 	}
 
-	$html = '';
-	if ( 'mediaelement' === $library && 1 === $instances )
-		$html .= "<!--[if lt IE 9]><script>document.createElement('video');</script><![endif]-->\n";
+	/**
+	 * Filters the HTML added before the video shortcode output.
+	 *
+	 * Give the possibility to insert some HTML code before the <video> tag 
+	 * generated by a video shortcode.
+	 *
+	 * @since 4.0.0
+	 *
+	 * @param string $html      Empty variable to be replaced with the HTML snippet to insert before the <video> tag.
+	 * @param string $library   Media library used for the video shortcode.
+	 * @param int    $instances Unique numeric ID of this video shortcode instance.
+	 */
+	$html = apply_filters('wp_video_shortcode_pre_html', '', $library, $instances);
 	$html .= sprintf( '<video %s controls="controls">', join( ' ', $attr_strings ) );
 
 	$fileurl = '';
@@ -1800,9 +1865,15 @@ function wp_video_shortcode( $attr, $content = '' ) {
 			if ( empty( $fileurl ) )
 				$fileurl = $$fallback;
 
-			if ( 'src' === $fallback && preg_match( $yt_pattern, $src ) ) {
-				$type = array( 'type' => 'video/youtube' );
-			} else {
+			$match = false;
+			foreach( $ext_providers_patterns as $provider ) {
+				if( 'src' === $fallback && preg_match( $provider['pattern'], $src ) ) {
+					$match = true;
+					$type = array( 'type' => $provider['mimetype'] );
+					break;
+				}
+			}
+			if ( ! $match ) {
 				$type = wp_check_filetype( $$fallback, wp_get_mime_types() );
 			}
 			$url = add_query_arg( '_', $instances, $$fallback );
@@ -1817,8 +1888,20 @@ function wp_video_shortcode( $attr, $content = '' ) {
 		$html .= trim( $content );
 	}
 
-	if ( 'mediaelement' === $library )
-		$html .= wp_mediaelement_fallback( $fileurl );
+	/**
+	 * Filters the HTML added inside the video shortcode output.
+	 *
+	 * Give the possibility to insert some HTML code inside the <video> tag 
+	 * generated by a video shortcode.
+	 *
+	 * @since 4.0.0
+	 *
+	 * @param string $html    Empty variable to be replaced with the HTML snippet to append into the <video> tag.
+	 * @param string $library Media library used for the video shortcode.
+	 * @param string $fileurl The URL of the video file.
+	 * @param int    $post_id Post ID.
+	 */
+	$html .= apply_filters('wp_video_shortcode_inside_html', '', $library, $fileurl, $post_id);
 	$html .= '</video>';
 
 	$html = sprintf( '<div style="width: %dpx; max-width: 100%%;" class="wp-video">%s</div>', $width, $html );
@@ -1838,6 +1921,20 @@ function wp_video_shortcode( $attr, $content = '' ) {
 }
 add_shortcode( 'video', 'wp_video_shortcode' );
 
+function wp_mediaelement_video_shortcode_pre_html($html, $library, $instances) {
+	if ( 'mediaelement' === $library && 1 === $instances )
+		$html .= "<!--[if lt IE 9]><script>document.createElement('video');</script><![endif]-->\n";
+	return $html;
+}
+add_filter('wp_video_shortcode_pre_html', 'wp_mediaelement_video_shortcode_pre_html', 10, 3);
+
+function wp_mediaelement_video_shortcode_inside_html($html, $library, $fileurl, $post_id) {
+	if ( 'mediaelement' === $library )
+		$html .= wp_mediaelement_fallback( $fileurl );
+	return $html;
+}
+add_filter('wp_video_shortcode_inside_html', 'wp_mediaelement_video_shortcode_inside_html', 10, 4);
+
 /**
  * Display previous image link that has the same post parent.
  *
-- 
1.9.1

