Some of the GStreamer examples (e.g. converting to webm, playing a video) use the whole file from start to finish.
But with GStreamer and GNonLin, it's possible to only work with a segment of a video file.
Here's how to play 2 seconds of file video.mov
, starting 10 seconds in:
gst-launch gnlfilesource location=file:///path/to/my/video.mov media-start=10000000000 media-duration=2000000000 ! autovideosink
gnlfilesource
This is the source element (like filesrc
) that plays only a portion of the file. The media-*
properties control the when in the original to play (media-start
), and how much to play (media-duration
). All times are given in nanoseconds, so 10 seconds is 10000000000 nanoseconds (9 extra zeros).
You also have to specify the full file path in the location
parameter, unlike filesrc
. If you're playing from a local file (as opposed to a remote URL), you have to include a file://
. That means there are 3 /
's at the start.
Annoyingly it's called gnlfilesource
, not gnlfilesrc
, it's inconsistant with the main gstreamer filesrc
.
No decodebin
You don't need a decodebin
element here (like you do when playing a video) because gnlfilesource
decodes it itself, that's how it knows how far into the file to play.