[vlc-devel] [PATCH] negative stop-time causes offset from the end
Aleksandr Pasechnik
al at megamicron.net
Sat Mar 21 01:40:53 CET 2015
Negative stop-time, for example -N seconds, causes the stream to stop N seconds
before the end.
Original code suggestion by MooseSoftware in the forum.videolan.org
---
src/input/input.c | 10 ++++++++++
src/libvlc-module.c | 3 ++-
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/src/input/input.c b/src/input/input.c
index 7de30ec..a8210f6 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -900,6 +900,16 @@ static void StartTitle( input_thread_t * p_input )
msg_Warn( p_input, "invalid run-time ignored" );
p_input->p->i_run = 0;
}
+ if( p_input->p->i_stop < 0 )
+ {
+ mtime_t duration = input_item_GetDuration( p_input->p->p_item );
+ if( duration > 0 && duration + p_input->p->i_stop > 0 )
+ {
+ p_input->p->i_stop = duration + p_input->p->i_stop;
+ msg_Dbg( p_input, "recalculated stop-time to %ds",
+ (int) p_input->p->i_stop );
+ }
+ }
if( p_input->p->i_start > 0 )
{
diff --git a/src/libvlc-module.c b/src/libvlc-module.c
index 31037b4..aaba078 100644
--- a/src/libvlc-module.c
+++ b/src/libvlc-module.c
@@ -627,7 +627,8 @@ static const char *const ppsz_prefres[] = {
#define STOP_TIME_TEXT N_("Stop time")
#define STOP_TIME_LONGTEXT N_( \
- "The stream will stop at this position (in seconds)." )
+ "The stream will stop at this position (in seconds). " \
+ "Negative values are subtracted from the end of the stream." )
#define RUN_TIME_TEXT N_("Run time")
#define RUN_TIME_LONGTEXT N_( \
--
2.3.3
More information about the vlc-devel
mailing list