Log in

View Full Version : ImageSource, Dissolve, frame rate - slightly off total length?


pinkshiro
19th January 2011, 09:08
I've setup a page which allows you to upload images, set various kenBurnsEffects to each image, and then spits out a video for you.

ImageSource's default FPS is 24 (happy with that)

By the time my avs is processed by Ffmpeg, my video length is always over what it should be.

Take this example, four images are added using ImageSource, the first with a length of 120frames, and the rest 132 frames.

The four images are Dissolved together, with the dissolve length set to 12 seconds. Hence why the final three images have 12 frames added, to account for the dissolve.

This should come out to 480 frames, at 24fps, the video should be 20 seconds? After I pass it through Ffmpeg though, its 20.166 seconds...

Below is my AVS, and my ffmpeg command. Do you have any tips or ideas as to why the video length is out?

AVS:
Import("kenburnseffect.avs")

Img1=ImageSource("img-1.jpg", end = 120, use_DevIl=false)
Img2=ImageSource("img-2.jpg", end = 132, use_DevIl=false)
Img3=ImageSource("img-3.jpg", end = 132, use_DevIl=false)
Img4=ImageSource("img-4.jpg", end = 132, use_DevIl=false)

Img1=Img1.Crop((Width(Img1)-640)/2, (Height(Img1)-360)/2, 640, 360).ConvertToRGB32()
Img2=Img2.Crop((Width(Img2)-640)/2, (Height(Img2)-360)/2, 640, 360).ConvertToRGB32()
Img3=Img3.Crop((Width(Img3)-640)/2, (Height(Img3)-360)/2, 640, 360).ConvertToRGB32()
Img4=Img4.Crop((Width(Img4)-640)/2, (Height(Img4)-360)/2, 640, 360).ConvertToRGB32()

Img1=Img1.KenBurnsEffect(startFrame=0, endFrame=120, KeepState=false, startZoomFactor=100, endZoomFactor=100)
Img2=Img2.KenBurnsEffect(startFrame=0, endFrame=132, KeepState=false, startZoomFactor=100, endZoomFactor=100)
Img3=Img3.KenBurnsEffect(startFrame=0, endFrame=132, KeepState=false, startZoomFactor=100, endZoomFactor=100)
Img4=Img4.KenBurnsEffect(startFrame=0, endFrame=132, KeepState=false, startZoomFactor=100, endZoomFactor=100)

FinalVideo = Dissolve(Img1, Img2, Img3, Img4, 12)

VideoLength = FrameCount(FinalVideo)
flipvertical(FinalVideo)

Ffmpeg:

ffmpeg.exe -i "sample.avs" -crf 18.0 -vcodec libx264 -acodec libfaac -ab 192kb -coder 1 -flags +loop -cmp +chroma -partitions +parti8x8+parti4x4+partp8x8+partb8x8 -me_method hex -subq 6 -me_range 16 -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -b_strategy 2 -qcomp 0.6 -qdiff 4 -bf 4 -refs 4 -directpred 3 -threads 0 -s 640x360 -y "sample.mp4"

Perhaps I've mucked up with my ffmpeg command?

Gavino
19th January 2011, 09:55
four images are added using ImageSource, the first with a length of 120frames, and the rest 132 frames.
Img1=ImageSource("img-1.jpg", end = 120, use_DevIl=false)
Img2=ImageSource("img-2.jpg", end = 132, use_DevIl=false)
Since frames are numbered from 0, you actually have 121 and 133 frames. Four extra frames in total giving 1/6 sec extra.

Use end=119 and 131, both here and in the KenBurnsEffect endframe parameter.

pinkshiro
19th January 2011, 19:47
What an oversight.

Thanks so much for the reply. Appreciate it. :thanks: