Process videos in a single phase
ffmpeg can be fed decoded frames with a pipe and transcode them on-fly instead of having to go through all the files again after dcraw step is completed.
Also, the conversion step to JPG is completely unnecessary and only makes the resulting quality worse while taking more time. It should be dropped.