Extract a frame from an MJPEG file by specifying the wall-clock time at which it was captured?
gstreamer at beta-engine.net
Thu Jul 25 13:33:45 UTC 2019
I capture video from a camera to a file in MJPEG format like so:
$ gst-launch-1.0 nvarguscamerasrc do-timestamp=true \
! 'video/x-raw(memory:NVMM), width=3280, height=2464' \
! nvjpegenc \
! matroskamux \
! filesink location=out.mkv
And I've found I can extract all the frames to individual JPEG files like
$ gst-launch-1.0 filesrc location=out.mkv \
! matroskademux \
! multifilesink location=out-%05d.jpg
But that's not what I want to do, I want to extract a particular frame by
specifying the wall-clock time at which it was captured.
E.g. if I started recording a video at 17:05:32UTC and recorded for 5
minutes, I'd later like to be able to extract a frame from the resulting
file by specifying that it was captured at e.g. 17:07:40UTC.
I.e. I want to work with absolute times, that depend on when the video was
captured, rather than times relative to the start of the video file - so
17:07:40UTC rather than 2m 8s.
I apologize for the cargo-cult nature of my pipelines. I added
do-timestamp=true because it sounded like a "good thing" but I don't know
what impact it has. Similarly, I chose Matroska because
https://www.linuxtv.org/wiki/index.php/GStreamer said that it, in contrast
to AVI and other formats, supports timestamps, but again I don't really
know on what level this applies and whether it's relevant to what I want to
So the container format is unimportant to me - I'm even happy to switch
from MJPEG to something else if it makes the task easier.
I was hoping that it might be as simple as that the wall-clock time could
be included as EXIF data in the individual JPEG images of the MJPEG file.
And then something could search the MJPEG file for the JPEG frame with the
requested wall-clock time in its EXIF data and extract it.
PS I know I'm abusing the term wall clock time. Generally, it means a time
of day without a time zone. But here I just wanted to be clear I meant an
externally defined time as opposed to e.g. the number of milliseconds since
the start of a file. In practice, I'd be expecting to express times as
absolute points in time e.g. 2007-04-05T14:30.123Z (ISO 8601).
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the gstreamer-devel