vlc | branch: master | Thomas Guillem <[email protected]> | Tue Jan 15 13:24:30 2019 +0100| [25d263a6613a7e856999033b0c69026f6da20c4f] | committer: Steve Lhomme
mux: avformat: add an option to reset timestamps > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=25d263a6613a7e856999033b0c69026f6da20c4f --- modules/codec/avcodec/avcommon.h | 3 +++ modules/demux/avformat/avformat.c | 1 + modules/demux/avformat/mux.c | 11 ++++++++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/modules/codec/avcodec/avcommon.h b/modules/codec/avcodec/avcommon.h index 9e43db4360..d2f5630acb 100644 --- a/modules/codec/avcodec/avcommon.h +++ b/modules/codec/avcodec/avcommon.h @@ -60,6 +60,9 @@ #define AV_OPTIONS_TEXT N_("Advanced options") #define AV_OPTIONS_LONGTEXT N_("Advanced options, in the form {opt=val,opt2=val2}.") +#define AV_RESET_TS_TEXT N_("Reset timestamps") +#define AV_RESET_TS_LONGTEXT N_("The muxed content will start near a 0 timestamp.") + static inline void vlc_av_get_options(const char *psz_opts, AVDictionary** pp_dict) { config_chain_t *cfg = NULL; diff --git a/modules/demux/avformat/avformat.c b/modules/demux/avformat/avformat.c index 8025a898b6..12d3881a21 100644 --- a/modules/demux/avformat/avformat.c +++ b/modules/demux/avformat/avformat.c @@ -57,6 +57,7 @@ vlc_module_begin () add_string( "sout-avformat-mux", NULL, MUX_TEXT, MUX_LONGTEXT, true ) add_obsolete_string("ffmpeg-mux") /* removed since 2.1.0 */ add_string( "sout-avformat-options", NULL, AV_OPTIONS_TEXT, AV_OPTIONS_LONGTEXT, true ) + add_bool( "sout-avformat-reset-ts", false, AV_RESET_TS_TEXT, AV_RESET_TS_LONGTEXT, true ) set_callbacks( avformat_OpenMux, avformat_CloseMux ) #endif #ifndef MERGE_FFMPEG diff --git a/modules/demux/avformat/mux.c b/modules/demux/avformat/mux.c index 215bcfb0a8..9b9d6c07f1 100644 --- a/modules/demux/avformat/mux.c +++ b/modules/demux/avformat/mux.c @@ -45,7 +45,7 @@ //#define AVFORMAT_DEBUG 1 static const char *const ppsz_mux_options[] = { - "mux", "options", NULL + "mux", "options", "reset-ts", NULL }; /***************************************************************************** @@ -65,6 +65,7 @@ typedef struct #if LIBAVFORMAT_VERSION_CHECK( 57, 7, 0, 40, 100 ) bool b_header_done; #endif + bool b_reset_ts; } sout_mux_sys_t; /***************************************************************************** @@ -151,6 +152,7 @@ int avformat_OpenMux( vlc_object_t *p_this ) p_sys->io->write_data_type = IOWriteTyped; p_sys->b_header_done = false; #endif + p_sys->b_reset_ts = var_GetBool( p_mux, "sout-avformat-reset-ts" ); /* Fill p_mux fields */ p_mux->pf_control = Control; @@ -371,8 +373,15 @@ static int MuxBlock( sout_mux_t *p_mux, sout_input_t *p_input ) } if( p_data->i_pts > 0 ) + { + if( p_sys->b_reset_ts ) + { + p_sys->oc->output_ts_offset = -p_data->i_pts; + p_sys->b_reset_ts = false; + } pkt.pts = TO_AV_TS(p_data->i_pts * p_stream->time_base.den / CLOCK_FREQ / p_stream->time_base.num); + } if( p_data->i_dts > 0 ) pkt.dts = TO_AV_TS(p_data->i_dts * p_stream->time_base.den / CLOCK_FREQ / p_stream->time_base.num); _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
