title: How to set up a cron job for ffmpeg in centOS 6
body: <p>I can convert from mp4 file to jpg file manually one by one with the below command on centOS 6 environment. </p>
  
  <p>Now, could anyone help me out how to set up a cron for any mp4 file in the directory to be converted automatically 
  to jpg file with the same file name as mp4 file such as <code>03052022_5a9d28723d2da.jpg</code> for the below environment?</p>
  
  <p>OS：centos-6 (x86_64)</p>
  
  <p>ffmpeg version 2.2.2</p>
  
  <p>Plesk 17.0.17</p>
  
  <pre><code>[root@server-xxxxxxxx-x ~]# ffmpeg -i                                \
    /var/www/vhosts/xxxxx.com/httpdocs/save/03052022_5a9d28723d2da.mp4 \
    /var/www/vhosts/xxxxx.com/httpdocs/save/03052022_5a9d28723d2da.jpg
  </code></pre>
  
  <p>With 's/.conf$/.jpg/p':</p>
  
  <pre><code>[root@server-xxxxxx-x ~]# for i in `find /var/www/vhosts/xxxxxx.com/httpdocs/save/ -type f -name "*.mp4"`; do ffmpeg -i $i `echo $i | sed -En 's/.conf$/.jpg/p'`; done
  </code></pre>
  
  <p>ffmpeg version 2.2.2 Copyright (c) 2000-2014 the FFmpeg developers
    built on Feb 21 2018 03:03:24 with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-18)
       configuration:
       libavutil      52. 66.100 / 52. 66.100
       libavcodec     55. 52.102 / 55. 52.102
       libavformat    55. 33.100 / 55. 33.100
       libavdevice    55. 10.100 / 55. 10.100
       libavfilter     4.  2.100 /  4.  2.100
       libswscale      2.  5.102 /  2.  5.102
       libswresample   0. 18.100 /  0. 18.100
       Input #0, mov,mp4,m4a,3gp,3g2,mj2, from   '/var/www/vhosts/xxxxxx.com/httpdocs/save/03081956_5aa116c836015.mp4':
       Metadata:
        major_brand     : mp42
        minor_version   : 0
        compatible_brands: isommp42
        creation_time   : 2018-02-14 04:42:34
        Duration: 00:00:00.83, start: 0.000000, bitrate: 23270 kb/s
         Stream #0:0(eng): Video: h264 (Baseline) (avc1 / 0x31637661), yuvj420p(pc,   smpte170m), 1920x1080, 25370 kb/s, SAR 65536:65536 DAR 16:9, 29.73 fps, 30 tbr, 90k   tbn, 180k tbc (default)
           Metadata:
           rotate          : 90
           creation_time   : 2018-02-14 04:42:34
           handler_name    : VideoHandle
           Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 96 kb/s (default)
           Metadata:
           creation_time   : 2018-02-14 04:42:34
            handler_name    : SoundHandle
         At least one output file must be specified
         Conversion failed!</p>
  
  <p>With "s/.conf$/.jpg/p":</p>
  
  <pre><code>[root@server-xxxxxxx-x ~]# for i in `find /var/www/vhosts/xxxxxx.com/httpdocs/save/ -type f -name "*.mp4"`; do ffmpeg -i $i `echo $i | sed -En "s/.conf$/.jpg/p"`; done
  </code></pre>
  
  <p>ffmpeg version 2.2.2 Copyright (c) 2000-2014 the FFmpeg developers
    built on Feb 21 2018 03:03:24 with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-18)
    configuration:
    libavutil      52. 66.100 / 52. 66.100
    libavcodec     55. 52.102 / 55. 52.102
    libavformat    55. 33.100 / 55. 33.100
    libavdevice    55. 10.100 / 55. 10.100
    libavfilter     4.  2.100 /  4.  2.100
    libswscale      2.  5.102 /  2.  5.102
    libswresample   0. 18.100 /  0. 18.100
  Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/var/www/vhosts/xxxxxx.com/httpdocs/save/03081956_5aa116c836015.mp4':
    Metadata:
      major_brand     : mp42
      minor_version   : 0
      compatible_brands: isommp42
      creation_time   : 2018-02-14 04:42:34
    Duration: 00:00:00.83, start: 0.000000, bitrate: 23270 kb/s
      Stream #0:0(eng): Video: h264 (Baseline) (avc1 / 0x31637661), yuvj420p(pc, smpte170m), 1920x1080, 25370 kb/s, SAR 65536:65536 DAR 16:9, 29.73 fps, 30 tbr, 90k tbn, 180k tbc (default)
      Metadata:
        rotate          : 90
        creation_time   : 2018-02-14 04:42:34
        handler_name    : VideoHandle
      Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 96 kb/s (default)
      Metadata:
        creation_time   : 2018-02-14 04:42:34
        handler_name    : SoundHandle
  At least one output file must be specified
  Conversion failed!</p>
  
  <p>With "s/.mp4$/.jpg/p"</p>
  
  <pre><code>[root@server-xxxxx-x ~]# for i in `find /var/www/vhosts/xxxxxx.com/httpdocs/save/ -type f -name "*.mp4"`; do ffmpeg -i $i `echo $i | sed -En "s/.mp4$/.jpg/p"`; done
  </code></pre>
  
  <p>[image2 @ 0x2c488e0] Could not get frame filename number 2 from pattern '/var/www/vhosts/xxxxxx.com/httpdocs/save/03100013_5aa2a49bb67bc.jpg' (either set updatefirst or use a pattern like %03d within the filename pattern)
  av_interleaved_write_frame(): Invalid argument
  frame=    2 fps=0.0 q=3.2 Lsize=N/A time=00:00:00.06 bitrate=N/A
  video:289kB audio:0kB subtitle:0 data:0 global headers:0kB muxing overhead -100.007446%
  Conversion failed!</p>