Log in

View Full Version : Loading a 1080i source into avisynth


bruno321
11th May 2020, 10:17
First, sorry if this is a duplicate, but I didn't find anything which would quite help me. I'm using the latest avisynth+.

I've a 1080i TV capture. The mediainfo of the videostream is at the end of the post. I'm loading it with ffvideosource(). I use avspmod. I get a 50fps which behaves weirdly: sometimes I see two or more duplicate frames in a row, sometimes a corrupted image, sometimes blending, sometimes back-and-forth movement. What's also weird is that sometimes I move with the arrows in avspmod, then I click F5 (without having changed the script) and the preview changes... which I think doesn't make sense. Sometimes I watch frame by frame a sequence, it looks terrible, then I go back, F5, move around a bit, and it looks fine. This non-deterministic behavior of avspmod puzzles me :D

I've tried bobbing then TDecimating to 25fps, but it still behaves weirdly. I've also tried loading the source with fpsnum=25000, fpsden=1000, also seekmode=0, but I still get weird behavior in avspmod. I've also tried AssumeTFF(). Nothing really helps.

What else can I try? Note that when I play the file with mpv it plays just fine, no interlacing, no blended frames, no back-and-forth, no repeated frames.

Note I haven't yet had the opportunity to make some test encodes and see (am running another encode at the moment), but even if some of them do come out ok, it's weird behavior from the part of avspmod.

Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High@L4
Format settings : CABAC / 4 Ref Frames
Format settings, CABAC : Yes
Format settings, ReFrames : 4 frames
Format settings, GOP : M=4, N=24
Codec ID : V_MPEG4/ISO/AVC
Duration : 1 h 12 min
Bit rate : 9 188 kb/s
Width : 1 920 pixels
Height : 1 080 pixels
Display aspect ratio : 16:9
Frame rate mode : Variable
Frame rate : 50.000 FPS
Original frame rate : 25.000 FPS
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Interlaced
Scan type, store method : Separated fields
Scan order : Top Field First
Bits/(Pixel*Frame) : 0.089
Stream size : 4.64 GiB (97%)
Default : Yes
Forced : No
Color range : Limited
Color primaries : BT.709
Transfer characteristics : BT.709
Matrix coefficients : BT.709

kedautinh12
11th May 2020, 11:11
Can you upload your file?

kedautinh12
11th May 2020, 11:16
I think this post can help you
https://forum.doom9.org/showthread.php?t=170364

(Try code QTGMC_bob(0,0.5) from this post)

FranceBB
11th May 2020, 13:26
Frame rate : 50.000 FPS
Original frame rate : 25.000 FPS


Uhm... sometimes ffms2 loads this kind of source wrongly as 50fps displaying a mess with fields, while it should really index it and display it as 25i which is what MPV is doing before it bobs it to make it view it on your display.
In this case, I have more luck with LWLibavVideoSource which displays the real 25i with the correct fields.
It occurred several times with dodgy PAL sources when I used to receive any sort of file in my days at our News channel.
So my suggestion is: use LWLibavVideoSource and then bob-deinterlace it with QTGMC (as suggested by kedautinh12).
If that doesn't solve your issue, feel free to post a sample and we'll help you out.

bruno321
11th May 2020, 13:45
LWLibavVideoSource worked like a charm! It's now loaded as 25fps and I can't see any interlacing. Thanks a lot.

Funny that I was asking around not long ago https://forum.doom9.org/showthread.php?p=1908892#post1908892 about LSmashVideoSource which doesn't work for me. I didn't see this other alternative which does work fine here.

StainlessS
11th May 2020, 16:27
LSmashVideoSource which doesn't work for me.
I see no mention of the container type in previous posts. [ie it could be mkv or something else]
LSmashVideoSource is only for ISO container types eg MP4, MOV.

Function IsISOFileName(String s) {
s=RT_GetFileExtension(s) Return(s==".mov"||s==".mp4"||s==".m4v"||s==".3gp"||s==".3g2"||s==".mj2"||s==".dvb"||s==".dcf"||s==".m21")}

Might be a few more, where ISO container, LSmashVideoSource() usually works very well.

bruno321
11th May 2020, 16:58
Oh sorry, it was an mkv. Does that explain why LSmashVideoSource wasn't working for it? (when I tried it back then it was for an mkv as well)

StainlessS
11th May 2020, 17:21
LSmashVideoSource will not open MKV. [not an ISO container]

You could use below demo, to remux to MP4, and would usually open without problems.


REM https://forum.doom9.org/showthread.php?p=1908619#post1908619
REM We DO NOT LIKE SPACES IN FILE NAMES (REM == REMark ie comment)

setlocal

REM Where to Find ffmpeg
set FFMPEG="C:\BIN\ffmpeg.exe"

REM Where to get INPUT files, No terminating Backslash, "." = current directory (ie same as dir .bat file)
set INDIR="."

REM Where to place OUTPUT files, No terminating Backslash. "." would be same as .bat file, ".\OUT" = OUT folder in same directory as bat file.
set OUTDIR="D:"

REM Below, can add INPUT extensions as eg *.WEBM (SPACE separated, Batch Processes all INPUT type files in INDIR)
FOR %%A IN (*.AVI *.MKV *.MP4 *.MOV *.QT *.3GP *.DVB *.VOB *.MPG *.MPEG *M2P *.PS *.TS *.DIVX *.XVID *.FLV *.WMV *.ASF *.MXF) DO (

REM ****** Un-REM [ie SELECT] ONLY one of below lines, Comment out ie REM the remaining lines.
%FFMPEG% -i "%INDIR%\%%A" -vcodec utvideo -acodec pcm_s16le "%OUTDIR%\%%~nxA.AVI"
REM %FFMPEG% -i "%INDIR%\%%A" -vcodec huffyuv -acodec pcm_s16le "%OUTDIR%\%%~nxA.AVI"
REM %FFMPEG% -i "%INDIR%\%%A" -vcodec magicyuv -acodec pcm_s16le "%OUTDIR%\%%~nxA.AVI"
REM %FFMPEG% -i "%INDIR%\%%A" -vcodec v410 -acodec pcm_s16le "%OUTDIR%\%%~nxA.AVI"
REM %FFMPEG% -i "%INDIR%\%%A" -vcodec r210 -acodec pcm_s16le "%OUTDIR%\%%~nxA.AVI"
REM %FFMPEG% -i "%INDIR%\%%A" -vcodec copy -acodec copy "%OUTDIR%\%%~nxA.MKV"
REM %FFMPEG% -i "%INDIR%\%%A" -vcodec utvideo -acodec copy "%OUTDIR%\%%~nxA.MKV"
REM %FFMPEG% -i "%INDIR%\%%A" -vn -acodec pcm_s16le "%OUTDIR%\%%~nxA.WAV"
REM *****************************************************************************************.

)
Pause

REM ... Above Command lines, What they do if UnREM'ed (and all others REM'ed, UnREM=UnCOMMENT ) :
REM (1) Convert Video to UtVideo lossless, Convert Audio to 16 bit PCM audio (output AVI).
REM (2) Convert Video to HuffYUV lossless, Convert Audio to 16 bit PCM audio (output AVI).
REM (3) Convert Video to MagicYUV lossless, Convert Audio to 16 bit PCM audio (output AVI).
REM (4) Convert Video to v410 Uncompressed 4:4:4 10-bit lossless, Convert Audio to 16 bit PCM audio (output AVI).
REM (5) Convert Video to r210 Uncompressed RGB 10-bit lossless, Convert Audio to 16 bit PCM audio (output AVI).
REM (6) Remux, copy both video and audio (output MKV - see file extension at the end of the Remux line, ie MKV).
REM (7) Convert Video to UtVideo lossless, copy audio (output MKV).
REM (8) Skip any video, Convert Audio to 16 bit PCM (output WAV).
REM *****************************************************************************************.
REM In the UnREM'ed command Line [ie without a preceding REM]:-
REM '-vcodec utvideo' means convert video using utvideo codec.
REM '-vcodec copy' means copy video rather than convert.
REM '-vn' means no video output, use instead of eg '-vcodec utvideo'
REM '-acodec pcm_s16le' means convert audio using pcm_s16le codec.
REM '-acodec copy' means copy audio rather than convert.
REM '-an' means no audio output, use instead of eg '-acodec pcm_s16le'
REM The file extension at end of the line determines output container, eg '.AVI'
REM
REM From Command line with ffmpeg somewhere in your environment PATH:-
REM 'ffmpeg -codecs >D:\ffmpeg_codecs.txt'
REM Writes a txt file of ffmpeg available codecs to D:\
REM At start of txt file it shows a 'legend' or 'key' for codecs that can be used for video and audio,
REM use only ENCODING SUPPORTED codecs, prefereably LOSSLESS.
REM Supported codecs will vary with ffmpeg version.
REM *****************************************************************************************.


Comment out line in RED, [precede with 'REM']
UnComment line in BLUE[remove 'REM'] and change the filename extension to MP4 [at the end of line].

EDIT: Also use the partner audio source for iso container ie LSmashAudioSource.

EDIT: The alternative video source in LSMash ie LWLibavVideoSource() / LWLibavAudioSource() can open more types of files, and perhaps even ISO types, but
LSmashVideoSource() / LSmashAudioSource() are specifically for ISO only, and do not require indexing.

tormento
11th May 2020, 18:24
You could use below demo, to remux to MP4, and would usually open without problems.
Am I wrong or will it remux to MKV instead of MP4?

StainlessS
11th May 2020, 18:58
Am I wrong or will it remux to MKV instead of MP4?
I invite you to read below again.


Comment out line in RED, [precede with 'REM']
UnComment line in BLUE[remove 'REM'] and change the filename extension to MP4 [at the end of line].


EDIT: bat was a demo, it makes more sense to leave it as originally intended where default line is line 1, and
the remux line defaults to MKV output [can remux lots of formats to MKV, same not possible for MP4].
Also, the description at the end would make less sense if bat was supplied modified.