In this posting I will show how to take high framerate raspivid videos (90fps with v1 camera, 120fps with older Raspbian or 180fps with newest Stretch with v2 camera), add readable millisecond precision time overlay to the video, cut out relevant part of it, convert it to 30fps video (the maximum youtube allows for in case video is less than 720p, which mode 7 VGA resolution is).
In posting viewtopic.php?f=43&t=206047&p=1294557#p1294557 I described the steps needed after raspivid video capture to associate each frame in video with its recorded timestamp.
Here I will show complete steps doing that, and finally upload to youtube as 30fps video. For the 180fps video I took that will result in 6x slower play speed than real, but the time overlay gives you exact information on time (youtube does not show sub second time).
- record 180fps VGA video and generate timestamp file:
Code: Select all
$ raspivid -md 7 -w 640 -h 480 -t 8000 -fps 180 -pts t.pts -o t.h264
- combine generated t.h264 and t.pts into Matroska video with timestamps:
Code: Select all
$ mkvmerge -o t.mkv --timecodes 0:t.pts t.h264
- post process that video for 90° rotation and (millisecond resolution) timeoverlay addition with gstreamer pipeline:
Code: Select all
$ gst-launch-1.0 -v filesrc location=t.mkv ! matroskademux ! h264parse ! avdec_h264 ! videoflip method=clockwise ! timeoverlay time-mode="buffer-time" shaded-background=true ! x264enc ! matroskamux ! filesink location=tt.mkv
- cut out the interesting part of the video generated sofar:
Code: Select all
$ ffmpeg -ss 0.1 -i tt.mkv -vframes 117 t2.mkv
- convert that video to 30fps fixed framerate video for youtube upload (you can take 25fps if you like as well):
Code: Select all
$ mkvmerge -o t30.mkv --default-duration 0:30fps t2.mkv
- youtube cannot upload Matroska video, convert to .avi for upload
Code: Select all
$ ffmpeg -i t30.mkv -c:v copy -c:a copy t30.avi
Code: Select all
0.1 + 0.481*6 = 2.986 ==> "0:02" in youtube time bar

Reminder:
After starting the video, stop it.
With right clicking you can select "Loop", that keeps the video playing again and again.
Instead of starting the video again, you can alternatively single step fore/back with keys "."/",".
Keeping the "," key pressed allows you to see video played backwards.
Clicking on "Settings" you can select playback speed in range 0.25 to 2.