run ffmpeg with multiple threads - vb.net

Ok i have learnt how to convert videos files using vb.net and ffmpeg. But as far as i know we cannot use multiple threads to run same exe file to convert files. Do you know how i can convert multiple videos using one external exe file (ffmpeg)?
I have not tried because my computer time was over. So iam just asking a general doubt whether if we attach it to one process then wouldn't the process get locked? Then can we multi-thread this application or not ?
Thanks in advance.

But as far as i know we cannot use multiple threads to run same exe file to convert files.
You are mistaken. Multiple FFmpeg instances (1st level OS processes) can run on a single machine. I'm doing this in Java myself. You can even use the same source file. (Obviously, you cannot allow each individual instance to use the same target file.)

Related

Getting batch variables

Hi there. I am busy with making kind of script in batch.
I need to insert into it kind of "Resume" function.
I know how to write variables into a file.
But is it possbile to get it back?
Is it possible to get variables from registry?
I found a nice BAT => EXE converter. It looks really professional if you run .exe in place of .bat. I would like the user to download .exe installer of my batch program, and install the real program. But is it possible to install it (place file of program) as .exe? I don't know much about .exe languages.
If I understand your questions correctly,
Do you want to read a variable that was previously written to a file back into the batch script? Yes, it is possible to read a file into a variable as long as you know the file's format.
Yes, it is possible to read keys and values from the registry using the reg command.
Once you convert a .bat script into an .exe you can distribute it however you like. Place it in a .exe installer, zip it in a archive.

Implement a self extracting archive?

I know i can use 7z or winrar but i want to learn this for myself.
How would i implement a self extracting archive? I can use C# or C++ but let me run down the problem.
When i open the exe i need some kind of GUI asking where to extract the files. Once the user says ok I should obviously extract them. I implemented a simple example in C# winforms already BUT my problem is HOW do i get the filenames and binary of the files into an exe?
One upon a time i ask Is it safe to add extra data to end of exe? and the answer suggested if i just add data to the end of the exe it may be picked up by a virus scanner. Now its pretty easy to write the length of the archive as the last 4bytes and just append the data to my generic exe and i do believe my process can read my own exe so this could work. But it feels hacky and i rather not have people accuse me of writing virus just because i am using this technique. Whats the proper way to implement this?
Note: I checked the self-extracting tag and many of the question is how to manipulate self extracting and not how to implement. Except this one which is asking something else Self-extracting self-checking executable
-edit- I made two self extracting with 7z and compared them. It looks like... well it IS the 7z.sfx file but with a regular 7z archive appended. So... there is nothing wrong with doing this? Is there a better way? I'm targeting windows and can use the C# compiler to help but i don't know how much extra work or how difficult it may be programmatically and maybe adding data to end of exe isnt bad?
It is possible. I used the following technique once, when we needed to distribute updates for the application, but the computers were configured so that the end user had no permissions to change application files. The update was supposed to log on to administrator account and update required files (so we came across identical problem: how to distribute many files as a single executable).
The solution were file resources in C#. All you need to do is:
Create a resource file in your C# project (file ending with .resx).
Add new resource of type "file". You can easily add existing files as byte[] resources.
In program you can simply extract resource as file:
System.IO.FileStream file = new System.IO.FileStream("C:\\PathToFile",
System.IO.FileMode.OpenOrCreate);
System.IO.BinaryWriter writer = new System.IO.BinaryWriter(file);
writer.Write(UpdateApplication.Data.DataValue, 0, UpdateApplication.Data.DataValue.Length);
(Here UpdateApplication.Data denotes binary resource).
Our solution lacked compression, but I believe this is easily achieved with libraries such as C#ZipLib.
I hope this solution is virus-scanner-safe, as this method creates complete, valid executable file.

files opened by a process on VMS

I have a DCL script on VMS which calls a perl script. Is there a VMS/DCL command I can use that will tell me every file handle opened by the perl script?
Set default to the disk the app runs from (or you might have to try each disk in succession if it's a really large or distributed app). Then the command is
show device/files/nosystem
If you're on a more recent version of VMS and the lists are too long, you can pipe it with a search by doing this:
pipe show device/files/nosystem | search sys$input (name of perl script)
You need to find the documentation for undocumented VMS features :-)
Seriously I think that set watch might do what you want. If you issue
$ set watch file/class=(all,nodump)
$ perl yourperlscript.pl
You will get loads of output that will hopefully include what you want. I havent done it for years, you probably tune the options to fine tune it. See
http://www.parsec.com/openvms/undocumented.php?page=13
Jason, I need more clarification for a). Are you saying that you want to run your perl script in a batch file and have the batch file monitor the files being accessed by the perl script? Or something else?
Hmm, not sure about that. Maybe add a linux tag to your post so that some linux people can see this and chime in. I'm not sure why your perl program wouldn't know what files it opened. It's your program, wouldn't it access the files you told it to access? Or if you're computing the filenames somehow (which I've done in cobol, but still know at least which directory to find them in, and what naming scheme they use), you'd still have clues like what I mention. Also, since it's your program, and if you're computing the filenames, coudn't you also make your Perl program output it's own little report of what the files were? Like, just after it computes the filename, have it copy the name string to a separate report file.

Creating File Associations in VB.NET?

How would one go about associating a file type with his application? I know how to read the command line arguments but I am not sure how I can "register" the file extension with Windows. Furthermore, my application is a stand-alone executable, so how would I keep Windows up-to-date on the location of my program?
I did a fair amount of searching and all I could find were old articles that didn't explain everything. How can I create file associations to a stand-alone executable in VB.NET?
Everything is handled by the registry. If you want to make your program self-register it's current location when run see this example.
http://www.codeproject.com/KB/dotnet/System_File_Association.aspx

Cross platform file-access tracking

I'd like to be able to track file read/writes of specific program invocations. No information about the actual transactions is required, just the file names involved.
Is there a cross platform solution to this?
What are various platform specific methods?
On Linux I know there's strace/ptrace (if there are faster methods that'd be good too). I think on mac os there's ktrace.
What about Windows?
Also, it would be amazing if it would be possible to block (stall out) file accesses until some later time.
Thanks!
The short answer is no. There are plenty of platform specific solutions which all probably have similar interfaces, but they aren't inherently cross platform since file systems tend to be platform specific.
How do I do it well on each platform?
Again, it will depend on the platform :) For Windows, if you want to track reads/writes in flight, you might have to go with IFS. If you just want to get notified of changes, you can use ReadDirectoryChangesW or the NTFS change journal.
I'd recommend using the NTFS change journal only because it tends to be more reliable.
On Windows you can use the command line tool Handle or the GUI version Process Explorer to see which files a given process has open.
If you're looking for a get this information in your own program you can use the IFS kit from Microsoft to write a file system filter. The file system filter will show all file system operation for all process. File system filters are used in AV software to scan files before they are open or to scan newly created files.
As long as your program launches the processes you want to monitor, you can write a debugger and then you'll be notified every time a process starts or exits. When a process starts, you can inject a DLL to hook the CreateFile system calls for each individual process. The hook can then use a pipe or a socket to report file activity to the debugger.