I'm trying to get this cronjob to work but it won't exec the the ffmpeg exec that I have in my controller file.

When I try to run it via web browser it outputs the variables correctly but won't exec

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Cron extends CI_Controller {


    public function transcode_wmv() {

    $this->db->select('*');
    $this->db->from('transcoding');
    $this->db->where("status", 'ready');
    $get_ready_file = $this->db->get();
    $ready_file = $get_ready_file->result();

    foreach($ready_file AS $RF)
    {
        $filename = $RF->newname;
        $output= $RF->newname;
    }

    ##exec("ffmpeg -y -i $filename -vcodec wmv2 -b 14000k -qmin 1 $output.wmv");
    $command = "ffmpeg -y -i $filename -vcodec wmv2 -b 14000k -qmin 1 $output.wmv";
    exec($command);
    echo $command;

    echo "<br>done";
    }




}//end

If I try to open the url in chrome/firefox via www.example.com/cron/transcode_wmv I can see the contents and I can see the echo and it has the proper data so it is getting the right info from mysql but wont' exec the ffmpeg.

I've tried running it cli with curl but no luck I just get the output of $command and still doesn't exec ffmpeg.

I've also tried running

php /var/www/html/site/index.php cron transcode_wmv

But I get this error and still no exec on ffmpeg

PHP Notice:  Undefined index: REQUEST_URI in /var/www/html/site/application/config/config.php on line 364
<div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;">

<h4>A PHP Error was encountered</h4>

<p>Severity: Notice</p>
<p>Message:  Undefined index: REQUEST_URI</p>
<p>Filename: config/config.php</p>
<p>Line Number: 364</p>

</div><div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;">

<h4>A PHP Error was encountered</h4>

<p>Severity: Notice</p>
<p>Message:  Undefined index: REMOTE_ADDR</p>
<p>Filename: core/Input.php</p>
<p>Line Number: 351</p>

</div><div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;">

<h4>A PHP Error was encountered</h4>

<p>Severity: Warning</p>
<p>Message:  Cannot modify header information - headers already sent by (output started at /var/www/html/site/system/core/Exceptions.php:185)</p>
<p>Filename: libraries/Session.php</p>
<p>Line Number: 688</p>

</div><div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;">

<h4>A PHP Error was encountered</h4>

<p>Severity: Warning</p>
<p>Message:  Cannot modify header information - headers already sent by (output started at /var/www/html/site/system/core/Exceptions.php:185)</p>
<p>Filename: libraries/Session.php</p>
<p>Line Number: 688</p>

</div><div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;">

<h4>A PHP Error was encountered</h4>

<p>Severity: Warning</p>
<p>Message:  Cannot modify header information - headers already sent by (output started at /var/www/html/site/system/core/Exceptions.php:185)</p>
<p>Filename: helpers/url_helper.php</p>
<p>Line Number: 542</p>

Any ideas? Driving me nuts!

Also running current version of CI

TIA

Hi,

regarding the ffmpeg execution in $RF->newname are you returning only the filename or also the path in which this file is located? Is the destination path writable?

Regarding the execution of the controller from CLI, it seems you are autoloading the session library, this will give the kind of warnings and notices you are experiencing, solution is to load the session into each controller or to extend the session library to detect CLI requests:

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class MY_Session extends CI_Session
{
    public function __construct()
    {
        $CI = get_instance();
        if($CI->input->is_cli_request())
            return;

        parent::__construct();
    }
}

Just save it into application/libraries/MY_Session.php.
Source: http://stackoverflow.com/a/8394485

Holy crap. Stupid me. You are right about the path. I did not have the path in for the file. I'm stupid.

Thanks for the help and pointing it out.

Used to writing the php scripts inside the directories where the files are.

No worry, it happens! ;)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.