MJPG Monitor Capture Rate breaks ffmpeg proccess



  • Hi, I have a MJPEG monitor configured, when i set any value in the field Monitor Capture Rate under the section Input Settings the ffmepg process crashes complaining about "undefined" parameter. Leting the field blank works, but only at 1 FPS what is not enought for me 🙂

    If i set the FPS at say, 15 the command looks like:

     -loglevel warning  -r 15 -reconnect 1 -r undefined -f mjpeg -analyzeduration 2000000 -probesize 2000000 -re -i 
    

    If i let the field blank i get:

     -loglevel warning  -reconnect 1 -r 1 -f mjpeg -analyzeduration 2000000 -probesize 2000000 -re -i 
    

    I'm on dev branch.



  • I've been taking a look of the code of camera.js and i found that around line 1263 the input fps are assigned to the ffmpeg command line like this:

         if(e.details.sfps!==''){x.input_fps=' -r '+e.details.sfps}else{x.input_fps=''}
    

    Around line 1776

        x.ffmpegCommandString = x.loglevel+x.input_fps;
    

    But if you scroll down around line 1790 you'll find this:

    case'mjpeg':
                if(!e.details.sfps||e.details.sfps===''){
                    x.capture_fps=parseFloat(e.details.sfps);
                    if(isNaN(x.capture_fps)){x.capture_fps=1}
                }
                x.ffmpegCommandString += ' -reconnect 1 -r '+x.capture_fps+' -f mjpeg'+x.cust_input+' -i "'+e.url+'"';
    

    So, with this in mind is easy to spot why the -r parameter is duplicationg for MJPEG input if you set input fps.

    I just fix it locally with a dirty workaround, but i'm not sure if it is correct, i'm not expert in ffmpeg or the Shinobi software internals. Is you @moeiscool think it is right or point me in the right direcction i can do a pull request myself 🙂

    My fix:

            case'mjpeg':
                if(x.input_fps)
                {
                    x.ffmpegCommandString += ' -reconnect 1 -f mjpeg'+x.cust_input+' -i "'+e.url+'"';
                }
                else
                {
                    if(!e.details.sfps||e.details.sfps===''){
                        x.capture_fps=parseFloat(e.details.sfps);
                        if(isNaN(x.capture_fps)){x.capture_fps=1}
                    }
                    x.ffmpegCommandString += ' -reconnect 1 -r '+x.capture_fps+' -f mjpeg'+x.cust_input+' -i "'+e.url+'"';
                }
    

    Thanks and best regards!


 

Looks like your connection to Shinobi Forum was lost, please wait while we try to reconnect.