<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://avisynth.nl/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://avisynth.nl/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=JamesJohnston</id>
		<title>Avisynth wiki - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="http://avisynth.nl/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=JamesJohnston"/>
		<link rel="alternate" type="text/html" href="http://avisynth.nl/index.php/Special:Contributions/JamesJohnston"/>
		<updated>2026-04-07T21:18:25Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.19.24</generator>

	<entry>
		<id>http://avisynth.nl/index.php/LSMASHSource/LWLibavVideoSource</id>
		<title>LSMASHSource/LWLibavVideoSource</title>
		<link rel="alternate" type="text/html" href="http://avisynth.nl/index.php/LSMASHSource/LWLibavVideoSource"/>
				<updated>2024-08-04T04:35:20Z</updated>
		
		<summary type="html">&lt;p&gt;JamesJohnston: Add note stating that FPS must be explicitly set when working with AVI files that have null/drop frames&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;div style=&amp;quot;max-width:62em&amp;quot; &amp;gt;&lt;br /&gt;
{{FilterCat|External_filters|Plugin_functions|Source_filters}}&lt;br /&gt;
This function uses [http://en.wikipedia.org/wiki/Libav#Video_codecs libavcodec] as a video decoder and libavformat as a demuxer.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
== [[Script variables|Syntax and Parameters]] ==&lt;br /&gt;
:{{Template:FuncDef|LWLibavVideoSource (string source, int &amp;quot;stream_index&amp;quot;, int &amp;quot;threads&amp;quot;, bool &amp;quot;cache&amp;quot;, string &amp;quot;cachefile&amp;quot;, int &amp;quot;seek_mode&amp;quot;, int &amp;quot;seek_threshold&amp;quot;, bool &amp;quot;dr&amp;quot;, int &amp;quot;fpsnum&amp;quot;, int &amp;quot;fpsden&amp;quot;, bool &amp;quot;repeat&amp;quot;, int &amp;quot;dominance&amp;quot;, string &amp;quot;format&amp;quot;, string &amp;quot;decoder&amp;quot;, int &amp;quot;prefer_hw&amp;quot;, int &amp;quot;ff_loglevel&amp;quot;)}}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
::{{Par2|source|string| }}&lt;br /&gt;
:::The path of the source file; path can be omitted if the source file is in the same directory as the AviSynth script (*.avs).&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
::{{Par2|stream_index|int|-1}}&lt;br /&gt;
:::The stream index to open in the source file. The value -1 means trying to get the video stream which has the largest resolution.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
::{{Par2|threads|int|0}}&lt;br /&gt;
:::The number of threads to decode a stream by libavcodec.&lt;br /&gt;
:::The value 0 means the number of threads is determined automatically and then the maximum value will be up to 16.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
::{{Par2|cache|bool|true}}&lt;br /&gt;
:::Create the index file (.lwi) to the same directory as the source file if set to true.&lt;br /&gt;
:::The index file avoids parsing all frames in the source file at the next or later access.&lt;br /&gt;
:::Parsing all frames is very important for frame accurate seek.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
::{{Par2|cachefile|string|source + &amp;quot;.lwi&amp;quot;}}&lt;br /&gt;
:::The filename of the index file (where the indexing data is saved).&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
::{{Par2|seek_mode|int|0}}&lt;br /&gt;
:::How to process when any error occurs during decoding a video frame.&lt;br /&gt;
::::*0 : Normal&lt;br /&gt;
:::::This mode retries sequential decoding from the next closest RAP up to 3 cycles when any decoding error occurs.&lt;br /&gt;
:::::If all 3 trial failed, retry sequential decoding from the last RAP by ignoring trivial errors.&lt;br /&gt;
:::::Still error occurs, then return the last returned frame.&lt;br /&gt;
::::*1 : Unsafe&lt;br /&gt;
:::::This mode retries sequential decoding from the next closest RAP up to 3 cycles when any fatal decoding error occurs.&lt;br /&gt;
:::::If all 3 trial failed, then return the last returned frame.&lt;br /&gt;
::::*2 : Aggressive&lt;br /&gt;
:::::This mode returns the last returned frame when any fatal decoding error occurs.&lt;br /&gt;
::: * RAP is an abbreviation of random accessible point.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
::{{Par2|seek_threshold|int|10}}&lt;br /&gt;
:::The threshold to decide whether a decoding starts from the closest RAP to get the requested video frame or doesn't.&lt;br /&gt;
::::Let's say&lt;br /&gt;
:::::the threshold is T,&lt;br /&gt;
::::and&lt;br /&gt;
:::::you request to seek the M-th frame called f(M) from the N-th frame called f(N).&lt;br /&gt;
::::If M &amp;gt; N and M - N &amp;lt;= T, then&lt;br /&gt;
:::::the decoder tries to get f(M) by decoding frames from f(N) sequentially.&lt;br /&gt;
::::If M &amp;lt; N or M - N &amp;gt; T, then&lt;br /&gt;
:::::check the closest RAP at the first.&lt;br /&gt;
:::::After the check, if the closest RAP is identical with the last RAP, do the same as the case M &amp;gt; N and M - N &amp;lt;= T.&lt;br /&gt;
:::::Otherwise, the decoder tries to get f(M) by decoding frames from the frame which is the closest RAP sequentially.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
::: * RAP is an abbreviation of random accessible point.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
::{{Par2|dr|bool|false}}&lt;br /&gt;
:::Try direct rendering from the video decoder if set to true.&lt;br /&gt;
:::The output resolution will be aligned to be mod16-width and mod32-height by assuming two vertical 16x16 macroblock.&lt;br /&gt;
:::For H.264 streams, in addition, 2 lines could be added because of the optimized chroma MC.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
::{{Par2|fpsnum|int|0}}&lt;br /&gt;
:::Forced frame rate numerator.&lt;br /&gt;
:::If frame rate is set to a positive value, output frame rate is forced to the specified value by padding and/or dropping frames.&lt;br /&gt;
:::Otherwise, output frame rate is set to a computed average frame rate and the output process is performed by actual frame-by-frame.&lt;br /&gt;
:::&amp;lt;br&amp;gt;&lt;br /&gt;
:::NOTE: You must explicitly set this if the source is an AVI file that contains null/drop frames that you would like to keep.  For example, AVI files captured using VirtualDub commonly contain null/drop frames that were inserted during the capture process.  Unless you provide this parameter, these null frames will be discarded, commonly resulting in loss of audio/video sync.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
::{{Par2|fpsden|int|1}}&lt;br /&gt;
:::Forced frame rate denominator.&lt;br /&gt;
:::See 'fpsnum' in details.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
::{{Par2|repeat|bool|false}}&lt;br /&gt;
:::Reconstruct frames by the flags specified in video stream and then treat all frames as interlaced if set to true and usable.&lt;br /&gt;
:::Note that this option is ignored when VFR-&amp;gt;CFR conversion is enabled.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
::{{Par2|dominance|int|0}}&lt;br /&gt;
:::Which field, top or bottom, is displayed first.&lt;br /&gt;
::::*0 : Obey source flags&lt;br /&gt;
::::*1 : TFF i.e. Top -&amp;gt; Bottom&lt;br /&gt;
::::*2 : BFF i.e. Bottom -&amp;gt; Top&lt;br /&gt;
:::This option is enabled only if one or more of the following conditions is true.&lt;br /&gt;
::::- 'repeat' is set to true.&lt;br /&gt;
::::- There is a video frame consisting of two separated field coded pictures&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
::{{Par2|format|string|&amp;quot;&amp;quot;}}&lt;br /&gt;
:::Force specified output pixel format if 'format' is specified.&lt;br /&gt;
:::The following formats are available currently.&lt;br /&gt;
::::{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;; width=&amp;quot;400px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!!width=&amp;quot;200px&amp;quot;| Format&lt;br /&gt;
!!width=&amp;quot;200px&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;YUV420P8&amp;quot;&lt;br /&gt;
|[[YV12]] / 4:2:0 planar&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;YUV422P8&amp;quot;&lt;br /&gt;
|[[YV16]] / 4:2:2 planar&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;YUV444P8&amp;quot;&lt;br /&gt;
|[[YV24]] / 4:4:4 planar&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;YUV410P8&amp;quot;&lt;br /&gt;
|4:1:0 planar&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;YUV411P8&amp;quot;&lt;br /&gt;
|[[YV411]] / 4:1:1 planar&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;YUV420P9&amp;quot;&lt;br /&gt;
|9-bit 4:2:0 planar&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;YUV422P9&amp;quot;&lt;br /&gt;
|9-bit 4:2:2 planar&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;YUV444P9&amp;quot;&lt;br /&gt;
|9-bit 4:4:4 planar&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;YUV420P10&amp;quot;&lt;br /&gt;
|10-bit 4:2:0 planar&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;YUV422P10&amp;quot;&lt;br /&gt;
|10-bit 4:2:2 planar&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;YUV444P10&amp;quot;&lt;br /&gt;
|10-bit 4:4:4 planar&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;YUV420P12&amp;quot;&lt;br /&gt;
|12-bit 4:2:0 planar&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;YUV422P12&amp;quot;&lt;br /&gt;
|12-bit 4:2:2 planar&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;YUV444P12&amp;quot;&lt;br /&gt;
|12-bit 4:4:4 planar&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;YUV420P14&amp;quot;&lt;br /&gt;
|14-bit 4:2:0 planar&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;YUV422P14&amp;quot;&lt;br /&gt;
|14-bit 4:2:2 planar&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;YUV444P14&amp;quot;&lt;br /&gt;
|14-bit 4:4:4 planar&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;YUV420P16&amp;quot;&lt;br /&gt;
|16-bit 4:2:0 planar&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;YUV422P16&amp;quot;&lt;br /&gt;
|16-bit 4:2:2 planar&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;YUV444P16&amp;quot;&lt;br /&gt;
|16-bit 4:4:4 planar&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;YUVA420P8&amp;quot;&lt;br /&gt;
|8-bit 4:2:0:4 planar with alpha channel&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;YUVA422P8&amp;quot;&lt;br /&gt;
|8-bit 4:2:2:4 planar with alpha channel&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;YUVA444P8&amp;quot;&lt;br /&gt;
|8-bit 4:4:4:4 planar with alpha channel&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;YUVA420P10&amp;quot;&lt;br /&gt;
|10-bit 4:2:0:4 planar with alpha channel&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;YUVA422P10&amp;quot;&lt;br /&gt;
|10-bit 4:2:2:4 planar with alpha channel&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;YUVA444P10&amp;quot;&lt;br /&gt;
|10-bit 4:4:4:4 planar with alpha channel&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;YUVA420P12&amp;quot;&lt;br /&gt;
|12-bit 4:2:0:4 planar with alpha channel&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;YUVA422P12&amp;quot;&lt;br /&gt;
|12-bit 4:2:0:4 planar with alpha channel&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;YUVA444P12&amp;quot;&lt;br /&gt;
|12-bit 4:4:4:4 planar with alpha channel&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;YUVA420P16&amp;quot;&lt;br /&gt;
|16-bit 4:2:0:4 planar with alpha channel&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;YUVA422P16&amp;quot;&lt;br /&gt;
|16-bit 4:2:2:4 planar with alpha channel&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;YUVA420P16&amp;quot;&lt;br /&gt;
|16-bit 4:4:4:4 planar with alpha channel&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;Y8&amp;quot;&lt;br /&gt;
|[[Y8]] / Grayscale&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;Y10&amp;quot;&lt;br /&gt;
|10-bit grayscale (ffmpeg only)&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;Y12&amp;quot;&lt;br /&gt;
|12-bit grayscale&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;Y16&amp;quot;&lt;br /&gt;
|16-bit grayscale&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;YUY2&amp;quot;&lt;br /&gt;
|[[YUY2]] / 4:2:2 interleaved &lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;RGB24&amp;quot;&lt;br /&gt;
|[[RGB24]] / 4:4:4 interleaved&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;RGB32&amp;quot;&lt;br /&gt;
|[[RGB32]] / 4:4:4:4 interleaved&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;RGB48&amp;quot;&lt;br /&gt;
|16-bit RGB / 4:4:4 interleaved&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;RGB64&amp;quot;&lt;br /&gt;
|16-bit RGBA / 4:4:4:4 interleaved&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;GBRP8&amp;quot;&lt;br /&gt;
|8-bit RGB / 4:4:4 planar&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;GBRP10&amp;quot;&lt;br /&gt;
|10-bit RGB / 4:4:4 planar&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;GBRP12&amp;quot;&lt;br /&gt;
|12-bit RGB / 4:4:4 planar&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;GBRP14&amp;quot;&lt;br /&gt;
|14-bit RGB / 4:4:4 planar&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;GBRP16&amp;quot;&lt;br /&gt;
|16-bit RGB / 4:4:4 planar&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;GBRAP8&amp;quot;&lt;br /&gt;
|8-bit RGBA / 4:4:4:4 planar&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;GBRAP10&amp;quot;&lt;br /&gt;
|10-bit RGBA / 4:4:4:4 planar&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;GBRAP12&amp;quot;&lt;br /&gt;
|12-bit RGBA / 4:4:4:4 planar&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;GBRAP14&amp;quot;&lt;br /&gt;
|14-bit RGBA / 4:4:4:4 planar&lt;br /&gt;
|-&lt;br /&gt;
|&amp;quot;GBRAP16&amp;quot;&lt;br /&gt;
|16-bit RGBA / 4:4:4:4 planar&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| High bit depth is only supported in AviSynth+ and VapourSynth&lt;br /&gt;
|}&lt;br /&gt;
:::Note: direct rendering is not available at all if pixel format is forced.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
::{{Par2|decoder|string|&amp;quot;&amp;quot;}}&lt;br /&gt;
:::Names of preferred decoder candidates, separated by comma. For instance, if you prefer to use the 'h264_qsv' and 'mpeg2_qsv' decoders instead of the generally used 'h264' and 'mpeg2video' decoder, then specify as &amp;quot;h264_qsv,mpeg2_qsv&amp;quot;. The evaluations are done in the written order and the first matched decoder, if any, is used.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
::{{Par2|ff_loglevel|int|0}}&lt;br /&gt;
:::Set the log level in FFmpeg.&lt;br /&gt;
:::* 0 : AV_LOG_QUIET - Print no output.&lt;br /&gt;
:::* 1 : AV_LOG_PANIC - Something went really wrong and we will crash now.&lt;br /&gt;
:::* 2 : AV_LOG_FATAL - Something went wrong and recovery is not possible.&lt;br /&gt;
:::* 3 : AV_LOG_ERROR - Something went wrong and cannot losslessly be recovered. However, not all future data is affected.&lt;br /&gt;
:::* 4 : AV_LOG_WARNING - Something somehow does not look correct. This may or may not lead to problems.&lt;br /&gt;
:::* 5 : AV_LOG_INFO - Standard information.&lt;br /&gt;
:::* 6 : AV_LOG_VERBOSE - Detailed information.&lt;br /&gt;
:::* 7 : AV_LOG_DEBUG - Stuff which is only useful for libav* developers.&lt;br /&gt;
:::* 8 : AV_LOG_TRACE - Extremely verbose debugging, useful for libav* development.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;max-width:62em&amp;quot; &amp;gt;&lt;br /&gt;
&amp;lt;div {{BoxWidthIndent|56|1}} &amp;gt;&lt;br /&gt;
 ## LWLibavVideoSource with default settings:&lt;br /&gt;
 '''LWLibavVideoSource'''(&amp;quot;source.m2ts&amp;quot;, stream_index=-1, threads=0, &lt;br /&gt;
 \                  cache=true, cachefile=&amp;quot;source.lwi&amp;quot; seek_mode=0, seek_threshold=10,&lt;br /&gt;
 \                   dr=false, fpsnum=0, fpsden=1, repeat=false, dominance=0, &lt;br /&gt;
 \                  format=&amp;quot;&amp;quot;, decoder=&amp;quot;&amp;quot;, prefer_hw=0, ff_loglevel=0)&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div {{BoxWidthIndent|56|1}} &amp;gt;&lt;br /&gt;
 ## Decoding 10bit, YUV 4:2:0 source and converting to 8-bit.&lt;br /&gt;
 '''LWLibavVideoSource'''(&amp;lt;''path''&amp;gt;, format=&amp;quot;YUV420P10&amp;quot;)&lt;br /&gt;
 [[ConvertBits]](8, dither=0) ## '0' means on, '-1' means off&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-----------------------------------------------&lt;br /&gt;
'''Back to [[LSMASHSource]] &amp;amp;larr;'''&lt;/div&gt;</summary>
		<author><name>JamesJohnston</name></author>	</entry>

	</feed>