Ffmpeg guru help wanted: adding timestamp to video

This is really not directly webcam related, but rather has to do with timelapse settings. I'm trying to improve on a script I have created to add a timestamp to the resulting timelapse video. At this point I have the following script:

#!/bin/bash

watermark=~/oprint/lib/python3.7/site-packages/octoprint/static/img/watermark.png
timestampfont=/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf
ffmpeg=$1
fps=$2
input=$3
videocodec=$4
threads=$5
bitrate=$6
containerformat=$7
output=$8
tmpfile=/var/tmp/$$_timelapse_raw.h264

filter="[in] drawtext=fontfile=${timestampfont}: text='%{pts \: hms}': x=10 : y=10 : box=1 : boxborderw=3 : fontsize=32 [timestamped];"
filter="${filter} movie='${watermark}' [wm]; [timestamped][wm] overlay=10:main_h-overlay_h-10 [out]"

nice "${ffmpeg}" -ts_from_file 1 -vsync drop -i "${input}" -vcodec "${videocodec}" -threads "${threads}" -filter:v "${filter}" \
    -r ${fps} -y "${tmpfile}" && \
    nice "${ffmpeg}" -fflags +genpts -r "${fps}" -i "${tmpfile}" -c:v ${videocodec} -b:v ${bitrate} -threads "${threads}" \
        -f "${containerformat}" -y "${output}"
ret=$?
rm -f "${tmpfile}"
exit $ret

This works, but tends to create a large temporary file, and obviously takes a long time due to the two passes needed for the encode. Also, I'm encoding to mp4 and then encoding again to bring down the bit rate.
My original test set the bitrate for the first pass and used -c:v copy for the second pass, but it looks like this caused the bitrate to be ignored because I ended up with files with 14x the bitrate specified. I also attempted to do it all in one pass, but that ended up erroring out.
Anyone intimately familiar with ffmpeg that can give me a hand with this?