Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > VapourSynth

Reply
 
Thread Tools Search this Thread Display Modes
Old 8th August 2017, 09:27   #2601  |  Link
lansing
Registered User
 
Join Date: Sep 2006
Posts: 1,657
Quote:
Originally Posted by blaze077 View Post
It's all there in the documentation:
FrameNum | FrameProps | SetFrameProp

A frame's properties can be accessed by using the get_frame function along with the props attribute. Like so:
Code:
src.get_frame(num).props.someFrameProperty = someValue
Reference.
That still doesn't tell me the list of properties of a frame. The problem I have is that I didn't even know the name. In my example, how do I know the name to call frame number? Is it ".props.frame_number" or ".props.frame_num", or is it "props.framenum"? The reference sure doesn't have them.
lansing is offline   Reply With Quote
Old 8th August 2017, 09:34   #2602  |  Link
TheFluff
Excessively jovial fellow
 
Join Date: Jun 2004
Location: rude
Posts: 1,100
http://www.vapoursynth.com/doc/apire...ame-properties

I'm not sure if there's a standard for anything else. The props are just a key-value map that can contain anything though so just iterate over the keys and all secrets will be revealed to you. Maybe.
TheFluff is offline   Reply With Quote
Old 8th August 2017, 22:35   #2603  |  Link
lansing
Registered User
 
Join Date: Sep 2006
Posts: 1,657
Quote:
Originally Posted by TheFluff View Post
http://www.vapoursynth.com/doc/apire...ame-properties

I'm not sure if there's a standard for anything else. The props are just a key-value map that can contain anything though so just iterate over the keys and all secrets will be revealed to you. Maybe.
Thanks, I didn't know that they were listed on that page, I was looking all over the python reference and function reference page.
lansing is offline   Reply With Quote
Old 11th August 2017, 17:24   #2604  |  Link
lansing
Registered User
 
Join Date: Sep 2006
Posts: 1,657
Hi I have another question, is there a function that can delete a series of ranges of frames? For example, I wanted to delete frame 1-10, 100-200 and 500-600 of a clip.
lansing is offline   Reply With Quote
Old 11th August 2017, 17:26   #2605  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,548
Quote:
Originally Posted by lansing View Post
Hi I have another question, is there a function that can delete a series of ranges of frames? For example, I wanted to delete frame 1-10, 100-200 and 500-600 of a clip.
Sure is. Trim and splice.
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 12th August 2017, 09:39   #2606  |  Link
lansing
Registered User
 
Join Date: Sep 2006
Posts: 1,657
Quote:
Originally Posted by HolyWu View Post
DeleteFrames should be easier to use.
Can you give an example?
lansing is offline   Reply With Quote
Old 12th August 2017, 15:28   #2607  |  Link
tuanden0
Registered User
 
Join Date: Oct 2016
Posts: 111
I'm new to vapoursynth, Can someone help me?
I need to change this line in Aviysnth with aWarpSharp filter to Vapoursynth with aWarpSharp2.
I haven't used aWarpSharp2 filter with Avisynth yet
Quote:
aWarpSharp(depth=12, thresh=0.2, cm=1)
tuanden0 is offline   Reply With Quote
Old 12th August 2017, 18:52   #2608  |  Link
WolframRhodium
Registered User
 
Join Date: Jan 2016
Posts: 162
Quote:
Originally Posted by tuanden0 View Post
I'm new to vapoursynth, Can someone help me?
I need to change this line in Aviysnth with aWarpSharp filter to Vapoursynth with aWarpSharp2.
I haven't used aWarpSharp2 filter with Avisynth yet
According to pinterf's code


Code:
aWarpSharp(depth=12, thresh=0.2, cm=1)
in Avisynth is (almost) equivalent to

Code:
aWarpSharp2(depth=12, thresh=51, chroma=4)
So in VapourSynth, I think it should be

Code:
last = core.warp.AWarpSharp2(last, depth=12, thresh=51, chroma=0)

Last edited by WolframRhodium; 12th August 2017 at 18:54.
WolframRhodium is offline   Reply With Quote
Old 12th August 2017, 18:55   #2609  |  Link
ChaosKing
Registered User
 
Join Date: Dec 2005
Location: Germany
Posts: 1,795
Quote:
Originally Posted by tuanden0 View Post
I'm new to vapoursynth, Can someone help me?
I need to change this line in Aviysnth with aWarpSharp filter to Vapoursynth with aWarpSharp2.
I haven't used aWarpSharp2 filter with Avisynth yet
From aWarpSharp2 readme (avisynth)
Quote:
Original aWarpSharp compatibility:
Mapping from original aWarpSharp parameters:
thresh = thresh*256
blur = blurlevel
depth = depth*blurlevel/2
chroma = 0->2, 1->4, 2->3
Code:
aWarpSharp(depth=12, thresh=0.2, cm=1)
You should change thresh to 51 or 52 in awarpsharp2
__________________
AVSRepoGUI // VSRepoGUI - Package Manager for AviSynth // VapourSynth
VapourSynth Portable FATPACK || VapourSynth Database
ChaosKing is offline   Reply With Quote
Old 12th August 2017, 19:00   #2610  |  Link
WolframRhodium
Registered User
 
Join Date: Jan 2016
Posts: 162
Quote:
Originally Posted by lansing View Post
Can you give an example?
I'll use following code in this case:

Code:
frame_list = list(range(1, 10+1)) + list(range(100, 200+1)) + list(range(500, 600+1))
last = core.std.DeleteFrames(last, frame_list)
WolframRhodium is offline   Reply With Quote
Old 12th August 2017, 21:05   #2611  |  Link
lansing
Registered User
 
Join Date: Sep 2006
Posts: 1,657
Quote:
Originally Posted by WolframRhodium View Post
I'll use following code in this case:

Code:
frame_list = list(range(1, 10+1)) + list(range(100, 200+1)) + list(range(500, 600+1))
last = core.std.DeleteFrames(last, frame_list)
Thanks, this is what I'm looking for.
lansing is offline   Reply With Quote
Old 13th August 2017, 03:15   #2612  |  Link
tuanden0
Registered User
 
Join Date: Oct 2016
Posts: 111
@WolframRhodium, @ChaosKing

Thank You very much
tuanden0 is offline   Reply With Quote
Old 13th August 2017, 04:25   #2613  |  Link
hydra3333
Registered User
 
Join Date: Oct 2009
Location: crow-land
Posts: 540
Quote:
Originally Posted by Myrsloik View Post
R38 is released.

The usual post
Thank you for your great work !

I also appreciate your enabling people to compile their own bits (in my case avisynth_compat.cpp). Beaut !
hydra3333 is offline   Reply With Quote
Old 13th August 2017, 09:45   #2614  |  Link
lansing
Registered User
 
Join Date: Sep 2006
Posts: 1,657
How do I overlay text on the frame, like showing frame number of every frame? I can only think of this, but it's certainly a wrong way to do it because it ate up all my ram until the program crashed on longer videos.

Code:
for i in range (len(clip)):
	if (i==0):
		sub_clip = core.sub.Subtitle(clip[i], text=str(i))
	else:
		sub_clip += core.sub.Subtitle(clip[i], text=str(i))
lansing is offline   Reply With Quote
Old 13th August 2017, 10:19   #2615  |  Link
AzraelNewtype
Registered User
 
AzraelNewtype's Avatar
 
Join Date: Oct 2007
Posts: 135
Code:
clip = core.text.FrameNum(clip)
You really might want to actually read the docs.
AzraelNewtype is offline   Reply With Quote
Old 13th August 2017, 13:41   #2616  |  Link
lansing
Registered User
 
Join Date: Sep 2006
Posts: 1,657
Quote:
Originally Posted by AzraelNewtype View Post
Code:
clip = core.text.FrameNum(clip)
You really might want to actually read the docs.
Thanks. I did read the documents many many times, I thought this function is to print the frame number out to the console, like "print(x)". And there's no sample codes showing what it does.
lansing is offline   Reply With Quote
Old 13th August 2017, 13:59   #2617  |  Link
TheFluff
Excessively jovial fellow
 
Join Date: Jun 2004
Location: rude
Posts: 1,100
The use of the word "print" in the docs is a bit confusing, yes. It should probably clarify that it refers to printing on the video frame.

Either way though, requesting all frames in the input clip in Python and splicing one frame at a time is an extremely awkward way of doing things in VS. If you ever find yourself writing a loop that requests frames in Python, you're probably doing things wrong. Yes, iterating over a sequence is intuitive for most programmers, but in the VS world, you need to stop thinking imperative programming and start thinking functional. What you want to write is a composition of functions that does what you want, handling one or at most a few frames at a time, and leave invoking that function chain up to the client application (usually vspipe). Or in other words, start attaching callbacks to things. One more idiomatic way of reimplementing the equivalent of what core.text.FrameNum does yourself is by using FrameEval (example stolen from the docs and slightly modified):

Code:
import vapoursynth as vs
import functools

core = vs.get_core()
base_clip = core.std.BlankClip(format=vs.YUV420P8, length=1000, color=[255, 128, 128])

def PrintFrameNumber(n, clip):
  return core.sub.Subtitle(clip, text=str(n))

number_clip = core.std.FrameEval(base_clip, functools.partial(PrintFrameNumber, clip=base_clip))
You might be thinking that this is just doing the same thing that you did. The difference is that here, the subtitling is done when a frame is actually requested, not when the Python script is compiled, and it can be parallelized by the VS thread pool to subtitle many frames at once.

Last edited by TheFluff; 13th August 2017 at 14:03.
TheFluff is offline   Reply With Quote
Old 14th August 2017, 01:25   #2618  |  Link
lansing
Registered User
 
Join Date: Sep 2006
Posts: 1,657
Thanks for the explanation, that's really clear. I practiced with a few simple function, [s]but I got the error "BuildSCClip() missing 1 required positional argument: 'f'", what does it mean?[/s]

update: I figured out the last problem. And for this one, why didn't it return a delete even clip back to me?

Code:
import vapoursynth as vs
import functools

core = vs.get_core(accept_lowercase=True)

source = abc.avi 

def DeleteEven(n, clip):
	if n % 2 ==0:		
		return core.std.DeleteFrames(clip, n)
	return clip

odd = core.std.FrameEval(source, functools.partial(DeleteEven, clip=source)) 

odd.set_output()

Last edited by lansing; 14th August 2017 at 07:53. Reason: update
lansing is offline   Reply With Quote
Old 14th August 2017, 06:17   #2619  |  Link
tuanden0
Registered User
 
Join Date: Oct 2016
Posts: 111
Can someone give me an example of using TCanny to create a mask and apply it to keep detail in dark area?
I tried it myself but the output turn on black and mask

Here's my output:
http://i.imgur.com/yBgilc4.png

Last edited by tuanden0; 14th August 2017 at 07:47.
tuanden0 is offline   Reply With Quote
Old 14th August 2017, 22:25   #2620  |  Link
TheFluff
Excessively jovial fellow
 
Join Date: Jun 2004
Location: rude
Posts: 1,100
Quote:
Originally Posted by lansing View Post
Thanks for the explanation, that's really clear. I practiced with a few simple function, [s]but I got the error "BuildSCClip() missing 1 required positional argument: 'f'", what does it mean?[/s]

update: I figured out the last problem. And for this one, why didn't it return a delete even clip back to me?

Code:
import vapoursynth as vs
import functools

core = vs.get_core(accept_lowercase=True)

source = abc.avi 

def DeleteEven(n, clip):
	if n % 2 ==0:		
		return core.std.DeleteFrames(clip, n)
	return clip

odd = core.std.FrameEval(source, functools.partial(DeleteEven, clip=source)) 

odd.set_output()
Well, I dunno. Aside from DeleteFrames taking a list of ints, not a single int (I think) that kinda looks like it should work (maybe; I'm a bit unsure of what'll happen on the last frame of the clip). I don't think "source = abc.avi" is what's actually in your script though. What does happen when you try to run it?
TheFluff is offline   Reply With Quote
Reply

Tags
speed, vaporware, vapoursynth

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 20:17.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.