Log in

View Full Version : how to get avisynth to read sony xdavc-L file?


zdoe
23rd March 2018, 07:50
how to get avisynth to read sony xdavc-L file?

currently i'm trying with:

FFMpegSource("H:\video\A011C026_180312ZU.MXF")

and get "video codec not found" error. i think the sony format is h264, though, that FFMpeg reads with no problems. and further, i CAN get FFmpeg to read/convert it.

and if/when i get it to read the file, how to apply a LUT to it. again - one can do this in FFmpeg...

Yanak
23rd March 2018, 10:46
Hello,

With a basic file using this profile in Vegas for rendering : Sony MXF HD EX 1280x720 60fps and avisynth+ x64 ( cannot guarantee for other versions )

FFVideoSource works for the video
LoadPlugin("H:\Plugins\ffms2.dll")
FFVideoSource("H:\test.mxf", colorspace = "YUV420P8")
or
LoadPlugin("H:\Plugins\ffms2.dll")
FFVideoSource("H:\test.mxf", colorspace = "YUV420P8", cachefile = "H:\TEMP\test.mxf.ffindex")

DDS2 works too :
LoadPlugin("H:\Plugins\DSS2.dll")
DSS2("H:\test.mxf")

And also LWLibavVideoSource :
LoadPlugin("H:\Plugins\LSMASHSource.dll")
LWLibavVideoSource("H:\test.mxf", format = "YUV420P8")

This said i have issues with XMF in 4:2:2 10 Bits and some others less common rendering profiles.

As for applying 3DLut's this isn't possible sadly with avisynth as far as i now, something i searched for long without success, would love to see avisytnh support either 3DLuts like .cube or simply be able to apply some haldclut's but i don't have much hope to see this possible one day sadly :/

Edit for video + audio :
LoadPlugin("H:\Plugins\ffms2.dll")
AudioDub( FFVideoSource("H:\test.mxf", colorspace = "YUV420P8"), FFAudioSource("H:\test.mxf") )

Or :
LoadPlugin("H:\Plugins\ffms2.dll")
video = FFVideoSource("H:\test.mxf", colorspace = "YUV420P8")
audio= FFAudioSource("H:\test.mxf")
return AudioDub(video, audio)

poisondeathray
23rd March 2018, 15:55
What version of ffms2 are you using ?

vapoursynth has a timecube filter that can apply cube LUTS , but it hasn't been ported to avisynth. You can make a request
https://github.com/sekrit-twc/timecube
https://forum.doom9.org/showthread.php?t=173361

Yanak
23rd March 2018, 16:10
Hi,

I use the one shipped with Staxrip, should be this one, 2.23.1 : https://github.com/FFMS/ffms2/releases

I saw in vapoursynth documentation that is supported some LUT's when i was searching for this long time ago but not using vapoursynth i did not pursue in this direction, thanks for the links, I'll try to do a request in the forum thread you linked and see how it goes , this will be really neat if possible with avisynth, have nothing to loose asking :p

Thank you

poisondeathray
23rd March 2018, 16:21
Hi,

I use the one shipped with Staxrip, should be this one, 2.23.1 : https://github.com/FFMS/ffms2/releases


:) I was asking the OP. He was getting "video codec not found" error

Usually MXF indicates the "prosumer" version, not the consumer variant. This means uncompressed audio and 10bit422 . I suspect the ffms2 he is using is older

Yanak
23rd March 2018, 16:43
I suspected it :p

with rendered 10 bits 422 i had issues, didn't went too far in testing so maybe something is possible or issue was on my end maybe.

Don't know for original files in this format, did not searched for samples.

qyot27
23rd March 2018, 17:10
Well, if 'FFmpegSource' as the function name is actually doing something and throwing error messages about video codecs (rather than AviSynth complaining that the function doesn't exist), that's a huge blinking red sign that the version is from the old 1.x series. Not even FFMS2.

zdoe
24th March 2018, 05:26
Well, if 'FFmpegSource' as the function name is actually doing something and throwing error messages about video codecs (rather than AviSynth complaining that the function doesn't exist), that's a huge blinking red sign that the version is from the old 1.x series. Not even FFMS2.

ffms2 - file date 12/29/2016. that's what i found by googling for it. though version number is not apparent, it likely is the same one as linked to on some answers above.

where to get the later version if there is one?

and yes, i have the
LoadPlugin("C:\Program Files (x86)\AviSynth\plugins\ffms2.dll")
line on the .AVS script.

the problem was that my command was FFMpegSource NOT FFvideoSource.

had gotten that somewhere when googled for it. now the clip loads.

but yes, i would really need LUT so that i don't have to do a 2nd pass with FFmpeg. i guess out of luck there...

poisondeathray
24th March 2018, 06:10
vapoursynth; yanak already requested the port . You can even load avs scripts in vapoursynth

what type of lut ? there is an old plugin ddcc by tritical for avisynth, but it uses a different type of 3DLUT, not the commonly used cube or 3dl . It might be possible to do some conversion



What is the background information ? What is the 2nd pass in ffmpeg (why can't 1pass be the final pass) ? What is the final format goal ? What are you doing in avisynth and after ?

zdoe
24th March 2018, 07:26
what type of lut ? there is an old plugin ddcc by tritical for avisynth, but it uses a different type of 3DLUT, not the commonly used cube or 3dl . It might be possible to do some conversion

What is the background information ? What is the 2nd pass in ffmpeg (why can't 1pass be the final pass) ? What is the final format goal ? What are you doing in avisynth and after ?

the LUT i need is SLog3SGamut3CineToLC-709.cube, provided by sony - in short, make low-con material have normal contrast.

but would like to resize, auto-Levels/Gain and stabilize in avisynth before.

i'm not the guy to do a port from some other LUT - i trust way too involved for me.

2nd pass would be to just to apply the LUT... but i guess i CAN feed FFMpeg with the .AVS if i figure out the right command line.

this is an ongoing/developing concern for such footage, but for now i just want to view dailies from manageable-size proxy files - h265 / 1080 instead of the 4k that the cam shoots.

Yanak
24th March 2018, 09:51
Hello,

You can feed FFMpeg with the avs script and apply the LUT, something like this:

The avs script (+ the filters you need/want):
LoadPlugin("H:\Plugins\ffms2.dll")
video = FFVideoSource("H:\test.mxf", colorspace = "YUV420P8")
audio= FFAudioSource("H:\test.mxf")
return AudioDub(video, audio)

FFMpeg windows cmd line will be something like this:
ffmpeg -hide_banner -i "H:\script.avs" -filter_complex lut3d="H\\:/LUTs/CineStyle\ S\ Curve.cube" -c:v libx264 -preset slow -crf 18 -c:a copy output.mkv
The encoding parameters and codec needs to be adjusted to your needs, here the audio is just copied and muxed for example.

You will notice the weird path name for the LUT location in the command above, my LUT applied to the script is located here on my machine:
"H:\LUTs\CineStyle S Curve.cube"

FFmpeg is a complete pain in the rear for paths having spaces or special characters in them that need to be escaped inside filters, in the end my path ends up like this in the windows command prompt :
"H\\:/LUTs/CineStyle\ S\ Curve.cube"

i strongly recommend having your files in folders that don't require spaces in paths to avoid long headaches trying to get FFmpeg reach them...

The FFmpeg encoding parameters and codec need to be adjusted to your needs ( and maybe refined for the colorspaces used ) but hopefully this helps a bit :)

poisondeathray
24th March 2018, 15:58
this is an ongoing/developing concern for such footage, but for now i just want to view dailies from manageable-size proxy files - h265 / 1080 instead of the 4k that the cam shoots.

but would like to resize, auto-Levels/Gain and stabilize in avisynth before.


might be ok for proxies... But when you get to the "ongoing/developing concern" part - be careful about the manipulations you do. Some of the filters might be 8bit, you didn't mention which ones specifically. You need at least 10bit or more to get the most out of slog3

Also, auto-levels/ gain before the LUT application might be problematic. slog is flat . If you "auto" contrast it before, that sort of messes everything up


i'm not the guy to do a port from some other LUT - i trust way too involved for me.


I wasn't asking you to do it :) I was suggesting you can use vapoursynth

zdoe
25th March 2018, 18:11
might be ok for proxies... But when you get to the "ongoing/developing concern" part - be careful about the manipulations you do. Some of the filters might be 8bit, you didn't mention which ones specifically. You need at least 10bit or more to get the most out of slog3

Also, auto-levels/ gain before the LUT application might be problematic. slog is flat . If you "auto" contrast it before, that sort of messes everything up

I wasn't asking you to do it :) I was suggesting you can use vapoursynth

yeah - i've yet to get into sophistication of color space accuracy. xdavc is 4:2:2 10 bit.

currently i have FFmpeg command line as:
"C:\Program Files (x86)\FFmpeg\ffmpeg.exe" -threads 1 -i "H:\03-12\MXFautoadjustDepan.AVS" -vf lut3d="SLog3SGamut3CineToLC-709.cube" -c:v libx265 -preset fast -b:v 1600k -c:a aac -b:a 128k -metadata:s:a:0 lang=en output265.mkv

and .AVS:
LoadPlugin("C:\Program Files (x86)\AviSynth\plugins\ffms2.dll")
LoadPlugin("C:\Program Files (x86)\AviSynth\plugins\AutoAdjust.dll")
LoadPlugin("C:\Program Files (x86)\AviSynth\plugins\depanestimate.dll")
LoadPlugin("C:\Program Files (x86)\AviSynth\plugins\depan.dll")

FFvideoSource("H:\03-12\video\A010C059_1803129F.MXF")
Lanczos4Resize(1920,1080)
i = ConvertToYV12(matrix="rec709")
mdata = DePanEstimate(i)
vectors=MSuper().MAnalyse(isb=false,blksize=8, overlap=0,search=5) globalmotion=MDepan(vectors,pixaspect=1,thSCD1=500)
DePanStabilize(i, data=mdata)
AutoAdjust(auto_gain=true, auto_balance=true)

this works for the video, but audio tracks are empty. how to have the audio carry over?

i tried:
video = FFVideoSource("H:\test.mxf", colorspace = "YUV420P8")
audio= FFAudioSource("H:\test.mxf")
return AudioDub(video, audio)

and get an error message from the resize filter.

and yes, i can see where auto-contrast would be problematic for slog footage. the output looks pretty good though.

once i figure out the audio part, what i need is a way to do this for all files in a directory recursively... probably doable, but variables in a batch file are kinda challenging.

poisondeathray
25th March 2018, 18:23
To load the audio, it depends on the audio configuration . You have to load each track with FFAudioSource, and specify the track number. You can use mergechannels() to send them or you might want to down mix them to stereo since it looks like you're using 2ch aac

For example 4channel mono

FFVideoSource("blah.mxf")
#whatever video filters here, depan etc...
vid=last

aud1=FFAudioSource("blah.mxf", track=1)
aud2=FFAudioSource("blah.mxf", track=2)
aud3=FFAudioSource("blah.mxf", track=3)
aud4=FFAudioSource("blah.mxf", track=4)

aud=mergechannels(aud1,aud2,aud3,aud4)
audiodub(vid,aud)


If you send 4ch in the avs script, you can also use -map in ffmepg to select specific channels

Yes, it's possible to do recursive subfolders with ffmpeg batch . There are some examples posted at videohelp.com and I think here too

qyot27
25th March 2018, 19:45
FFmpegSource2("title.mxf",atrack=-1)

You might want to use ffmsindex to do the indexing separately, if the file's too big to do quickly:
ffmsindex -t -1 title.mxf

zdoe
26th March 2018, 08:25
To load the audio, it depends on the audio configuration . You have to load each track with FFAudioSource, and specify the track number. You can use mergechannels() to send them or you might want to down mix them to stereo since it looks like you're using 2ch aac

For example 4channel mono

FFVideoSource("blah.mxf")
#whatever video filters here, depan etc...
vid=last

aud1=FFAudioSource("blah.mxf", track=1)
aud2=FFAudioSource("blah.mxf", track=2)
aud3=FFAudioSource("blah.mxf", track=3)
aud4=FFAudioSource("blah.mxf", track=4)

aud=mergechannels(aud1,aud2,aud3,aud4)
audiodub(vid,aud)


If you send 4ch in the avs script, you can also use -map in ffmepg to select specific channels

Yes, it's possible to do recursive subfolders with ffmpeg batch . There are some examples posted at videohelp.com and I think here too

great - it works! yes, i'd like only one stereo track on the result. e.g. channel 1 clean, channels 2,3 mixed together, drop channel 4.

the mergechannels above seems to NOT merge, but to somehow bundle the tracks together.

as for the recursive batch - does avisynth do variables?

zdoe
26th March 2018, 09:39
FFmpegSource2("title.mxf",atrack=-1)

You might want to use ffmsindex to do the indexing separately, if the file's too big to do quickly:
ffmsindex -t -1 title.mxf

is there a way to define multiple tracks in "atrack?" i got 4 in the source, and need at least 2 in the target?

otherwise i'll have to do FFvideo/FFaudio -Source, but that needs multiple references to the source file - which worries me because of the ultimate result - recursion.

indexing time doesn't worry me that much - the batch can run overnight if i get it to work.

qyot27
26th March 2018, 10:41
The atrack parameter is for discrete audio tracks. You have to use MixAudio (http://avisynth.nl/index.php/MixAudio) for downmixing.

zdoe
26th March 2018, 12:05
The atrack parameter is for discrete audio channels. You have to use MixAudio (http://avisynth.nl/index.php/MixAudio) for downmixing.

atrack - can pull only one audio channel, right?

anyway, now i have:

aud1=FFAudioSource("H:\03-12\video\A011C001_1803129K.MXF", track=1)
aud2=FFAudioSource("H:\03-12\video\A011C001_1803129K.MXF", track=2)
aud3=FFAudioSource("H:\03-12\video\A011C001_1803129K.MXF", track=3)

audR=MixAudio(aud2, aud3, 0.75, 0.075)

aud=mergechannels(aud1,audR)
audiodub(vid,aud)

and it works, though i'm not sure what i should do with the level-parameters.

zdoe
27th March 2018, 11:24
ok - i'm getting close, i think, but still errors

avs:
SetWorkingDir("C:\Program Files (x86)\AviSynth\plugins\")
LoadPlugin("ffms2.dll")
LoadPlugin("AutoAdjust.dll")
LoadPlugin("depanestimate.dll")
LoadPlugin("depan.dll")
LoadPlugin("GetSystemEnv.dll")

BlankClip()
zname=GetSystemEnv("zname")
subtitle(getsystemenv("zname"))
FFvideoSource(zname)

Lanczos4Resize(1920,1080)
i = ConvertToYV12(matrix="rec709")
mdata = DePanEstimate(i)
vectors=MSuper().MAnalyse(isb=false,blksize=8, overlap=0,search=5) globalmotion=MDepan(vectors,pixaspect=1,thSCD1=500)
DePanStabilize(i, data=mdata)
AutoAdjust(auto_gain=true, auto_balance=true)

vid=last

aud1=FFAudioSource("H:\economist-03-12\video\A011C001_1803129K.MXF", track=1)
aud2=FFAudioSource("H:\economist-03-12\video\A011C001_1803129K.MXF", track=2)
aud3=FFAudioSource("H:\economist-03-12\video\A011C001_1803129K.MXF", track=3)

audR=MixAudio(aud2, aud3, 0.75, 0.075)

aud=mergechannels(aud1,audR)
audiodub(vid,aud)

bat:
for /r %%f in (\video\*) do (
set zname=h:\video\%%~nxf
:: timeout 1
goto ffcommand
)

:ffcommand
"C:\Program Files (x86)\FFmpeg\ffmpeg.exe" -threads 1 -i "H:\03-12\callsavariable.AVS" -vf lut3d="SLog3SGamut3CineToLC-709.cube" -c:v libx265 -preset fast -b:v 1600k -c:a aac -b:a 128k -metadata:s:a:0 lang=en
pause
goto end

:end
set
pause

error message running the .bat:
Trailing options were found on the commandline.
[avisynth @ 00168460] FFVideoSource: Can't open 'h:\video\A011C001_1803129K.MXF'

(H:\03-12\callsavariable.AVS, line 11)
H:\03-12\callsavariable.AVS: Unknown error occurred

e.g. even though the .AVS can read the variable if run on its own, when used in a batch it doesn't.

"Trailing options were found on the commandline." i assume is caused by the fact that target file is not defined for ffmpeg.

all hail to GetSystemEnv author @stickboy, by the way.