From 43449034382b1cf64c25cdf27f489baad3f7a0a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matt=C3=A9o=20Delabre?= Date: Fri, 3 Apr 2020 11:25:20 +0200 Subject: [PATCH] Fix recorded videos playing back too fast MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use the `setpts` video filter to set each frame’s presentation timestamp to the time it is received by the encoder. See . --- reStream.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/reStream.sh b/reStream.sh index 6e5e138..8cdbf2a 100755 --- a/reStream.sh +++ b/reStream.sh @@ -79,12 +79,13 @@ fi output_args=() +video_filters=() # calculate how much bytes the window is window_bytes="$(($width*$height*$bytes_per_pixel))" # rotate 90 degrees if landscape=true -$landscape && output_args+=('-vf' 'transpose=1') +$landscape && video_filters+=('transpose=1') # read the first $window_bytes of the framebuffer head_fb0="dd if=/dev/fb0 count=1 bs=$window_bytes 2>/dev/null" @@ -104,6 +105,12 @@ else output_args+=("$output_path") fi +# set frame presentation time to the time it was received +video_filters+=('setpts=(RTCTIME - RTCSTART) / (TB * 1000000)') + +joined_filters=$(IFS=,; echo "${video_filters[*]}") +output_args+=('-vf' "$joined_filters") + set -e # stop if an error occurs $ssh_cmd "$read_loop" \