LSMASHSource/LSMASHVideoSource

From Avisynth wiki
(Difference between revisions)
Jump to: navigation, search
m (heading)
m (v901 changes)
Line 4: Line 4:
 
<br>
 
<br>
 
== [[Script variables|Syntax and Parameters]] ==
 
== [[Script variables|Syntax and Parameters]] ==
:{{Template:FuncDef|LSMASHVideoSource (string source, int "track", int "threads", int "seek_mode", int "seek_threshold", bool "dr", int "fpsnum", int "fpsden", bool "stacked", string "format")}}
+
:{{Template:FuncDef|LSMASHVideoSource (string source, int "track", int "threads", int "seek_mode", int "seek_threshold", bool "dr", int "fpsnum", int "fpsden", bool "stacked", string "format", string "decoder")}}
 
<br>
 
<br>
 
::{{Par2|source|string| }}
 
::{{Par2|source|string| }}
Line 14: Line 14:
 
<br>
 
<br>
 
::{{Par2|threads|int|0}}
 
::{{Par2|threads|int|0}}
:::The number of threads to decode a stream by libavcodec.
+
:::The number of threads to decode a stream by [[wikipedia:Libavcodec|libavcodec]].
 
:::The value 0 means the number of threads is determined automatically and then the maximum value will be up to 16.
 
:::The value 0 means the number of threads is determined automatically and then the maximum value will be up to 16.
 
<br>
 
<br>
Line 20: Line 20:
 
:::How to process when any error occurs during decoding a video frame.
 
:::How to process when any error occurs during decoding a video frame.
 
::::*0 : Normal
 
::::*0 : Normal
:::::This mode retries sequential decoding from the next closest RAP up to 3 cycles when any decoding error occurs.
+
:::::This mode retries sequential decoding from the next closest RAP* up to 3 cycles when any decoding error occurs.
 
:::::If all 3 trial failed, retry sequential decoding from the last RAP by ignoring trivial errors.
 
:::::If all 3 trial failed, retry sequential decoding from the last RAP by ignoring trivial errors.
 
:::::Still error occurs, then return the last returned frame.
 
:::::Still error occurs, then return the last returned frame.
Line 28: Line 28:
 
::::*2 : Aggressive
 
::::*2 : Aggressive
 
:::::This mode returns the last returned frame when any fatal decoding error occurs.
 
:::::This mode returns the last returned frame when any fatal decoding error occurs.
<br>
 
 
::: * RAP is an abbreviation of random accessible point.
 
::: * RAP is an abbreviation of random accessible point.
 
<br>
 
<br>
 
::{{Par2|seek_threshold|int|10}}
 
::{{Par2|seek_threshold|int|10}}
:::The threshold to decide whether a decoding starts from the closest RAP to get the requested video frame or doesn't.
+
:::The threshold to decide whether a decoding starts from the closest RAP* to get the requested video frame or doesn't.
 
::::Let's say
 
::::Let's say
 
:::::the threshold is T,
 
:::::the threshold is T,
Line 43: Line 42:
 
:::::After the check, if the closest RAP is identical with the last RAP, do the same as the case M > N and M - N <= T.
 
:::::After the check, if the closest RAP is identical with the last RAP, do the same as the case M > N and M - N <= T.
 
:::::Otherwise, the decoder tries to get f(M) by decoding frames from the frame which is the closest RAP sequentially.
 
:::::Otherwise, the decoder tries to get f(M) by decoding frames from the frame which is the closest RAP sequentially.
<br>
 
 
::: * RAP is an abbreviation of random accessible point.
 
::: * RAP is an abbreviation of random accessible point.
 
<br>
 
<br>
Line 58: Line 56:
 
::{{Par2|fpsden|int|1}}
 
::{{Par2|fpsden|int|1}}
 
:::Forced frame rate denominator.
 
:::Forced frame rate denominator.
:::See 'fpsnum' in details.
+
:::See 'fpsnum' above.
 
<br>
 
<br>
 
::{{Par2|stacked|bool|false}}
 
::{{Par2|stacked|bool|false}}
Line 145: Line 143:
 
|[[RGB32]] / 4:4:4:4 interleaved
 
|[[RGB32]] / 4:4:4:4 interleaved
 
|-
 
|-
! colspan="2"| *YV12, YV16 and YV24 allow bit depths greater than 8.
+
! colspan="2"| * YV12, YV16 and YV24 allow bit depths greater than 8.
 
|}
 
|}
 
:::Note: direct rendering is not available at all if pixel format is forced.
 
:::Note: direct rendering is not available at all if pixel format is forced.
 +
<br>
 +
::{{Par2|decoder|string|""}}
 +
:::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 "h264_qsv,mpeg2_qsv". The evaluations are done in the written order and the first matched decoder, if any, is used.
 
<br>
 
<br>
  
Line 153: Line 154:
 
LSMASHVideoSource with default settings:
 
LSMASHVideoSource with default settings:
 
  LSMASHVideoSource(source="source.mp4", track=0, threads=0, seek_mode=0,  
 
  LSMASHVideoSource(source="source.mp4", track=0, threads=0, seek_mode=0,  
  \                seek_threshold=10, dr=false, fpsnum=0, fpsden=1, stacked=false, format="")
+
  \                seek_threshold=10, dr=false, fpsnum=0, fpsden=1, stacked=false,  
 +
\                format="", decoder="")
 
<br>
 
<br>
 
<br>
 
<br>
 
-----------------------------------------------
 
-----------------------------------------------
 
'''Back to [[LSMASHSource]] &larr;'''
 
'''Back to [[LSMASHSource]] &larr;'''

Revision as of 02:56, 15 August 2016

LSMASHVideoSource uses libavcodec as a video decoder and L-SMASH as a demuxer. Recommended for MP4, MOV, ISO Base Media and its derived file formats. One advantage of LSMASHVideoSource is that it doesn't need to create an index file for its supported formats.

Syntax and Parameters

LSMASHVideoSource (string source, int "track", int "threads", int "seek_mode", int "seek_threshold", bool "dr", int "fpsnum", int "fpsden", bool "stacked", string "format", string "decoder")


string  source =
The path of the source file; path can be omitted if the source file is in the same directory as the AviSynth script (*.avs).


int  track = 0
The track number to open in the source file.
The value 0 means trying to get the first detected video stream.


int  threads = 0
The number of threads to decode a stream by libavcodec.
The value 0 means the number of threads is determined automatically and then the maximum value will be up to 16.


int  seek_mode = 0
How to process when any error occurs during decoding a video frame.
  • 0 : Normal
This mode retries sequential decoding from the next closest RAP* up to 3 cycles when any decoding error occurs.
If all 3 trial failed, retry sequential decoding from the last RAP by ignoring trivial errors.
Still error occurs, then return the last returned frame.
  • 1 : Unsafe
This mode retries sequential decoding from the next closest RAP up to 3 cycles when any fatal decoding error occurs.
If all 3 trial failed, then return the last returned frame.
  • 2 : Aggressive
This mode returns the last returned frame when any fatal decoding error occurs.
* RAP is an abbreviation of random accessible point.


int  seek_threshold = 10
The threshold to decide whether a decoding starts from the closest RAP* to get the requested video frame or doesn't.
Let's say
the threshold is T,
and
you request to seek the M-th frame called f(M) from the N-th frame called f(N).
If M > N and M - N <= T, then
the decoder tries to get f(M) by decoding frames from f(N) sequentially.
If M < N or M - N > T, then
check the closest RAP at the first.
After the check, if the closest RAP is identical with the last RAP, do the same as the case M > N and M - N <= T.
Otherwise, the decoder tries to get f(M) by decoding frames from the frame which is the closest RAP sequentially.
* RAP is an abbreviation of random accessible point.


bool  dr = false
Try direct rendering from the video decoder if set to true.
The output resolution will be aligned to be mod16-width and mod32-height by assuming two vertical 16x16 macroblock.
For H.264 streams, in addition, 2 lines could be added because of the optimized chroma MC.


int  fpsnum = 0
Forced frame rate numerator.
If frame rate is set to a positive value, output frame rate is forced to the specified value by padding and/or dropping frames.
Otherwise, output frame rate is set to a computed average frame rate and the output process is performed by actual frame-by-frame.


int  fpsden = 1
Forced frame rate denominator.
See 'fpsnum' above.


bool  stacked = false
Use the stacked format for a hack of AviSynth high bit-depth support if set to true.
The stacked format splits MSB and LSB into vertically, and MSB comes on top of output image.
Note: direct rendering is not available at all if stacked format is used.


string  format = ""
Force specified output pixel format if 'format' is specified.
The following formats are available currently.
Format Comments
"YUV420P8" YV12 / 4:2:0 planar
"YUV422P8" YV16 / 4:2:2 planar
"YUV444P8" YV24 / 4:4:4 planar
"YUV410P8" 4:1:0 planar
"YUV411P8" YV411 / 4:1:1 planar
"YUV420P9" 9-bit 4:2:0 planar
"YUV422P9" 9-bit 4:2:2 planar
"YUV444P9" 9-bit 4:4:4 planar
"YUV420P10" 10-bit 4:2:0 planar
"YUV422P10" 10-bit 4:2:2 planar
"YUV444P10" 10-bit 4:4:4 planar
"YUV420P12" 12-bit 4:2:0 planar - (ffmpeg only)
"YUV422P12" 12-bit 4:2:2 planar - (ffmpeg only)
"YUV444P12" 12-bit 4:4:4 planar - (ffmpeg only)
"YUV420P14" 14-bit 4:2:0 planar - (ffmpeg only)
"YUV422P14" 14-bit 4:2:2 planar - (ffmpeg only)
"YUV444P14" 14-bit 4:4:4 planar - (ffmpeg only)
"YUV420P16" 16-bit 4:2:0 planar
"YUV422P16" 16-bit 4:2:2 planar
"YUV444P16" 16-bit 4:4:4 planar
"Y8" Y8 / Grayscale
"YUY2" YUY2 / 4:2:2 interleaved
"RGB24" RGB24 / 4:4:4 interleaved
"RGB32" RGB32 / 4:4:4:4 interleaved
* YV12, YV16 and YV24 allow bit depths greater than 8.
Note: direct rendering is not available at all if pixel format is forced.


string  decoder = ""
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 "h264_qsv,mpeg2_qsv". The evaluations are done in the written order and the first matched decoder, if any, is used.


Examples

LSMASHVideoSource with default settings:

LSMASHVideoSource(source="source.mp4", track=0, threads=0, seek_mode=0, 
\                 seek_threshold=10, dr=false, fpsnum=0, fpsden=1, stacked=false, 
\                 format="", decoder="")




Back to LSMASHSource

Personal tools