Jump to content

My end goal:

 

On like youtube, they show a little thing in the bottom that says "5 mins reaming".

 

 

I have no idea where to start, but i am Using FFMPEG:

 

$format = new Streaming\Format\X264();
$format->on('progress', function ($video, $format, $percentage){
	global $time;
	global $time_init;
	$url_23 = '/home/nrrinc/Desktop/HLS2/2/'.$time.'/';
    // You can update a field in your database or can log it to a file
    // You can also create a socket connection and show a progress bar to users
    //echo sprintf("\rTranscoding...(%s%%) [%s%s]", $percentage, str_repeat('#', $percentage), str_repeat('-', (100 - $percentage))).'';
    $myfile = fopen($url_23."txt.status", "w") or die("Unable to open file!");
    //$txt = sprintf("\rTranscoding...(%s%%) [%s%s]", $percentage, str_repeat('#', $percentage), str_repeat('-', (100 - $percentage))).'';
	$txt = sprintf("%s%", $percentage, str_repeat('#', $percentage),).''.'<br>';
    fwrite($myfile, $txt);
    fclose($myfile);

### I want to echo how much time is remaining til the render is done
});

 

Link to comment
https://linustechtips.com/topic/1362682-php-calculate-remaining-time-for-script/
Share on other sites

Link to post
Share on other sites

Total file size (MBs) minus MBs rendered = MBs Remaining

MBs Remaining divided by MB per second = Time remaining

MBs rendered divided by (Total file size (MBs) divided by 100) = Progress Percentage

 

Additionally you will have to define the following terms:

Total file size (MBs)

MBs rendered

MB per second

 

A PC Enthusiast since 2011
AMD Ryzen 7 5700X@4.65GHz | GIGABYTE RTX 3080 GAMING OC | 4x 8GB Micron Rev.E (D9VPP) 3800MHz 16-19-14-21-58
Link to post
Share on other sites

also as a suggestion, if you have your own server or  your web hosting offers this, consider using memcached or a memory table in your mysql instead of updating text files.

memcached - https://memcached.org/ - is a key:value list kept in memory ... so you can create a unique key based on the path of the file and the value can be the information you want to access later encoded in some format , for example json encoded.

memcached will automatically prune the oldest least accessed records when the memory it has allocated gets full so you don't need to worry about deleting key:value pairs from memory (but you could)

With a memory table in mysql, you could just add a "last_updated" column and store the time there (jut time() result would be plenty)  and once an hour or so you could run a query "delete all records older than 48 hours " or whatever period you want.

Link to post
Share on other sites

12 hours ago, Vishera said:

Total file size (MBs) minus MBs rendered = MBs Remaining

MBs Remaining divided by MB per second = Time remaining

MBs rendered divided by (Total file size (MBs) divided by 100) = Progress Percentage

 

Additionally you will have to define the following terms:

Total file size (MBs)

MBs rendered

MB per second

 

in PHP-FFMpeg, how could this be done? (i know how to get the total file size, but how to get the MBs rendered?)

 

i can provide the full code if needed

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×