vlc/vlc-3.0 | branch: master | Thomas Guillem <[email protected]> | Tue Jan 15 13:24:30 2019 +0100| [be297fda17f1b348e68ec36d3265c27748ac65ba] | committer: Thomas Guillem
mux: avformat: add an option to reset timestamps (cherry picked from commit 25d263a6613a7e856999033b0c69026f6da20c4f) Signed-off-by: Thomas Guillem <[email protected]> > http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=be297fda17f1b348e68ec36d3265c27748ac65ba --- 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 65ad35f4ad..8c8298014f 100644 --- a/modules/codec/avcodec/avcommon.h +++ b/modules/codec/avcodec/avcommon.h @@ -46,6 +46,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 "Reset timestamps" +#define AV_RESET_TS_LONGTEXT "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 9500c915b4..b838dd4816 100644 --- a/modules/demux/avformat/mux.c +++ b/modules/demux/avformat/mux.c @@ -44,7 +44,7 @@ //#define AVFORMAT_DEBUG 1 static const char *const ppsz_mux_options[] = { - "mux", "options", NULL + "mux", "options", "reset-ts", NULL }; /***************************************************************************** @@ -64,6 +64,7 @@ struct sout_mux_sys_t #if LIBAVFORMAT_VERSION_CHECK( 57, 7, 0, 40, 100 ) bool b_header_done; #endif + bool b_reset_ts; }; /***************************************************************************** @@ -150,6 +151,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; @@ -361,8 +363,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 = p_data->i_pts * p_stream->time_base.den / CLOCK_FREQ / p_stream->time_base.num; + } if( p_data->i_dts > 0 ) pkt.dts = 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
