[vlc-devel] Re: [Patch] Allow DV sources to skip frames

Jean-Paul Saman jean-paul.saman at planet.nl
Sun Apr 22 11:24:08 CEST 2007


Paul,

Did you try --sout-transcode-hurry-up ? it drops frames if the CPU can't 
keep up. Also add --cr-average=1000.

Does your problem persist?

Regards,
Jean-Paul Saman.

Paul Corke wrote:
> I have a DV source (a Canopus ADVC300) that occasionally drops
> frames (maybe 1 every 10 or 20 seconds) for some reason.
> 
> This causes a problem when streaming with VLC.  Because the rawdv
> demux just increments it's PTS every time it gets a frame from
> the source, it eventually drops behind real time (ie mdate()
> increments faster that p_sys->i_pcr).  This results in a lot of:
> 
> [00000357] stream_out_transcode private debug: late picture skipped
> (41806)
> [00000357] stream_out_transcode private debug: late picture skipped
> (32943)
> [00000357] stream_out_transcode private debug: late picture skipped
> (23502)
> [00000357] stream_out_transcode private debug: late picture skipped
> (15668)
> [00000357] stream_out_transcode private debug: late picture skipped
> (38214)
> 
> which means no more stream (there is no way for p_sys->i_pcr to
> ever catch up).
> 
> The enclosed patch uses the current mdate() timestamp to calculate
> the PTS for each frame.  This means that the DV source can stop
> sending frames for a while, and when it starts up again vlc will
> carry on streaming the content.  To turn on the new behaviour,
> set the "rawdv-realtime" variable.  Example use:
> 
> dvgrab - \
> | vlc -vvv --intf dummy --no-sub-autodetect-file - \
> :demux=rawdv :rawdv-realtime=1 --sout '#something'
> 
> This is only useful for live streaming of DV content, and cases
> where you don't want the occasional dropped frame to break the
> stream.
> 
> Regards,
> 
> Paul.
> 
> 
> ------------------------------------------------------------------------
> 
> Index: modules/demux/rawdv.c
> ===================================================================
> --- modules/demux/rawdv.c	(revision 19759)
> +++ modules/demux/rawdv.c	(working copy)
> @@ -5,6 +5,7 @@
>   * $Id$
>   *
>   * Authors: Gildas Bazin <gbazin at netcourrier.com>
> + *          Paul Corke <paul dot corke at datatote dot co dot uk>
>   *
>   * This program is free software; you can redistribute it and/or modify
>   * it under the terms of the GNU General Public License as published by
> @@ -32,6 +33,9 @@
>  /*****************************************************************************
>   * Module descriptor
>   *****************************************************************************/
> +#define RT_TEXT N_("Realtime")
> +#define RT_LONGTEXT N_("Allow DV source to send frames when it wants.")
> +
>  static int  Open ( vlc_object_t * );
>  static void Close( vlc_object_t * );
>  
> @@ -41,6 +45,7 @@
>      set_capability( "demux2", 2 );
>      set_category( CAT_INPUT );
>      set_subcategory( SUBCAT_INPUT_DEMUX );
> +    add_bool( "rawdv-realtime", 0, NULL, RT_TEXT, RT_LONGTEXT, VLC_FALSE );
>      set_callbacks( Open, Close );
>      add_shortcut( "rawdv" );
>  vlc_module_end();
> @@ -104,6 +109,7 @@
>  
>      /* program clock reference (in units of 90kHz) */
>      mtime_t i_pcr;
> +    vlc_bool_t b_realtime;
>  };
>  
>  /*****************************************************************************
> @@ -122,6 +128,7 @@
>  {
>      demux_t     *p_demux = (demux_t*)p_this;
>      demux_sys_t *p_sys;
> +    vlc_value_t val;
>  
>      byte_t      *p_peek, *p_peek_backup;
>  
> @@ -202,6 +209,11 @@
>      p_demux->pf_control = Control;
>      p_demux->p_sys      = p_sys = malloc( sizeof( demux_sys_t ) );
>  
> +    var_Create( p_demux, "rawdv-realtime", VLC_VAR_BOOL|VLC_VAR_DOINHERIT );
> +    var_Get( p_demux, "rawdv-realtime", &val);
> +    p_sys->b_realtime = val.b_bool;
> +    msg_Dbg( p_demux, "Realtime DV Source: %s", (p_sys->b_realtime)?"Yes":"No" );
> +
>      p_sys->i_dsf = dv_header.dsf;
>      p_sys->frame_size = dv_header.dsf ? 12 * 150 * 80 : 10 * 150 * 80;
>      p_sys->f_rate = dv_header.dsf ? 25 : 29.97;
> @@ -278,6 +290,11 @@
>      block_t     *p_block;
>      vlc_bool_t  b_audio = VLC_FALSE;
>  
> +    if( p_sys->b_realtime )
> +    {
> +        p_sys->i_pcr = mdate() + (p_sys->i_dsf ? 120000 : 90000); /* 3 frames */
> +    }
> +
>      /* Call the pace control */
>      es_out_Control( p_demux->out, ES_OUT_SET_PCR, p_sys->i_pcr );
>  
> @@ -309,7 +326,10 @@
>  
>      es_out_Send( p_demux->out, p_sys->p_es_video, p_block );
>  
> -    p_sys->i_pcr += ( I64C(1000000) / p_sys->f_rate );
> +    if( !p_sys->b_realtime )
> +    {
> +        p_sys->i_pcr += ( I64C(1000000) / p_sys->f_rate );
> +    }
>  
>      return 1;
>  }

-- 
This is the vlc-devel mailing-list, see http://www.videolan.org/vlc/
To unsubscribe, please read http://developers.videolan.org/lists.html



More information about the vlc-devel mailing list