Just mux the images
You can simply mux the JPG images to make a video:
ffmpeg -framerate 30 -i input%03d.jpg -codec copy output.mkv
Note that if you omit -framerate
then a default of -framerate 25
will be applied to the input.
Lossless optimization
You can use jpegtran
to perform lossless optimization on each frame which may provide significant file size savings:
mkdir outputdir
for f in *.jpg; do jpegtran -optimize -copy none -perfect -v "$f" > "outputdir/$f"; done
Now mux with ffmpeg
as shown above.
Checking that it is actually lossless
The framehash muxer can be used to compare the unique hash of each frame to ensure that the result is truly lossless:
$ ffmpeg -i input%03d.jpg -f framehash -
stream_index, packet_dts, packet_pts, packet_duration, packet_size, hash
0, 0, 0, 1, 460800, 29bcc2db3726c7dfec1826c5740f603f
0, 1, 1, 1, 460800, b5fdc23d93cbd043dc2b9290dc8378f0
0, 2, 2, 1, 460800, ee0709942f24b458fd2380d134dcb59d
...
$ ffmpeg -i output.mkv -map 0:v -f framehash -
stream_index, packet_dts, packet_pts, packet_duration, packet_size, hash
0, 0, 0, 1, 460800, 29bcc2db3726c7dfec1826c5740f603f
0, 1, 1, 1, 460800, b5fdc23d93cbd043dc2b9290dc8378f0
0, 2, 2, 1, 460800, ee0709942f24b458fd2380d134dcb59d
...
In the above examples each associated frame for the input and output share the same hash ensuring that the frames are identical and that the output is lossless.
Also see