To expand on LordNeckbeard's answer, yes, just mux the JPEG data into an MJPEG video stream. That will be the smallest representation of the exact sequence of output images, even though MJPEG is a terribly inefficient codec by today's standards. (no temporal redundancy, and not even any intra prediction.
You can make a variable-framerate MJPEG video to take advantage of the duplicate images in your input.
ffmpeg -framerate 30 -i input%03d.jpg -vf mpdecimate -codec copy output.mkv # doesn't work.
Hrm, this isn't going to work, since mpdecimate won't work on compressed data, and we can't let ffmpeg decode and then re-jpeg the image data without loss and CPU cost.
Maybe if you replaced duplicate jpg source files with empty files with that sequence number, or something?
Since this question isn't even recent, I'm not going to take the time to figure out how to do it unless someone replies to ask how. But since MJPEG can go into an mkv container, I'm sure it's possible to have a file that doesn't duplicate the jpeg data for repeated frames, but instead just doesn't have an output frame to decode until the sequence of duplicates is over.
Oh here's an idea:
ffmpeg -framerate blah -input blah -vf mpdecimate -f mkvtimestamp_v2 mpdecimate.timestamps
Then remove (or move aside) all the jpegs for frames that mpdecimate wants to drop (probably it has some logging options? Or -vf showinfo, and parse that, and move or hardlink only the frames that show up in its output, leaving behind the dropped JPEGs?). mux that to a MJPEG.mkv, then do something with mkvmerge to replace the frame timestamps in that with the timestamps from
If you were xcoding, instead of just muxing jpeg data to MJPEG, this would be MUCH easier, since you'd just use my first command with mpdecimate and any codec other than
copy, and it would Just Work(tm).
I haven't tried any of this, since this was an old question. Also the reason I haven't filled in the gaps of how to actually filter your directory of jpegs based on mpdecimate output, or how to actually use the timestamp stream.