Log in

View Full Version : Altering frames using photoshop


canuckerfan
1st April 2012, 10:13
I recently discovered that saved images of frames can be inserted into a video using avisynth. This is especially handy for manual removal of spots.

For example, if I want to replace frame number 5301 in a video, here's what I would do:

video=avisource("G:\movie.avi",audio=false) #movie is 23.9760240 fps
pic1 = ImageSource("G:\5301.bmp",end=0,fps=23.9760240).converttoyv12() #rest of the movie is in yv12 colourspace

a=video.trim(0,5300)
b=video.trim(5302,266124)

final = a+pic1+b
return final

The above method also works with more frames using more trim commands. Are there any disadvantages/caveats to this process that I should know about?

mastrboy
1st April 2012, 12:24
might be easier to use stickboy's tools rather than having a huge script filled with trims: http://avisynth.org/stickboy/RemapFrames.zip

canuckerfan
1st April 2012, 19:11
That's a handy plugin. Would this be the most efficient way to use it?

src=avisource("F:\movie.avi", audio=false)
fr1=imagesource("F:\8950.bmp",end=266124,fps=23.9760240).converttoyv12()
fr2=imagesource("F:\36252.bmp",end=266124,fps=23.9760240).converttoyv12()

ReplaceFramesSimple(src, fr1, mappings="8950")
ReplaceFramesSimple(src, fr2, mappings="36252")

smok3
1st April 2012, 19:23
Are there any disadvantages/caveats to this process that I should know about?

Did you know that extened version of photoshop (i think its cs3 and up) can work with video directly?

canuckerfan
1st April 2012, 19:27
Did you know that extened version of photoshop (i think its cs3 and up) can work with video directly?
I only have version 7.0 and I really don't have the funds for CS3. But maybe I could be motivated to get it if it could save AVI's losslessly.

Btw, I tried out my above code and it seems only frame 36252 is being replaced. Frame 8950 stays the same unless I comment out the ReplaceFrameSimple line for 36252.

canuckerfan
1st April 2012, 19:30
Did you know that extened version of photoshop (i think its cs3 and up) can work with video directly?
I only have version 7.0 and I really don't have the funds for CS3. But maybe I could be motivated to get it if it could save AVI's losslessly.

Btw, I tried out my above code and it seems only frame 36252 is being replaced. Frame 8950 stays the same unless I comment out the ReplaceFrameSimple line for 36252. Any ideas?

edit: sorry for the double post

edit2: I figured it out:

src=avisource("F:\English\Temporary\DCH\deflicker2.avi", audio=false)
fr1=imagesource("F:\English\Temporary\DCH\Frames\8950.bmp",end=266124,fps=23.9760240).converttoyv12()
fr2=imagesource("F:\English\Temporary\DCH\Frames\36252_fixed.bmp",end=266124,fps=23.9760240).converttoyv12()

src2=ReplaceFramesSimple(src, fr1, mappings="8950")
ReplaceFramesSimple(src2, fr2, mappings="36252")

The above code now works. But is there anyways I can combine that into 1 call for ReplaceFramesSimple?

smok3
1st April 2012, 19:49
I could be motivated to get it if it could save AVI's losslessly.
no idea, i'am on mac (when in adobe mode).

p.s. a noobie-to-photoshop-video example http://youtu.be/GYFZgolqYow
input: rle/anim, ouput: rle/anim

canuckerfan
1st April 2012, 20:57
no idea, i'am on mac (when in adobe mode).

p.s. a noobie-to-photoshop-video example http://youtu.be/GYFZgolqYow
input: rle/anim, ouput: rle/anim
I did some googling and I don't think it can. Oh well.

Using the above code works for me anyways. However, I'm trying to use ImageSource() to load up multiple .bmp files and create one clip with the "fixed" frames at particular spots in the clip. This way, I only need to call ReplaceFramesSimple once with multiple values for frames. Don't think I can do it this way though.

edit: this process can quite laborious when doing hundreds of frames. any ideas on how to make an easier script than this?

src=avisource("F:\English\Temporary\DCH\deflicker2.avi", audio=false)

fr1=imagesource("F:\English\Temporary\DCH\Frames\3513.bmp",end=266124,fps=23.9760240).converttoyv12()
fr2=imagesource("F:\English\Temporary\DCH\Frames\3899.bmp",end=266124,fps=23.9760240).converttoyv12()
fr3=imagesource("F:\English\Temporary\DCH\Frames\3900.bmp",end=266124,fps=23.9760240).converttoyv12()
fr4=imagesource("F:\English\Temporary\DCH\Frames\3901.bmp",end=266124,fps=23.9760240).converttoyv12()
fr5=imagesource("F:\English\Temporary\DCH\Frames\4120.bmp",end=266124,fps=23.9760240).converttoyv12()


src2=ReplaceFramesSimple(src, fr1, mappings="3513")
src3=ReplaceFramesSimple(src2, fr2, mappings="3899")
src4=ReplaceFramesSimple(src3, fr3, mappings="3900")
src5=ReplaceFramesSimple(src4, fr4, mappings="3901")
ReplaceFramesSimple(src5, fr5, mappings="4120")

You can imagine this script getting longer and longer with more frames...

Gavino
2nd April 2012, 01:10
However, I'm trying to use ImageSource() to load up multiple .bmp files and create one clip with the "fixed" frames at particular spots in the clip. This way, I only need to call ReplaceFramesSimple once with multiple values for frames. Don't think I can do it this way though.
Do it like this:
src=avisource("F:\English\Temporary\DCH\deflicker2.avi", audio=false)

imgs=imagesource("F:\English\Temporary\DCH\Frames\%d.bmp",end=266124).converttoyv12()

ReplaceFramesSimple(src, imgs, mappings="3513 3899 3900 3901 4120")
You will have to create a dummy frame 0.bmp, otherwise ImageSource wil complain, but apart from that, only the frames actually referenced by ReplaceFramesSimple need to exist.

canuckerfan
2nd April 2012, 01:23
^Thanks! Works like a charm. You have saved me hours of work :D

How many images do you think it could load before the memory begins to fill up? Or is that not an issue?

Gavino
2nd April 2012, 10:51
How many images do you think it could load before the memory begins to fill up? Or is that not an issue?
It's not an issue now that you have switched to using a single ImageSource call.
With multiple calls as in your original script, you would hit a limit with a large number of frames - difficult to quantify and depends on image size.