View Full Version : [solved] avs2yuv produces greenish bad video
Redsandro
17th November 2009, 19:56
-update- solved:
Source resolution and x264's specified resolution need to be the same OR avs2yuv needs to output y4m in stead of raw.
Original post follows:
_________________________________
What am I doing wrong when I get this kind of video? (Image Pending Approval)
http://forum.doom9.org/attachment.php?attachmentid=10497&stc=1&d=1258483951
pipebuf.exe avs2yuv.exe -raw something.avs -o - : x264x64.exe - 320x240 --profile baseline --level 2 --bitrate 512 --thread-input --output something.264 : 2
AVISource("something.avi", audio=false)
# ConvertToRGB24(matrix="Rec709")
I've tried converting to RGB or keeping it YUV but it's the same.
Inspector.Gadget
17th November 2009, 20:18
I assume your AVS script looks OK when played back?
Chikuzen
17th November 2009, 20:18
Do not you forget to specify --fps?
pipebuf.exe avs2yuv.exe -raw something.avs -o - : x264x64.exe - 320x240 --fps ***/*** --profile baseline --level 2 --bitrate 512 --thread-input --output something.264 : 2
Dark Shikari
17th November 2009, 21:09
Did you ConvertToYV12()? It doesn't look that way.
Redsandro
17th November 2009, 22:33
I assume your AVS script looks OK when played back?
Yep, perfectly fine
Do not you forget to specify --fps?
Why is that necessary? I don't do that for non-avs2yuv encodes either and they work fine. Either way, I still need to specify fps during muxing but since this is for a vb script that automates stuff, I was wondering if there's a way to detect fps so I don't have to change the script every time.
Did you ConvertToYV12()? It doesn't look that way.
I forgot to mention it but I assumed it was YUV already because the source avi's are always YUV in this case. Anyway in case I am missing something I will try it out right now and edit this post with the result.
-edit-
No change, same problem.
I also noticed that the source is 46 seconds, the resulting video is about 2:17 minutes, even if I set the proper framerate!
ajp_anton
17th November 2009, 22:56
What about inputing the avs directly to a 32-bit x264?
Redsandro
17th November 2009, 23:01
I tried your suggestion but same difference.
In case it helps, I use avs2yuv 0.24 and pipebuf 1.03.
kemuri-_9
18th November 2009, 00:45
Did you ConvertToYV12()? It doesn't look that way.
avs2yuv automatically converts to YV12 if the video is not so.
try
pipebuf.exe avs2yuv.exe something.avs -raw -o - : x264x64.exe - 320x240 --profile baseline --level 2 --bitrate 512 --thread-input --output something.264 : 2
or more simply
pipebuf.exe avs2yuv.exe something.avs -o - : x264x64.exe - --stdin y4m --profile baseline --level 2 --bitrate 512 --thread-input --output something.264 : 2
Redsandro
18th November 2009, 01:08
I just realized something stupid. Your first example works fine, just like my line in the first post. Your second line fails* because it has no resolution specified, and that got me thinking.
(* actually it doesn't but I typed it over wrong, anyway still good I got that message)
I wrongly *assumed* that the resolution specified to x264 was for resizing purposes, so I could conveniently scale the video to 320x240 for mobile devices for example. Apparently, it's not. It must be the exact resolution of the input file and then it works! :o
This raises one question for me: Why? I thought YUV was just another color model, but still in a digital resolution. But why does Rawyuv input require a resolution?
And second, is there some way I can detect the resolution and framerate from an avs file so I can automate those settings in my script?
Dark Shikari
18th November 2009, 01:10
I just realized something stupid. Your first example works fine, just like my line in the first post. Your second line fails because it has no resolution specified, and that got me thinking.
I wrongly *assumed* that the resolution specified to x264 was for resizing purposes, so I could conveniently scale the video to 320x240 for mobile devices for example. Apparently, it's not. It must be the exact resolution of the input file and then it works! :o
This raises one question for me: Why? I thought YUV was just another color model, but still in a digital resolution. But why does Rawyuv input require a resolution?Because raw YUV has no header, so x264 can't magically figure it out if you don't tell it. The solution is to use yuv4mpeg and --stdin y4m accordingly.
Redsandro
18th November 2009, 02:29
Ah it took me some time to get it right, being a fool with mixing raw and y4m and not really knowing what I am doing..
Now it finally works. Just two more problems for my script. I need to get that FPS value in order to pass it to the command line. At the moment I manually edit it in there, but it needs to be automated for different sources.
I got the 2997/125 fps for a value of 23.976 from avs2yuv because I couldn't find proper documentation to figure out how to do it myself. How does that value work? 23976/1000 would make more sense to me, if not just 23.976.
Mp4Box wants that value in normal dot notation. How do I get it?
Here's the script so far for people to use. It definitely requires you to manually personalize it. Esp. setting temp ( = output) dir and changing command paths.
My personal use is that I can right-click an .avi file and convert it to a movie I can play on my phone.
'' RED x264 for portable devices
'' Convert .AVI to .MP4 for mobile devices
''
'' By Sander S
'' 2009-11-17 - 2009-11-18
'' http://www.REDnet.nl/en/
' Usage:
'
' cscript.exe x264-n96.vbs "d:\source\myvid.avi"
' Installation for Windows 7: (earlier Windows versions require different HKCR path)
' HKEY_CLASSES_ROOT\SystemFileAssociations\.avi\Shell\Mpeg4Level2\Command
' @ = cscript.exe D:\Software\bin\x264-N96.vbs "%1"
'
' Notes:
'
' Command line parameter should be path+filename.avi.
' This will create avs, m4a, mux and clean.
Option Explicit
' Options - SELFNOTE: not implemented yet
Dim myRes: myRes = "320x240"
Dim myBuf: myBuf = "2"
' Command paths
Dim encAac: encAac = "D:\Software\Video\Tools\MeGUI\neroAacEnc.exe"
Dim enFaac: enFaac = "D:\Software\Video\Tools\MeGUI\tools\faac\faac.exe"
Dim enc264: enc264 = "D:\Software\bin\x264x64.exe"
Dim muxMp4: muxMp4 = "D:\Software\Video\Tools\MeGUI\tools\mp4box\mp4box.exe"
Dim bePipe: bePipe = "D:\Software\Video\Tools\bepipe\bepipe.exe"
Dim doPipe: doPipe = "D:\Software\bin\pipebuf.exe"
Dim avsYuv: avsYuv = "D:\Software\bin\avs2yuv.exe"
'Dim bePipe: bePipe = "D:\Software\Video\Tools\Bin\avs2wav.exe"
Dim tmpPath: tmpPath = "P:\temp\"
' Commands
encAac = encAac & " -ignorelength -lc -cbr 80000 -if - -of ""%M4A%"""
enFaac = enFaac & " -P --tns -b 80 - -o ""%M4A%"""
enc264 = enc264 & " - --stdin y4m --profile baseline --level 2 --bitrate 512 --fps 2997/125 --thread-input --output ""%264%"""
muxMp4 = muxMp4 & " -add ""%264%"":fps=23.976 -add ""%M4A%#trackID=1"" -tmp ""%PATH%"" -new ""%MP4%"""
bePipe = bePipe & " --script ""Import(^%AVS%^)"""
doPipe = doPipe & " %OUT% : %IN% : 2"
avsYuv = avsYuv & " ""%AVS%"" -o -"
' Globals
Dim fso: Set fso = CreateObject("Scripting.FileSystemObject")
Dim src: src = WScript.Arguments.Item(0) ' command line argument
Dim idx: idx = LastIndexOf(src)
Dim srcPath: srcPath = Left(src, idx)
Dim srcFile: srcFile = Right(src, Len(src) - idx)
Dim srcFileBase: srcFileBase = fso.getBaseName(srcFile)
Dim srcFileExt: srcFileExt = fso.getExtensionName(srcFile)
Dim tmpFile
Dim tmp
' Begin
'
Main
Sub Main
' Begin output
WScript.Echo "*************************"
WScript.Echo "* RED Mpeg4 L2@B script *"
WScript.Echo "*************************"
WScript.Echo ""
WScript.Echo "Path: " & srcPath
WScript.Echo "File: " & srcFile
WScript.Echo "Temp: " & tmpPath
WScript.Echo "Out : " & tmpPath
WScript.Echo ""
WScript.Echo ""
WScript.Echo ""
' Create AVS file - audio only
WScript.Echo "Creating AVS for audio..."
WScript.Echo ""
Set tmpFile = fso.OpenTextFile(tmpPath & srcFileBase & ".avs", 2, True)
tmpFile.WriteLine("AVISource(""" & srcPath & srcFile & """, audio=true)")
tmpFile.WriteLine("EnsureVBRMP3Sync()")
tmpFile.Close
' Prepare commands
bePipe = strReplace("%AVS%", tmpPath & srcFileBase & ".avs", bePipe)
encAac = strReplace("%M4A%", tmpPath & srcFileBase & ".m4a", encAac)
tmp = doPipe
tmp = strReplace("%OUT%", bePipe, tmp)
tmp = strReplace("%IN%", EncAac, tmp)
' Encode through pipe
WScript.Echo "Encoding audio..."
WScript.Echo ""
run tmp
' Remove AVS file
WScript.Echo "Removing AVS..."
WScript.Echo ""
fso.DeleteFile(tmpPath & srcFileBase & ".avs")
' Create AVS file - Video
WScript.Echo "Creating AVS for video..."
WScript.Echo ""
Set tmpFile = fso.OpenTextFile (tmpPath & srcFileBase & ".avs", 2, True)
tmpFile.WriteLine("AVISource(""" & srcPath & srcFile & """, audio=false)")
tmpFile.WriteLine("Lanczos4Resize(320, 240)")
tmpFile.Close
' Prepare commands
avsYuv = strReplace("%AVS%", tmpPath & srcFileBase & ".avs", avsYuv)
enc264 = strReplace("%264%", tmpPath & srcFileBase & ".264", enc264)
tmp = doPipe
tmp = strReplace("%OUT%", avsYuv, tmp)
tmp = strReplace("%IN%", enc264, tmp)
' Encode video
WScript.Echo "Video encoding..."
WScript.Echo ""
run tmp
' Remove AVS file
WScript.Echo "Removing AVS..."
WScript.Echo ""
fso.DeleteFile(tmpPath & srcFileBase & ".avs")
' Mux AV
WScript.Echo "Muxing AAC and AVC to MP4..."
WScript.Echo ""
tmp = muxMp4
tmp = strReplace("%264%", tmpPath & srcFileBase & ".264", tmp)
tmp = strReplace("%M4A%", tmpPath & srcFileBase & ".m4a", tmp)
tmp = strReplace("%PATH%", Left(tmpPath, Len(tmpPath)-1), tmp)
tmp = strReplace("%MP4%", tmpPath & srcFileBase & ".mp4", tmp)
run tmp
' Remove intermediate files
' NOTE!! You may want to comment this out. On encodes that take forever, if something goes wrong with the mux, you're gonna be glad if you still got those files for manual muxing.
WScript.Echo ""
WScript.Echo "Removing 264..."
WScript.Echo ""
fso.DeleteFile(tmpPath & srcFileBase & ".264")
WScript.Echo "Removing M4A..."
WScript.Echo ""
fso.DeleteFile(tmpPath & srcFileBase & ".m4a")
' Pause (Keep command window open)
WScript.Echo "Done. Press ENTER to exit."
Do While Not WScript.StdIn.AtEndOfLine
Dim Input: Input = WScript.StdIn.Read(1)
Loop
WScript.Echo "Bye."
End Sub
' Private functions
'
Function promptYesNo(ByVal strMsg)
Do
WScript.Echo strMsg
Dim key: key = WScript.StdIn.ReadLine()
Select Case LCase(Trim(key))
Case "n","no" promptYesNo = False: Exit Function
Case "y","yes" promptYesNo = True: Exit Function
End Select
WScript.StdOut.WriteLine "Just enter 'y' or 'n'..."
Loop
End Function
Function lastIndexOf(ByVal str)
' Because src.LastIndexOf("\") doesn't work and the FUCKING vague lame ass crappy internet documentation isn't any help at all and even though I am not too stupid I wasted an unreasonable amount of my life trying to google (read: figure ) why everyone else seems to get away with it
Dim oRE, oMatches, oMatch
Set oRE = New RegExp
oRE.Pattern = "\\"
oRE.Global = True
Set oMatches = oRE.Execute(src)
For Each oMatch In oMatches
lastIndexOf = oMatch.FirstIndex + 1
Next
End Function
Sub run(ByVal executable)
WScript.Echo executable
WScript.Echo ""
Dim shell: Set shell = CreateObject("WScript.Shell")
shell.Run executable, 1, true
Set shell = Nothing
End Sub
Function strReplace(ByVal strOld, strNew, strSource)
strSource = Replace(strSource, strOld, strNew, 1, -1, 1)
strReplace = strSource
End Function
-edit-
Oh yeah the second problem would be that avs2yuv crashes after it has done it's job, requiring me to click 'close' before the script continues.
I didn't have this when I got the green video, which makes me think it's my fault somehow.
avs2yuv.exe has stopped working
Problem signature:
Problem Event Name: APPCRASH
Application Name: avs2yuv.exe
Application Version: 0.0.0.0
Application Timestamp: 4228f465
Fault Module Name: xvidvfw.dll
Fault Module Version: 0.0.0.0
Fault Module Timestamp: 4a2bcd84
Exception Code: c0000005
Exception Offset: 000098f4
OS Version: 6.1.7600.2.0.0.256.48
Locale ID: 1043
There's not really a problem with my xvid codec in anything else I do. The .avs plays back fine.
kemuri-_9
18th November 2009, 02:44
Now it finally works. Just two more problems for my script. I need to get that FPS value in order to pass it to the command line. At the moment I manually edit it in there, but it needs to be automated for different sources.
having avs2yuv output the y4m format (without the -raw) instead of yuv will have it write the y4m header (which contains the resolution and framerate) to the output stream that x264 can read and parse from, so you won't have to manually set the fps or resolution in this case.
as for the crashes, i've gotten them before but not lately...
I've usually found them to be caused by avisynth itself doing some odd things that avs2yuv can have issues with.
Redsandro
18th November 2009, 02:47
Thanks. Yes the crashes occured more regularly since I've put that Lancsoz4Resize() in. Maybe I need to try bicubic or another one. I'm not really doing other crazy stuff except opening a video..
Anyway, I still need that fps in a variable, because I still need to tell Mp4Box what FPS to mux in, because if I don't it will always default to 25 fps which is often wrong.
kemuri-_9
18th November 2009, 02:54
Anyway, I still need that fps in a variable, because I still need to tell Mp4Box what FPS to mux in, because if I don't it will always default to 25 fps which is often wrong.
the obvious solution would to have x264 write to a .mp4 file rather than a .h264 as the mp4 header will contain the framerate.
another easy way is to take the stderr output from avs2yuv, i.e.
some.avs: 848x480, 5000000/166833 fps, 42616 frames
and parse this.
Redsandro
18th November 2009, 03:15
Thanks that's very helpful!
I am glad it's as easy as just entering an .mp4 filename as x264's output. Mp4box automatically picks it up.
New problem though, I just noticed that the last bunch of seconds is cut off from the sound. It's also cut off in the intermediate sound file.
Is it my fault, Nero's fault or bePipe, pipeBuf or Avisynth's?
Adding EnsureVBRMP3Sync() doesn't make a difference.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.