Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
dc88eb65
Commit
dc88eb65
authored
Jan 16, 2018
by
Jacob Walser
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Correct video file timestamping issues
parent
0e0d3073
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
0 deletions
+36
-0
VideoReceiver.cc
src/VideoStreaming/VideoReceiver.cc
+35
-0
VideoReceiver.h
src/VideoStreaming/VideoReceiver.h
+1
-0
No files found.
src/VideoStreaming/VideoReceiver.cc
View file @
dc88eb65
...
...
@@ -674,6 +674,14 @@ VideoReceiver::startRecording(const QString &videoFile)
gst_element_sync_state_with_parent
(
_sink
->
mux
);
gst_element_sync_state_with_parent
(
_sink
->
filesink
);
// Install a probe on the recording branch to drop buffers until we hit our first keyframe
// When we hit our first keyframe, we can offset the timestamps appropriately according to the first keyframe time
// This will ensure the first frame is a keyframe at t=0, and decoding can begin immediately on playback
GstPad
*
probepad
=
gst_element_get_static_pad
(
_sink
->
queue
,
"src"
);
gst_pad_add_probe
(
probepad
,
(
GstPadProbeType
)(
GST_PAD_PROBE_TYPE_BUFFER
/* | GST_PAD_PROBE_TYPE_BLOCK */
),
_keyframeWatch
,
this
,
NULL
);
// to drop the buffer or to block the buffer?
gst_object_unref
(
probepad
);
// Link the recording branch to the pipeline
GstPad
*
sinkpad
=
gst_element_get_static_pad
(
_sink
->
queue
,
"sink"
);
gst_pad_link
(
_sink
->
teepad
,
sinkpad
);
gst_object_unref
(
sinkpad
);
...
...
@@ -802,6 +810,33 @@ VideoReceiver::_unlinkCallBack(GstPad* pad, GstPadProbeInfo* info, gpointer user
}
#endif
//-----------------------------------------------------------------------------
#if defined(QGC_GST_STREAMING)
GstPadProbeReturn
VideoReceiver
::
_keyframeWatch
(
GstPad
*
pad
,
GstPadProbeInfo
*
info
,
gpointer
user_data
)
{
Q_UNUSED
(
pad
);
if
(
info
!=
NULL
&&
user_data
!=
NULL
)
{
GstBuffer
*
buf
=
gst_pad_probe_info_get_buffer
(
info
);
if
(
GST_BUFFER_FLAG_IS_SET
(
buf
,
GST_BUFFER_FLAG_DELTA_UNIT
))
{
// wait for a keyframe
return
GST_PAD_PROBE_DROP
;
}
else
{
VideoReceiver
*
pThis
=
(
VideoReceiver
*
)
user_data
;
// reset the clock
GstClock
*
clock
=
gst_pipeline_get_pipeline_clock
(
GST_PIPELINE
(
pThis
->
_pipeline
));
GstClockTime
time
=
gst_clock_get_time
(
clock
);
gst_object_unref
(
clock
);
gst_element_set_base_time
(
pThis
->
_pipeline
,
time
);
// offset pipeline timestamps to start at zero again
buf
->
dts
=
0
;
// The offset will not apply to this current buffer, our first frame, timestamp is zero
buf
->
pts
=
0
;
qCDebug
(
VideoReceiverLog
)
<<
"Got keyframe, stop dropping buffers"
;
}
}
return
GST_PAD_PROBE_REMOVE
;
}
#endif
//-----------------------------------------------------------------------------
void
VideoReceiver
::
_updateTimer
()
...
...
src/VideoStreaming/VideoReceiver.h
View file @
dc88eb65
...
...
@@ -119,6 +119,7 @@ private:
static
gboolean
_onBusMessage
(
GstBus
*
bus
,
GstMessage
*
message
,
gpointer
user_data
);
static
GstPadProbeReturn
_unlinkCallBack
(
GstPad
*
pad
,
GstPadProbeInfo
*
info
,
gpointer
user_data
);
static
GstPadProbeReturn
_keyframeWatch
(
GstPad
*
pad
,
GstPadProbeInfo
*
info
,
gpointer
user_data
);
void
_detachRecordingBranch
(
GstPadProbeInfo
*
info
);
void
_shutdownRecordingBranch
();
void
_shutdownPipeline
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment