[FFmpeg-user] Appending new jpg images to an existing mp4 (built of jpg's)

Mark Filipak markfilipak.noreply at gmail.com
Tue Apr 12 09:41:24 EEST 2022


On 2022-04-11 23:12, Steve Williams wrote:
> Hi,
> 
> I am completely new to the video world, so I am trying to learn from the various resources on the 
> Internet.
> 
> I am running ffmpeg on a Unix (OpenBSD) system.
> 
> I have a webcam that is capturing 4 still (jpeg) images per minute. The jpeg is stored in a filename 
> YYYY-MM-DD-hh-mm-ss.  Once an hour, I use ffmpeg to create an mp4 movie of all the stills for the day.
> 
> ffmpeg -y -pattern_type glob -i "image_2020-04-11-*.jpeg" -c:v libx264 -preset ultrafast today.mp4
> 
> As the day progresses, the ffmpeg is encoding more and more images and totally recreating "today.mp4".
> 
> Is there a way to just append the new jpeg files to "today.mp4"?
> 
> I can change formats, whatever it takes if it's possible.
> 
> Reading the faq, there are various "concat" options, but I am not sure if they are relevant.  The 
> one that seemed to make the most sense is:
> 
> 3.14.2 Concatenating using the concat demuxer
> FFmpeg has a concat demuxer which you can use when you want to avoid a re-encode and your format 
> doesn’t support file level concatenation.
> 
> I don't want to re-encode all the jpeg images... so I was thinking I could create an "hourly" mp4 of 
> the new jpeg images and then use the concat demuxer to combine the 2 mp4's into a new (third) file.  
> But I was wondering if there was a more efficient way to do this.
> 
> Can I specify "ffmpeg -i today.mp4" -y pattern_type glob -i "image_2020-04-11-*.jpeg" ...
> 
> Looking at "3 Detailed description" in the documentation, it looks like that would run the today.mp4 
> through the demuxer, decoder, then re-encode it all.  I am trying to avoid the decoding / 
> re-encoding of the existing mp4.
> 
> Is this even possible?
> 
> Thanks,
> Steve Williams

If I'm wrong, someone will hopefully correct me, but I think that you can simply concatenate mp4 
streams with 'cat' with binary option (as though they were RIFF images or MP3 audios). If so, simply 
make an incremental mp4 of the current 'frame' -- I don't know how to do that -- and then 'cat' it 
to the existing 'movie'. Give it a try.



More information about the ffmpeg-user mailing list