<div dir="ltr">No, it is not related to the decoder output. Decoder has `skip-frames` option as well, but it is not useful since it is<div>the encoder which drops frames.<br><div>My problem is that those timestamps are different every time I run the code. Looks like they are absolute,</div><div>not relative to the beginning of the video. Is this intended?</div><div><br><div class="gmail_quote"><div dir="ltr">On Thu, Jul 26, 2018 at 8:58 AM Steve Lhomme <<a href="mailto:robux4@ycbcr.xyz">robux4@ycbcr.xyz</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 24/07/2018 21:59, Paweł Wegner wrote:<br>
> Encoder will encode only one frame per timestamp. Since timestamps may be<br>
> inaccurate, skipping frames may render encoder's output nondeterministic.<br>
> Added an option which instructs to encode all frames which come out of avcodec.<br>
<br>
Is this related to the output of the avcodec decoder ? Because that's <br>
how I understand the commit log and doc of the option. But the option is <br>
on the encoder, which may receive frames from other decoders.<br>
<br>
> ---<br>
> modules/codec/avcodec/avcodec.c | 3 +++<br>
> modules/codec/avcodec/avcodec.h | 6 ++++++<br>
> modules/codec/avcodec/encoder.c | 32 ++++++++++++++++++--------------<br>
> 3 files changed, 27 insertions(+), 14 deletions(-)<br>
><br>
> diff --git a/modules/codec/avcodec/avcodec.c b/modules/codec/avcodec/avcodec.c<br>
> index 0e08c11fc6..d5df52871a 100644<br>
> --- a/modules/codec/avcodec/avcodec.c<br>
> +++ b/modules/codec/avcodec/avcodec.c<br>
> @@ -235,6 +235,9 @@ vlc_module_begin ()<br>
> ENC_PROFILE_TEXT, ENC_PROFILE_LONGTEXT, true )<br>
> <br>
> add_string( ENC_CFG_PREFIX "options", NULL, AV_OPTIONS_TEXT, AV_OPTIONS_LONGTEXT, true )<br>
> +<br>
> + add_bool( ENC_CFG_PREFIX "skip-frames", true,<br>
> + ENC_SKIP_FRAMES_TEXT, ENC_SKIP_FRAMES_LONGTEXT, true )<br>
> #endif /* ENABLE_SOUT */<br>
> <br>
> #ifdef MERGE_FFMPEG<br>
> diff --git a/modules/codec/avcodec/avcodec.h b/modules/codec/avcodec/avcodec.h<br>
> index 52e522dc32..2900b86b3a 100644<br>
> --- a/modules/codec/avcodec/avcodec.h<br>
> +++ b/modules/codec/avcodec/avcodec.h<br>
> @@ -233,6 +233,12 @@ int ffmpeg_OpenCodec( decoder_t *p_dec, AVCodecContext *, const AVCodec * );<br>
> "main, low, ssr (not supported),ltp, hev1, hev2 (default: low). " \<br>
> "hev1 and hev2 are currently supported only with libfdk-aac enabled libavcodec" )<br>
> <br>
> +#define ENC_SKIP_FRAMES_TEXT N_( "Skip frames" )<br>
> +#define ENC_SKIP_FRAMES_LONGTEXT N_( "Encoder will encode only one frame \<br>
> + per timestamp. Since timestamps may be inaccurate, skipping frames may \<br>
> + render encoder's output nondeterministic. Disable in order to encode all frames \<br>
> + which come out of avcodec." )<br>
> +<br>
> #ifndef AV_VERSION_INT<br>
> # define AV_VERSION_INT(a, b, c) ((a)<<16 | (b)<<8 | (c))<br>
> #endif<br>
> diff --git a/modules/codec/avcodec/encoder.c b/modules/codec/avcodec/encoder.c<br>
> index a00439e939..7c1082c099 100644<br>
> --- a/modules/codec/avcodec/encoder.c<br>
> +++ b/modules/codec/avcodec/encoder.c<br>
> @@ -144,6 +144,7 @@ typedef struct<br>
> int i_quality; /* for VBR */<br>
> float f_lumi_masking, f_dark_masking, f_p_masking, f_border_masking;<br>
> int i_aac_profile; /* AAC profile to use.*/<br>
> + bool b_skip_frames;<br>
> <br>
> AVFrame *frame;<br>
> } encoder_sys_t;<br>
> @@ -193,7 +194,7 @@ static const char *const ppsz_enc_options[] = {<br>
> "interlace", "interlace-me", "i-quant-factor", "noise-reduction", "mpeg4-matrix",<br>
> "trellis", "qscale", "strict", "lumi-masking", "dark-masking",<br>
> "p-masking", "border-masking",<br>
> - "aac-profile", "options",<br>
> + "aac-profile", "options", "skip-frames",<br>
> NULL<br>
> };<br>
> <br>
> @@ -419,6 +420,7 @@ int InitVideoEnc( vlc_object_t *p_this )<br>
> p_sys->f_rc_buffer_aggressivity = var_GetFloat( p_enc, ENC_CFG_PREFIX "rc-buffer-aggressivity" );<br>
> p_sys->f_i_quant_factor = var_GetFloat( p_enc, ENC_CFG_PREFIX "i-quant-factor" );<br>
> p_sys->b_mpeg4_matrix = var_GetBool( p_enc, ENC_CFG_PREFIX "mpeg4-matrix" );<br>
> + p_sys->b_skip_frames = var_GetBool( p_enc, ENC_CFG_PREFIX "skip-frames" );<br>
> <br>
> f_val = var_GetFloat( p_enc, ENC_CFG_PREFIX "qscale" );<br>
> <br>
> @@ -1213,21 +1215,23 @@ static block_t *EncodeVideo( encoder_t *p_enc, picture_t *p_pict )<br>
> <br>
> if ( ( frame->pts != AV_NOPTS_VALUE ) && ( frame->pts != VLC_TICK_INVALID ) )<br>
> {<br>
> - if ( p_sys->i_last_pts == frame->pts )<br>
> + if ( p_sys->b_skip_frames )<br>
> {<br>
> - msg_Warn( p_enc, "almost fed libavcodec with two frames with "<br>
> - "the same PTS (%"PRId64 ")", frame->pts );<br>
> - return NULL;<br>
> - }<br>
> - else if ( p_sys->i_last_pts > frame->pts )<br>
> - {<br>
> - msg_Warn( p_enc, "almost fed libavcodec with a frame in the "<br>
> - "past (current: %"PRId64 ", last: %"PRId64")",<br>
> - frame->pts, p_sys->i_last_pts );<br>
> - return NULL;<br>
> + if ( p_sys->i_last_pts == frame->pts )<br>
> + {<br>
> + msg_Warn( p_enc, "almost fed libavcodec with two frames with "<br>
> + "the same PTS (%"PRId64 ")", frame->pts );<br>
> + return NULL;<br>
> + }<br>
> + else if ( p_sys->i_last_pts > frame->pts )<br>
> + {<br>
> + msg_Warn( p_enc, "almost fed libavcodec with a frame in the "<br>
> + "past (current: %"PRId64 ", last: %"PRId64")",<br>
> + frame->pts, p_sys->i_last_pts );<br>
> + return NULL;<br>
> + }<br>
> }<br>
> - else<br>
> - p_sys->i_last_pts = frame->pts;<br>
> + p_sys->i_last_pts = frame->pts;<br>
> }<br>
> <br>
> frame->quality = p_sys->i_quality;<br>
> -- <br>
> 2.17.1<br>
><br>
> _______________________________________________<br>
> vlc-devel mailing list<br>
> To unsubscribe or modify your subscription options:<br>
> <a href="https://mailman.videolan.org/listinfo/vlc-devel" rel="noreferrer" target="_blank">https://mailman.videolan.org/listinfo/vlc-devel</a><br>
<br>
_______________________________________________<br>
vlc-devel mailing list<br>
To unsubscribe or modify your subscription options:<br>
<a href="https://mailman.videolan.org/listinfo/vlc-devel" rel="noreferrer" target="_blank">https://mailman.videolan.org/listinfo/vlc-devel</a></blockquote></div></div></div></div>