Answers.Body: <p>I would use shell scripting thus:</p>
  
  <ul>
  <li>find the creation date of the first jpeg and the creation date of the subsequent jpeg. </li>
  <li>if the time difference is &lt;= 1 second then we have the start of a sequence. If the files are named sequentially then maybe move them to a subfolder. If not then move (or copy) the files to create a sequence.</li>
  <li>while the time difference is &lt;= 1 second keep updating the last frame of the sequence</li>
  <li>once we have a non-sequential file create a video using ffmpeg</li>
  <li>set the new first frame to the non-sequential file </li>
  <li>repeat for all the jpegs.</li>
  <li>concatenate all the videos</li>
  </ul>
  
  <p>ffmpeg can create a video from an image sequence where the files are named <code>frame_000.jpg, frame_001.jpeg, frame_002.jpg…</code> thus:</p>
  
  <pre><code>ffmpeg -i frame_%03d.jpg -r 1 output.mp4
  </code></pre>
  
  <p>the <code>-r 1</code> option sets the frame rate to 1 per second. If the sequence doesn't start with 000 then you can use <code>-start_number 123</code> to specify the first frame. more details <a href="https://www.ffmpeg.org/faq.html#How-do-I-encode-single-pictures-into-movies_003f" rel="nofollow noreferrer">here</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-01-14T01:58:14.960Z
Answers.LastActivityDate: 2020-01-14T01:58:14.960Z
Answers.UserDisplayName: stib
Body: <p>I have a camera which when motion is detected uploads JPG files at roughly one a second — so I want to take them and convert them back to video.</p>
  
  <p>For the uploaded files </p>
  
  <ul>
  <li>It sometimes skips a few uploads (up to about 3 second gaps) </li>
  <li>They continue for around 20 seconds after motion has ceased </li>
  <li>The files are 640×480 color 24-bit Depth and each is around 40K</li>
  <li>The pictures vary in lighting between stills </li>
  <li>There are no files once the motion detection has stopped — so a gap in files can be used to determine the end of video </li>
  </ul>
  
  <p>So I want to use a script to make these into a video - I'd like to </p>
  
  <ul>
  <li>Extend each JPG to the correct length of time </li>
  <li>“watermark” the timestamp onto the video </li>
  <li>Compress the video</li>
  </ul>
  
  <p>For compression, I feel that the common background and large sections of unchanging video should be highly compressible</p>
  
  <p>I'll be able to write the scripts which would include
   - the selection of the right set of files to include in each video 
  - production of an intermediate parameter file 
  - calculation of time span of each still image
  - determination of end of movie — including still currently recording  </p>
  
  <p>I'm running on a Window's laptop — but would consider a Raspberry Pi or Ubuntu system.</p>
  
  <p>I've looked at FFmpeg but got a little lost of where to start — I did find <a href="https://video.stackexchange.com/questions/22132/possible-to-stream-append-images-into-an-existing-mp4">possible-to-stream-append-images-into-an-existing-mp4</a>.  Which is close and I can start with this. However, one answer seemed to be saying that this may cause loss of fidelity with a comment saying no it won't. Also, I am unsure about how to make the JPGs extend to different lengths and how to watermark a time stamp onto each image  </p>
  
  <p>So my questions are
     What tool and encoding format is a good match with what I want ?</p>
  
  <p>Should I make the script wait until the files are fully produced or is it possible to append one JPG file to the movie stream at a time with parameters without excessive loss of fidelity?</p>
  
  <p>Is timestamping best done with a watermark on the video - or with some metadata tagging and require the renderer to display timestamps?  </p>
  
  <p>I have included one image from the camera</p>
  
  <p><a href="https://i.sstatic.net/E9lWT.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/E9lWT.png" alt="One Still Image"></a></p>
  
Tags: <software-recommendation>
Title: Convert jpg to video
UserDisplayName: Ross
ThreadText: # Convert jpg to video
  
  (Asked by: username_0 on 2020-01-12)
  
  I have a camera which when motion is detected uploads JPG files at roughly one a second — so I want to take them and convert them back to video.
  
  For the uploaded files
  
  * It sometimes skips a few uploads (up to about 3 second gaps)
  * They continue for around 20 seconds after motion has ceased
  * The files are 640×480 color 24-bit Depth and each is around 40K
  * The pictures vary in lighting between stills
  * There are no files once the motion detection has stopped — so a gap in files can be used to determine the end of video
  
  So I want to use a script to make these into a video - I'd like to
  
  * Extend each JPG to the correct length of time
  * “watermark” the timestamp onto the video
  * Compress the video
  
  For compression, I feel that the common background and large sections of unchanging video should be highly compressible
  
  I'll be able to write the scripts which would include
  - the selection of the right set of files to include in each video
  - production of an intermediate parameter file
  - calculation of time span of each still image
  - determination of end of movie — including still currently recording
  
  I'm running on a Window's laptop — but would consider a Raspberry Pi or Ubuntu system.
  
  I've looked at FFmpeg but got a little lost of where to start — I did find [possible-to-stream-append-images-into-an-existing-mp4](https://video.stackexchange.com/questions/22132/possible-to-stream-append-images-into-an-existing-mp4). Which is close and I can start with this. However, one answer seemed to be saying that this may cause loss of fidelity with a comment saying no it won't. Also, I am unsure about how to make the JPGs extend to different lengths and how to watermark a time stamp onto each image
  
  So my questions are
  What tool and encoding format is a good match with what I want ?
  
  Should I make the script wait until the files are fully produced or is it possible to append one JPG file to the movie stream at a time with parameters without excessive loss of fidelity?
  
  Is timestamping best done with a watermark on the video - or with some metadata tagging and require the renderer to display timestamps?
  
  I have included one image from the camera
  
  [![One Still Image](https://i.sstatic.net/E9lWT.png)](https://i.sstatic.net/E9lWT.png)
  
  **Tags:** software-recommendation
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-01-14. Score: 1
  
  I would use shell scripting thus:
  
  * find the creation date of the first jpeg and the creation date of the subsequent jpeg.
  * if the time difference is <= 1 second then we have the start of a sequence. If the files are named sequentially then maybe move them to a subfolder. If not then move (or copy) the files to create a sequence.
  * while the time difference is <= 1 second keep updating the last frame of the sequence
  * once we have a non-sequential file create a video using ffmpeg
  * set the new first frame to the non-sequential file
  * repeat for all the jpegs.
  * concatenate all the videos
  
  ffmpeg can create a video from an image sequence where the files are named `frame_000.jpg, frame_001.jpeg, frame_002.jpg…` thus:
  
  ```
  ffmpeg -i frame_%03d.jpg -r 1 output.mp4
  
  ```
  
  the `-r 1` option sets the frame rate to 1 per second. If the sequence doesn't start with 000 then you can use `-start_number 123` to specify the first frame. more details [here](https://www.ffmpeg.org/faq.html#How-do-I-encode-single-pictures-into-movies_003f)
  
  
  ---
  
  