Log in

View Full Version : HCEnc and Crop problem?


DrPhill
4th May 2012, 10:20
I am using HCEnc to covert my avs script to mv2 files.

I have come across an oddity. Here is a reduced test script:

imageWidth = 1280
imageHeight = 960
reference = DirectShowSource("2012-01-04\output.m2v")
video = Trim(reference, 50, 200)


append = DirectShowSource("2012-02-09\output.m2v")
append = AddBorders(append, 10, 4, 0, 0)
#append = Crop(append, 0, 0, -10, -4)
append = BilinearResize(append, imageWidth, imageHeight)
append = Trim (append, 50, 200)
video = Dissolve(video, append, 50)
return video


This works fine (except the images are not aligned properly). If I uncomment the crop command, then the output GTU when the fade completes. By GTU I mean the image is replaced by horizontal coloured banding (corrupt image I guess).

The same script works perfectly well in windows media player.

If I replace either negative parameter to Crop with zero, then the problem goes away.
Two successive calls to Crop, (each with one negative parameter) fails, but if I move one of these calls to before AddBorders everything works fine.

Anybody stumbled across similar?

Groucho2004
4th May 2012, 10:25
For MPEG-2 you should use DGIndex/DGDecode (http://neuron2.net/dgmpgdec/dgmpgdec.html).

DrPhill
4th May 2012, 10:47
Even splitting the crop into two commands I get problems with HCEnc.

For MPEG-2 you should use DGIndex/DGDecode (http://neuron2.net/dgmpgdec/dgmpgdec.html).

Nope, still problems running the script in: dgmpgdec148_20060720

No problems in AVSPMod or Windoze Media player.

MY Script:

imageWidth = 1280
imageHeight = 960
reference = DirectShowSource("2012-01-04\output.m2v")
reference = BilinearResize(reference, imageWidth, imageHeight)
video = Trim(reference, 50, 350)
reference = Subtitle(reference, "reference", y=40)
video = Subtitle(video, "2012-01-04", y = 40)


append = DirectShowSource("2012-02-09\output.m2v")
append = Crop(append, 0, 0, -10, 0) # negative
append = AddBorders(append, 10, 4, 0, 0)
append = Crop(append, 0, 0, 0, -4) # negative
append = BilinearResize(append, imageWidth, imageHeight)
append = Subtitle(append, "2012-02-09", y=40)
# merge single frame to check alignment
#return Dissolve(Trim(reference, 1,1), Trim(append, 1,1), 0)
append = Trim (append, 50, 350)
video = Dissolve(video, append, 50)


append = DirectShowSource("2012-02-14\output.m2v")
append = Crop(append, 0, 0, -12, 0) # negative
append = AddBorders(append, 12, 6, 0, 0)
append = Crop(append, 0, 0, 0, -6) # negative
append = BilinearResize(append, imageWidth, imageHeight)
append = Subtitle(append, "2012-02-14", y=40)
# merge single frame to check alignment
#return Dissolve(Trim(reference, 1,1), Trim(append, 1,1), 0)
append = Trim (append, 50, 350)
video = Dissolve(video, append, 100)


append = DirectShowSource("2012-02-19\output.m2v")
append = Crop(append, 0, 0, -8, 0) # negative
append = AddBorders(append, 8, 1, 0, 0)
append = Crop(append, 0, 0, 0, -2) # negative
append = BilinearResize(append, imageWidth, imageHeight)
append = Subtitle(append, "2012-02-19", y=40)
# merge single frame to check alignment
#return Dissolve(Trim(reference, 1,1), Trim(append, 1,1), 0)
append = Trim (append, 50, 350)
video = Dissolve(video, append, 50)


append = DirectShowSource("2012-03-22\output.m2v")
append = AddBorders(append, 0, 2, 2, 0)
append = Crop(append, 2, 0, 0, -2) # negative
append = BilinearResize(append, imageWidth, imageHeight)
append = Subtitle(append, "2012-03-22", y=40)
# merge single frame to check alignment
#return Dissolve(Trim(reference, 1,1), Trim(append, 1,1), 0)
append = Trim (append, 50, 350)
video = Dissolve(video, append, 50)


# This is slightly rotated - may need to discard
append = DirectShowSource("2012-03-28\output.m2v")
append = AddBorders(append, 0, 10, 18, 0)
append = Crop(append, 12, 0, 0, -10) # negative
append = BilinearResize(append, imageWidth, imageHeight)
append = Subtitle(append, "2012-03-28", y=40)
# merge single frame to check alignment
#return Dissolve(Trim(reference, 1,1), Trim(append, 1,1), 0)
append = Trim (append, 50, 350)
video = Dissolve(video, append, 50)


append = DirectShowSource("2012-04-24\output.m2v")
append = AddBorders(append, 0, 0, 10, 0)
append = Crop(append, 10, 0, 0, 0) # negative
append = BilinearResize(append, imageWidth, imageHeight)
append = Subtitle(append, "2012-04-24", y=40)
# merge single frame to check alignment
#return Dissolve(Trim(reference, 1,1), Trim(append, 1,1), 0)
append = Trim (append, 50, 350)
video = Dissolve(video, append, 100)


#append = DirectShowSource("2012-04-24\output.m2v")
#append = AddBorders(append, 0, 0, 10, 18)
#append = Crop(append, 14, 14, 0, 0) # negative
#append = BilinearResize(append, imageWidth, imageHeight)
#append = Subtitle(append, "2012-04-24")
# merge single frame to check alignment
#return Dissolve(Trim(reference, 1,1), Trim(append, 1,1), 0)
#append = Trim (append, 50, 350)
#video = Dissolve(video, append, 100)

return video

Groucho2004
4th May 2012, 11:04
Nope, still problems running the script in: dgmpgdec148_20060720
Where did that come from? This appears to be an ancient version. Current is 1.58 from here (http://hank315.nl/).

Don't use DSS for a MPEG-2 stream!

Also, are your streams progressive or interlaced?

DrPhill
4th May 2012, 11:05
I guess that the programs which are failing (HCEnc, DGIndex) are trying to encode the video stream to file, whereas the ones that work (AVSPMod, WMP) are just displaying the video. I wonder if the encoding uses a common module, and I have stumbled upon a weakness in it?

I have successfully encoded another time sequence with no glitches, using a very similar script.

DrPhill
4th May 2012, 11:09
Where did that come from? This appears to be an ancient version. Current is 1.58 from here (http://hank315.nl/).

Don't use DSS for a MPEG-2 stream!

Also, are your streams progressive or interlaced?
Still GTU with dgmpgdec158......

sneaker_ger
4th May 2012, 11:23
Groucho2004 already hinted at it: make sure to work with mod4 resolutions when dealing with interlaced stuff.

DrPhill
4th May 2012, 11:30
Hmmmm, DGIndex is not what I thought it was - so I am probably using it wrongly.

I would like to read in an AVI script and render it to a video file format (dont care which, as long as others can easily read it).

Ultimately I want to join video fragments into a complete video, but I will need to adjust the size/offset of successive clips to match, and then do a fade from each to next......

DrPhill
4th May 2012, 11:51
Groucho2004 already hinted at it: make sure to work with mod4 resolutions when dealing with interlaced stuff.

????

All the video fragments being joined are in YuY2 (return myVideo.convertToYuY2() at the end of each script), and all are 1280 x 960 pixels. These fragments have all been converted with from AviSynth scripts to m2v using HCEnc.

I only do the BilinearResize in case I mess up the Crop/AddBorder commands, or need some finer control of scaling.

So what am I doing wrong?

Guest
4th May 2012, 14:07
Nope, still problems running the script in: dgmpgdec148_20060720

No problems in AVSPMod or Windoze Media player.

MY Script:
The script you gave still uses DirectShowSource()! If you are confused about how to use DGMPGDec, you can read the Quick Start guide that comes with it.

DrPhill
4th May 2012, 14:12
The script you gave still uses DirectShowSource()! If you are confused about how to use DGMPGDec, you can read the Quick Start guide that comes with it.

Aaaaa - that is DSS. (Thunk!)

I will try that.

Thanks

Groucho2004
4th May 2012, 14:20
Just to clarify - Using DSS() as you do will most likely return a completely random number of frames. Your trim() statements are therefore a recipe for disaster.

DrPhill
4th May 2012, 14:44
Just to clarify - Using DSS() as you do will most likely return a completely random number of frames. Your trim() statements are therefore a recipe for disaster.
ok, Thanks, that make sense.

DGware it is, then.

sneaker_ger
4th May 2012, 18:20
All the video fragments being joined are in YuY2 (return myVideo.convertToYuY2() at the end of each script), and all are 1280 x 960 pixels. These fragments have all been converted with from AviSynth scripts to m2v using HCEnc.

I see. You didn't post your color space nor did you answer Groucho's question about interlacing, so I assumed the worst, but in YUY2 this does indeed not affect you.

DrPhill
4th May 2012, 18:28
I see. You didn't post your color space nor did you answer Groucho's question about interlacing, so I assumed the worst, but in YUY2 this does indeed not affect you.
Oh, sorry I did not answer - rude of me. I am still so new to all of this that I am confused by all the terminology (eg: I do not think that I am interlacing - but how can I tell?)

Anyway, ditching DSS and using the MPEG2Source seems to work.
It meant a slight channge to the way I work, but I have now got some batch files working.

I have a prototype up on YouTube (http://youtu.be/ALVnqP79wso) of what I am going to do with all of this stuff.

My thanks to all who have helped, despite my fumblings and ineptitude.

DrPhill
4th May 2012, 18:38
And another prototype (http://youtu.be/AQc9OARPYX8).