Log in

View Full Version : ImageWriter - How to restrict file name output to 4 digits 0%4d


Yellow_
5th September 2010, 16:47
Hi

How do I restrict the file naming output from IW to 4 digits, the usual 0%4d type of thing? I'm getting 000000.png etc currently amd I want 0000.png onwards.

poisondeathray
5th September 2010, 17:50
"filename%04d.png"

Yellow_
5th September 2010, 18:12
:-), I've tried all sorts of variations before posting such as

ImageWriter("d:\path\to\images\test_%04d.png", "png")

And your suggestion, but still can't get it to work, invalid arguments etc.

And not specifying the "png" gives me avisynths ebmp. :-(

Also I need the filename to be just the incremental number like 0000.png. Is that possible?

Cheers

poisondeathray
5th September 2010, 18:14
You need to fill in the other arguments, start frame #, end frame #.

EDIT: sorry you're right, it's not working. I think it's supposed to use sprintf syntax, like imagesource, so it should work... maybe only imagesource works like that and not imagewriter() ?

As an alternative, you can load your avs script into vdub to control the prefix & digits and export png sequence

Yellow_
5th September 2010, 18:51
Thanks, I've just been looking at Wilberts Immaavs again but don't see the option there either. :-(

Yes, usually use Vdub for this sort of thing but I'm trying to do a uncompressed avi or mkv using vdub + proxies (writing out via Imagewriter) in the same play through. But not turning out well. :-) Guess I'll look at vdub batch wizard again but don't think it can handle jobs of differing types in the same job list?

Thanks for your help.

poisondeathray
5th September 2010, 18:56
Yeah I don't get it, that syntax works for imagesource (and other programs that use wildcards), but not imagewriter :( ... not sure why

Not sure about vdub batching different types of "jobs". What types of jobs were you referring to? You should be able to make ffmpeg batch file.

Wilbert
5th September 2010, 19:01
How do I restrict the file naming output from IW to 4 digits, the usual 0%4d type of thing?
I will try to add it when i have some time (that holds for immaavs as well).

Yellow_
5th September 2010, 20:47
Yes, was considering using FFmpeg feeding it the .avs files. Cheers.

Wilbert, sounds great, if you find time to do Immaavs as well, could you recompile with ImageMagick at Q16? For the 16bit output. I understand from the Immaavs thread that even then it may not produce what's needed re AVISynth 8bit only. But it would be great to try. :-)

ganymede
5th September 2010, 22:38
:-), I've tried all sorts of variations before posting such as

ImageWriter("d:\path\to\images\test_%04d.png", "png")

And your suggestion, but still can't get it to work, invalid arguments etc.

And not specifying the "png" gives me avisynths ebmp. :-(

Also I need the filename to be just the incremental number like 0000.png. Is that possible?

Cheers
Did you try :
ImageWriter("d:\path\to\images\test_%04d.png", type="png") ?
It works for me (also under linux+wine) - at least the png files are created, no "invalid arguments". BUT the name of these png files is "test_%04d.png000000.png", "test_04d.png000001.png", etc.

IanB
6th September 2010, 01:00
The filename construction code is this :- // construct filename
ostringstream fn_oss;
fn_oss << base_name << setfill('0') << setw(6) << n << '.' << ext;
string filename = fn_oss.str();base_name is from argument 1, "file"
ext is from argument 4, "type"
n is the current frame number.

Yes this sucks, added to the todo list.

Yellow_
6th September 2010, 06:56
ganymede & IanB. Thanks for the response, glad it's not just me then who found it not possible. :-)

Emulgator
6th September 2010, 15:23
Just as a workaround suggestion until this is implemented:
A renamer could help here.
File and MP3 Renamer 5.25 is freeware now and can do this.

Yellow_
6th September 2010, 18:27
Emulgator, thanks for the suggestion.

Yellow_
7th November 2010, 09:31
Just catching up, wonder whether the option to restrict number of zeros in filename output through Imagewriter is in the code and if a build is available somewhere?

Wilbert
8th November 2010, 00:07
Just catching up, wonder whether the option to restrict number of zeros in filename output through Imagewriter is in the code and if a build is available somewhere?
No, not yet.

IanB
9th November 2010, 00:23
Feature committed to CVS.

If base_name contains a '%' character user formatting is assumed. Printf argument 1 is N, the frame number. Argument 2 is the extension string.

Example use :-

ImageWriter("filename_%04d.%s", type ="png") # Default extension

or

ImageWriter("C:\Dir\Filename_%3d_Mine.JPEG", type ="jpg") # non-default extension

Code changes :- if (strchr(base_name, '%') == NULL) {
base_name[(sizeof base_name)-8] = '\0';
strcat(base_name, "%06d.%s"); // Append default formatting
}
...
_snprintf(temp, MAX_PATH, base_name, n, ext);

Yellow_
9th November 2010, 14:35
Most Excellent. :-)

Now off to find a build, I'm on Linux + Wine so no Win32 build enviroment set up. :-(

Cheers.