summaryrefslogtreecommitdiff
path: root/includes/inc_files.php
blob: 15ef491f3c568bf9877922f2fbf4955f64f9b185 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php

function mediagetinfostream($stream = "")
{

	global $mediainfopath, $ffmpegpath;

	// Get info
	exec($mediainfopath ." \"" .$stream ."\"", $mediainfo);

	$info = "";
	$title = "";

	// Parse info
	$count = count($mediainfo);
	for ($i = 0; $i < $count; $i++)
	{
		if (!strncmp($mediainfo[$i], "Video", strlen("Video")) || !strncmp($mediainfo[$i], "Audio", strlen("Audio")))
			break;

		if (!strncmp($mediainfo[$i], "Format", strlen("Format")))
			$title = substr(strstr($mediainfo[$i], ": "), 2);
		else if (!strncmp($mediainfo[$i], "Format/Info", strlen("Format/Info")))
			$title = substr(strstr($mediainfo[$i], ": "), 2);
		else if (!strncmp($mediainfo[$i], "Duration", strlen("Duration")))
			$info = substr(strstr($mediainfo[$i], ": "), 2);
	}

	// Extract a thumbnail
	exec("rm ram/stream-tb.png");
	exec($ffmpegpath ." -y -i \"" .$stream ."\" -an -ss 00:00:05.00 -r 1 -vframes 1 -s 128x72 -f mjpeg ram/stream-tb.png");
	
	return array($title, $info);
}