title: How to generate images from mp4 file?
body: <p>I am trying to generate the <code>images</code> from <code>mp4</code> video file with <code>ffmpeg</code>. </p>
  
  <p>I only want the first 3 second of every video in the file.</p>
  
  <p>I have the following command..</p>
  
  <pre><code> $videoFile = $mp4File; //I have many mp4 files
  
   $ffmpeg ="/usr/ffmpeg";
  
   $image_path = $videoFile;
  
   $ALL_PLACE_WIDTH = 300;
   $ALL_PLACE_HEIGHT = 220;
  
   $image_cmd = " -r 1 -r 0.03 -s ".$ALL_PLACE_WIDTH."x".$ALL_PLACE_HEIGHT." -f image2 ";
   $dest_path = 'project/image-%01d.png';
  
   $str_command= $ffmpeg  ." -i " . $image_path . $image_cmd .$dest_path;
   shell_exec($str_command);
  </code></pre>
  
  <p>I am trying to generate firt 3 second image of every <code>mp4</code> file but my script will genearte a lot of images and it create images across entire <code>mp4</code> file.</p>
  
  <p>Can I restrict the script to get only the first 3 seconds images only? Thanks a lot!</p>