Printable Version of Topic
Click here to view this topic in its original format
Unofficial VirtualDub Support Forums > Newbie Questions > Automatic Avi Split


Posted by: stecart May 30 2014, 01:33 PM
Dear all,

I need some help to split many avi files in 3 smaller files. All movies are 30 seconds long and I would like to split them in 10 seconds movies. I can do it manually but I would like to know if there is any way to process this splitting in automatic, I have many videos!
thanks for helping with good hints
Best
ste

Posted by: dloneranger May 30 2014, 01:45 PM
On the file menu -> save segmented avi
You can set a split on a number of frames, or Mb

Posted by: stecart Jun 2 2014, 08:07 AM
QUOTE (dloneranger @ May 30 2014, 01:45 PM)
On the file menu -> save segmented avi
You can set a split on a number of frames, or Mb

Thanks dloneranger for reply. I have tried that, it works even if after it process a file the all program crashes and says something like this:

An out-of-bounds memory access (access violation) occurred in module 'Veedub64'


What I also would love to know is if it is possible to make the automatic process of many files in automatic instead of load file by file and manually segment each of them.
My settings are going to be always the same 1997 frames per segment.
Thanks a lot and have a nice day

s

Posted by: dloneranger Jun 2 2014, 01:57 PM
The access violation is unexpected, try the 32bit version instead
(the log would be useful to show where the error is, in virtualdub or a codec)

You can automate it a few ways, the easiest is with .bat files and a script
Then you can just drag 50 odd files to it and off it goes

There's a BUT with splitting a video though
If you're using direct stream copy mode, you can only split a file on a keyframe - and the chances of those being on frame 1997 are pretty small if the source uses a normal compression codec
If the source is uncompressed then you're fine to use direct stream copy mode

Otherwise you'll need to set a compressor and configure it

We'll need the script of your settings and compressors
To do all this it's easiest if you load one of the videos into virtualdub, set all the compressors etc
And then do
file menu->queue batch operation->save segmented avi
type in any name and save
quit virtualdub

Ok, now open virtualdub's folder and make a copy of virtualdub.jobs (it's a text file with a script in)
Rename it to something meaningful like splitterscript.vdscript
Open it up in notepad (or fave text editor) and look for
VirtualDub.Open("somevideofile.avi" -- or similar at the top
That line needs to be changed to
VirtualDub.Open(VirtualDub.params[0],"",0);
Towards the bottom look for
VirtualDub.SaveSegmentedAVI(""somevideofile.avi"
Change that line to
VirtualDub.SaveSegmentedAVI(VirtualDub.params[0], 2048, 1997, 2);
Just above that, there might be three lines like
VirtualDub.subset.Clear();
VirtualDub.subset.AddRange(0,7138);
VirtualDub.video.SetRange();
Delete those three lines
Now save the file and quit notepad

As an example here's one I modified (that does direct stream copying)
CODE
VirtualDub.Open(VirtualDub.params[0],"",0);
VirtualDub.audio.SetSource(1);
VirtualDub.audio.SetMode(0);
VirtualDub.audio.SetInterleave(1,500,1,0,0);
VirtualDub.audio.SetClipMode(1,1);
VirtualDub.audio.SetEditMode(1);
VirtualDub.audio.SetConversion(0,0,0,0,0);
VirtualDub.audio.SetVolume();
VirtualDub.audio.SetCompression();
VirtualDub.audio.EnableFilterGraph(0);
VirtualDub.video.SetInputFormat(15);
VirtualDub.video.SetOutputFormat(0);
VirtualDub.video.SetMode(0);
VirtualDub.video.SetSmartRendering(0);
VirtualDub.video.SetPreserveEmptyFrames(0);
VirtualDub.video.SetFrameRate2(0,0,1);
VirtualDub.video.SetIVTC(0, 0, 0, 0);
VirtualDub.video.SetCompression();
VirtualDub.video.filters.Clear();
VirtualDub.audio.filters.Clear();
VirtualDub.project.ClearTextInfo();
VirtualDub.SaveSegmentedAVI(VirtualDub.params[0], 2048, 1997, 2);
VirtualDub.Close();


Now, make a new file - lets call it splitter.bat
Open it an a text editor and paste this in
CODE
@echo off
set vdub="C:\Users\Karl\Desktop\VirtualDub-1.10.4\vdub.exe"
set myscript="C:\Users\Karl\Desktop\splitterscript.vdscript"

:loop
if "%~1".=="". goto theend
%vdub% /i %myscript% "%~1" /x
if errorlevel 1 echo Error....&pause
shift
goto loop

:theend
echo.
echo All files processed
pause

Change the two top line to where ever your virtualdub and script actually are, and the right names
note: you don't want the larger virtualdub.exe, but the smaller one that's in the same directory
Save that splitter.bat file

Phew......
Now that's all done, drag a video file to the splitter.bat file
A cmdprompt window should appear, and virtualdub will chug away for a bit
When it says 'all files processed' you should have all the split parts in the same place as the source file, but with .00 .01 etc after the main name
You can also drag multiple files to the.bat file and it'll do them all

Posted by: stecart Jun 2 2014, 03:32 PM
Thanks a lot for helping, I have tried also the 32bit version but it gives me the same error, here is the report.
On the log it says:
Dub:Input (decompression) format is l8.
Dub:Output (compression) format is: RGB888



I am not sure what is a keyframe, my movies are taken with an high speed camera on the whisker of a mouse so the only thing moving are its whiskers, does it have something to do with keyframe?


In the mean time I already followed your instructions to create the two scripts (really detailed instructions). It looks like is working fine, it creates the first 2 files but for the last it crashes the same way it does when I do it manually.
It is already a huge step and I do not know how to thank you enough!! do you think this crashing problem is possible to fix?



VirtualDub crash report -- build 35491 (release)
--------------------------------------

Disassembly:
004dab00: 50 push eax
004dab01: 50 push eax
004dab02: ffd2 call edx
004dab04: 8b4e14 mov ecx, [esi+14h]
004dab07: 8b01 mov eax, [ecx]
004dab09: 8b542410 mov edx, [esp+10h]
004dab0d: 8b404c mov eax, [eax+4ch]
004dab10: 52 push edx
004dab11: ffd0 call eax
004dab13: 8b4c2414 mov ecx, [esp+14h]
004dab17: 014e28 add [esi+28h], ecx
004dab1a: 8b542410 mov edx, [esp+10h]
004dab1e: 8b4e10 mov ecx, [esi+10h]
004dab21: 115e2c adc [esi+2ch], ebx
004dab24: 015630 add [esi+30h], edx
004dab27: 8d542418 lea edx, [esp+18h]
004dab2b: 52 push edx
004dab2c: 115e34 adc [esi+34h], ebx
004dab2f: 8b01 mov eax, [ecx]
004dab31: 8b4048 mov eax, [eax+48h]
004dab34: 8d542420 lea edx, [esp+20h]
004dab38: 52 push edx
004dab39: 6aff push 0ffh
004dab3b: 6aff push 0ffh
004dab3d: ffd0 call eax
004dab3f: 84c0 test al, al
004dab41: 0f8439010000 jz 004dac80
004dab47: 8b4c2418 mov ecx, [esp+18h]
004dab4b: 014e28 add [esi+28h], ecx
004dab4e: 8b4e10 mov ecx, [esi+10h]
004dab51: 8b44241c mov eax, [esp+1ch]
004dab55: 115e2c adc [esi+2ch], ebx
004dab58: 8b11 mov edx, [ecx]
004dab5a: 8b524c mov edx, [edx+4ch]
004dab5d: 50 push eax
004dab5e: ffd2 call edx
004dab60: e91b010000 jmp 004dac80
004dab65: 8b4e14 mov ecx, [esi+14h]
004dab68: 8b01 mov eax, [ecx]
004dab6a: 8b5038 mov edx, [eax+38h]
004dab6d: ffd2 call edx
004dab6f: 84c0 test al, al
004dab71: 0f8409010000 jz 004dac80
004dab77: 8b4e14 mov ecx, [esi+14h]
004dab7a: 8b01 mov eax, [ecx]
004dab7c: 8b5050 mov edx, [eax+50h]
004dab7f: ffd2 call edx
004dab81: 8b4e10 mov ecx, [esi+10h]
004dab84: 8b01 mov eax, [ecx] <-- FAULT
004dab86: 8b4048 mov eax, [eax+48h]
004dab89: 8d54241c lea edx, [esp+1ch]
004dab8d: 52 push edx
004dab8e: 8d54241c lea edx, [esp+1ch]
004dab92: 52 push edx
004dab93: 6aff push 0ffh
004dab95: 6aff push 0ffh
004dab97: ffd0 call eax
004dab99: 84c0 test al, al
004dab9b: 0f84df000000 jz 004dac80
004daba1: 395c2418 cmp [esp+18h], ebx
004daba5: 7518 jnz 004dabbf
004daba7: 8b4e10 mov ecx, [esi+10h]
004dabaa: 8b11 mov edx, [ecx]
004dabac: 8b4238 mov eax, [edx+38h]
004dabaf: ffd0 call eax
004dabb1: 84c0 test al, al
004dabb3: 740a jz 004dabbf
004dabb5: 8b4e10 mov ecx, [esi+10h]
004dabb8: 8b11 mov edx, [ecx]
004dabba: 8b4250 mov eax, [edx+50h]
004dabbd: ffd0 call eax
004dabbf: d9e8 fld1
004dabc1: 8b7c241c mov edi, [esp+1ch]
004dabc5: d9c0 fld st(0)
004dabc7: 8b4e38 mov ecx, [esi+38h]
004dabca: dc7618 fdiv qword ptr [esi+18h]
004dabcd: 33ed xor ebp, ebp
004dabcf: 037e28 add edi, [esi+28h]
004dabd2: 894c2428 mov [esp+28h], ecx
004dabd6: 136e2c adc ebp, [esi+2ch]
004dabd9: 83c718 add edi, 18h
004dabdc: 13eb adc ebp, ebx
004dabde: 8b5e3c mov ebx, [esi+3ch]
004dabe1: 83ec08 sub esp, 08h
004dabe4: dec1 faddp st(1), st
004dabe6: df6e30 fild qword ptr [esi+30h]
004dabe9: dec9 fmulp st(1), st
004dabeb: dd1c24 fstp qword ptr [esp]
004dabee: e87d16f6ff call 0043c270
004dabf3: 83c408 add esp, 08h
004dabf6: 6a00 push 00h
004dabf8: 6a18 push 18h
004dabfa: 52 push edx
004dabfb: 50 push eax
004dabfc: e8 db 0e8h
004dabfd: 4f dec edi
004dabfe: d911 fst dword ptr [ecx]

Built on Althena on Sun Oct 27 15:59:07 2013 using compiler version 1400

Windows 6.1 (Windows 7 x64 build 7601) [Service Pack 1]
Memory status: virtual free 1826M/2048M, commit limit 8107M, physical total 4055M

EAX = 00646e48
EBX = 00000000
ECX = 00000000
EDX = 004da040
EBP = 06a8ff08
ESI = 003bb7f8
EDI = 00000000
ESP = 06a8fe78
EIP = 004dab84
EFLAGS = 00010202
FPUCW = 027f
FPUTW = ffff

Crash reason: Access Violation

Crash context:
An out-of-bounds memory access (access violation) occurred in module 'VirtualDub'...

...reading address 00000000...

...while running thread "Processing" (thread.cpp:197).

Pointer dumps:

EAX 00646e48: 004cff10 004dbde0 004d0050 004d0060 004d00e0 004d0000 004da060 004d0030
EDX 004da040: 006041c6 ccccccc3 cccccccc cccccccc ff5f7be9 ccccccff cccccccc cccccccc
ESI 003bb7f8: 00646e28 00646e20 0018f5f8 00364398 00000000 003bb880 00000000 3ff00000
ESP 06a8fe78: 00000000 003bb7f8 06a8ff08 00000001 00000000 00000000 00421f81 00421f8e
06a8fe98: 00000000 00000000 00000001 00362fa0 004dadac 003bb7f8 0042002f 00362df0
06a8feb8: 06a8fefc 00616a28 00000000 00422ee0 003bb7f8 00000001 00000001 00000000
06a8fed8: 00362df0 00364928 004f9917 06a8ff14 00000001 00000000 00000000 00362df0
EBP 06a8ff08: 06a8ff48 0051a2dc 00364928 0064ae50 00000000 00657600 000000c5 006575e8
06a8ff28: 0062c5ec 00657600 000000c5 006575e8 0062c5ec 06a8ff70 0061efd7 00000000
06a8ff48: 06a8ff80 005fcc0e 00362df0 80fcfa89 00000000 00364928 00364928 c0000005
06a8ff68: 06a8ff54 06a8f8d4 06a8ffc4 00600390 863eb119 00000000 06a8ff94 005fccb3

Thread call stack:
004dab84: VDAVIOutputSegmented::Update()
00421f81: VDDubProcessThread::OnVideoStreamEnded()
00421f8e: VDDubProcessThread::OnVideoStreamEnded()
004dadac: VDAVIOutputSegmented::finalize()
0042002f: VDAVIOutputPreviewSystem::CloseSegment()
00422ee0: _catch$?ThreadRun@VDDubProcessThread@@MAEXXZ$2()
004f9917: ?$VDProtectedAutoScope1::?$VDProtectedAutoScope1()
0051a2dc: VDThread::StaticThreadStart()
005fcc0e: _callthreadstartex()
005fccb3: _threadstartex@4()
772f338a: kernel32!BaseThreadInitThunk [772e0000+13378+12]
77d79f72: ntdll!RtlInitializeExceptionChain [77d40000+39f0f+63]
77d79f45: ntdll!RtlInitializeExceptionChain [77d40000+39f0f+36]

-- End of report

Posted by: dloneranger Jun 2 2014, 04:16 PM
Ok, the crash is in virtualdub
Could be it's not handling the unusual image format properly

Can you upload a sample file so I can check it out?

Posted by: stecart Jun 3 2014, 07:51 AM
https://www.dropbox.com/s/2sw35c1t84098sl/Experiment_76.00.avi

here is a small example

I noticed that I can see this files only with vd and not with vcl, maybe this is the problem

Posted by: stecart Jun 3 2014, 08:32 AM
And actually there is no audio in my movies

Posted by: dloneranger Jun 3 2014, 12:03 PM
Looks like a bug in virtualdub 1.10.4
Fixed in 1.10.5 test versions
QUOTE
AVI: Fixed crash when exporting segments with no audio track.

http://forums.virtualdub.org/index.php?act=ST&f=15&t=22042

Posted by: stecart Jun 3 2014, 12:54 PM
Great you were right, it is amazing!!it is working, this night I will run the automatic splitting of many files and I let you know how is working.
Really thank you, you are the Master! smile.gif

Posted by: stecart Jun 4 2014, 01:24 PM
Actually there is still something wrong, the script is splitting the files in the right way but it is not reducing their size at all.
Could it be because is not running in direct stream copy?
Is there anyway to correct for this?

Posted by: dloneranger Jun 4 2014, 01:59 PM
If you've used that example above, it's in direct stream copy mode
There's some overhead in an avi - about 18K in a 1 frame video I tested with
What are the actual file sizes of source and output?
Have you checked the frame count of the finished files?

Posted by: stecart Jun 4 2014, 02:06 PM
Problem solved, I had to change this line VirtualDub.video.SetMode(0);
The problem is that I did not really copy and paste the text but I did just changed the lines you told me and in my original script the value was not 0.
I have run the script overnight and it worked fine, only problem was the size, now I can start my splitting marathon !
Thanks again
s

Posted by: dloneranger Jun 4 2014, 02:19 PM
I was going to make a longer version of your test file, but weirdness happened

Loading it into virtualdub it's 62 frames long, appending the same video should give double the length, but it comes adds an extra 500 frames, all of which are blank

Not sure if that's a problem with the small clip you made, or a vdub problem - can't tell without an original
You could test by loading 1 video and appending the same video, the length should be doubled

Posted by: stecart Jun 5 2014, 08:45 AM
It might be a problem with the example I gave you, it is everything going smooth now!Thanks again
Is it possible to also enhance contrast and brightness in my movies?

Posted by: dloneranger Jun 5 2014, 11:17 AM
Yes, but you have to do full processing and recompress the video
There are brightness/contrast and levels filters built in to virtualdub, plus many other add on plugins (eg multiadjust in my sig)

There are plenty of how-to's on youtube
Here's one of me doing fadeins and then brightness/contrast/saturation adjustment + showing how the curve editor works
https://www.youtube.com/watch?v=hVLsDW5nQso

Powered by Invision Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)