amc file format
amc file format
I'm developing a plugin for TVedia that reads ant movies database, can u help me with reading the amc file?¿
Regards,
.:FiDo:.
Regards,
.:FiDo:.
I'm reading now the file format info, thanks, but i have some questions... If i open the file for reading binary format, how can i know the leght of each field? the picture is in an array of bytes... how do i know where to finish? I'm using javascript for the script, can u post here a little sample code for reading a single field in the file?
Many thanks in advance,
.:FiDo:.
Many thanks in advance,
.:FiDo:.
I'm using this code in javascript:
objStream = new ActiveXObject("ADODB.Stream");
objStream.Open();
objStream.Type = 1;
objStream.LoadFromFile("D:\\Mis documentos\\Catalogo peliculas\\Mi catalogo.amc");
var dataArr = objStream.Read(35);
...
objStream.Close();
objStream = null;
but dataArr contains a byte array that i don't know how to decode... any ideas??
.:FiDo:.
objStream = new ActiveXObject("ADODB.Stream");
objStream.Open();
objStream.Type = 1;
objStream.LoadFromFile("D:\\Mis documentos\\Catalogo peliculas\\Mi catalogo.amc");
var dataArr = objStream.Read(35);
...
objStream.Close();
objStream = null;
but dataArr contains a byte array that i don't know how to decode... any ideas??
.:FiDo:.
I also need some help reading the file. I'm using Java and I need to know if the integer that represents the string length is Big Endian or Little Endian. That will help a bit.
Another question, so that I confirm that I'm not thinking this the wrong way:
Your file starts with an integer stating the size of the string
"AMC_3.5 Ant Movie Catalog 3.5.x www.buypin.com www.antp.be" an then has the string, after that there is another integer to tell how long is the owner name field followed by the owner name string?
Generally speaking, to read your file, one would follow these lines:
read an int into x
read x bytes representing the first string
read an int into y
read y bytes representing the owner name
and so on for the header. After that one will go on reading the rest of the fields.
Another question, so that I confirm that I'm not thinking this the wrong way:
Your file starts with an integer stating the size of the string
"AMC_3.5 Ant Movie Catalog 3.5.x www.buypin.com www.antp.be" an then has the string, after that there is another integer to tell how long is the owner name field followed by the owner name string?
Generally speaking, to read your file, one would follow these lines:
read an int into x
read x bytes representing the first string
read an int into y
read y bytes representing the owner name
and so on for the header. After that one will go on reading the rest of the fields.
I would like to but I really can't
Assuming the integer is Big Endian I would right teh following code to read an integer:
This results in a wrong integer size, so I belive as "541150531" can't be the size of any string
If I assume it's little endian I'll have to read as:
This results in the number "1129136416"...
So I don't know where to go to.[/code]
Assuming the integer is Big Endian I would right teh following code to read an integer:
Code: Select all
DataInputStream din = new DataInputStream(new BufferedInputStream((new FileInputStream("c:\\testcatalog.amc"));
int integersize = din.readInt();
If I assume it's little endian I'll have to read as:
Code: Select all
BufferedInputStream bin = new BufferedInputStream(new FileInputStream("c:\\testcatalog.amc"));
byte[] fourbytes = new byte[4];
bin.read(fourbytes);
int integersize = ((fourbytes[0] & 0xff)) | ((fourbytes[1] & 0xff) << 8) | ((fourbytes[2] & 0xff) << 16) | ((fourbytes[3] & 0xff) << 24);
So I don't know where to go to.[/code]
There is a space (0x20) before and after the header string, that you did not include in the quotes in your message, be sure to have these in your code. You have to "skip" these 65 bytes then.
Then you have the integer size of the owner name, then the owner name itself, etc.
I always forget these big/little endian things, but if I remember correctly Delphi uses little endian, so AMC's file format uses that too.
It would maybe be easier to make a sample catalog with 1 movie and a special value in each file (including file->properties), and then watch the contents with an hexadecimal editor, though that I do not see what is missing in what I said above and in the help file
Code: Select all
strFileHeader35 = ' AMC_3.5 Ant Movie Catalog 3.5.x www.buypin.com www.antp.be ';
I always forget these big/little endian things, but if I remember correctly Delphi uses little endian, so AMC's file format uses that too.
It would maybe be easier to make a sample catalog with 1 movie and a special value in each file (including file->properties), and then watch the contents with an hexadecimal editor, though that I do not see what is missing in what I said above and in the help file
Well I was reading that the every string had an integer stating the size and, because you didn't said otherwise, I assumed that the first string in the file also had that integer. I was trying to read the first four bytes of the file as an integer.
I then found that those 4 bytes represented " ACM", now I know what I'm doing wrong
I would suggest that the either the help file be change or the file format be changed so that *every* string has it's size stated before. It will help make things more correct. If you decide to change the header I have to recompile the software, if you add the size of that first string then even if the header is changed the software works.
It just doesn't make sense to have on string in the all file that does not have it's size before.
I think I can now manage. Thank you.
I then found that those 4 bytes represented " ACM", now I know what I'm doing wrong
I would suggest that the either the help file be change or the file format be changed so that *every* string has it's size stated before. It will help make things more correct. If you decide to change the header I have to recompile the software, if you add the size of that first string then even if the header is changed the software works.
It just doesn't make sense to have on string in the all file that does not have it's size before.
I think I can now manage. Thank you.
In the help file you have
Is the ";" character in the file?
Code: Select all
"OwnerName: string;"
The header is not a string, it is just the header
Its purpose is to identify the version of the program and prevent old programs to read newer formats that they would not be able to read correctly if I add a field.
So of course programs has to be recompiled to use the new file format when it is modified.
XML is a better choice for compatibility with non-existing-yet versions, so maybe some day I may use XML (even if stored in another format) rather than current system.
About the date, indeed it is a special value since a fixed date. It is Delphi's TDateTime format, 0 = 30-12-1899 and each unit is one day (decimal part, not used in this case, is for the time).
Its purpose is to identify the version of the program and prevent old programs to read newer formats that they would not be able to read correctly if I add a field.
So of course programs has to be recompiled to use the new file format when it is modified.
XML is a better choice for compatibility with non-existing-yet versions, so maybe some day I may use XML (even if stored in another format) rather than current system.
About the date, indeed it is a special value since a fixed date. It is Delphi's TDateTime format, 0 = 30-12-1899 and each unit is one day (decimal part, not used in this case, is for the time).
If you don't add more than 65 bytes I believe I can live with that
I want to be able to read this file format, writing it will most likely not be an option.
So if the date is days after 30-12-1899 I can just subtract todays date, in days, from the assumed zero date and get the number of days.... maybe there is still light at the end of the tunel
By the way, fidoboy, I have been able to read the AMC binary file. I always read byte arrays. When reading integer you have to read 4 bytes at a time and convert those 4 bytes into a single integer value. The integer format is little endian. When reading strings you just need to read the number of byte that form the string and every array position will hold the value of the ASCII character it corresponds to. I haven't got to the picture nor the boolean values yet but I think they'll not be a problem.
I'll try to make my spike solution more developer friendly and I'll post the solution. If I can I'll make it tomorrow.
Thanks
I want to be able to read this file format, writing it will most likely not be an option.
So if the date is days after 30-12-1899 I can just subtract todays date, in days, from the assumed zero date and get the number of days.... maybe there is still light at the end of the tunel
By the way, fidoboy, I have been able to read the AMC binary file. I always read byte arrays. When reading integer you have to read 4 bytes at a time and convert those 4 bytes into a single integer value. The integer format is little endian. When reading strings you just need to read the number of byte that form the string and every array position will hold the value of the ASCII character it corresponds to. I haven't got to the picture nor the boolean values yet but I think they'll not be a problem.
I'll try to make my spike solution more developer friendly and I'll post the solution. If I can I'll make it tomorrow.
Thanks
Here you have a simple application that will open a ACM file and read some info on it, it's just a spike solution, or a prof of concept if you prefer.
It is written in Java an will output the info to the console, so you must use it from the console, and display a JDialog with an image.
Jar file, just run "java -jar K_Movie_Cataloger_Spikes.jar": http://www.sergio-lopes.org/projectfile ... Spikes.jar
My acm file, must be at "c:\": http://www.sergio-lopes.org/projectfile ... /Anime.amc
The important class: http://www.sergio-lopes.org/projectfile ... eader.java
The Main class, not important: http://www.sergio-lopes.org/projectfile ... /Main.java
The image i used, not necessary, but if you want to compare with the one on the catalog file: http://www.sergio-lopes.org/projectfile ... enshin.jpg
I have yet another question
What is the field "Export: Boolean;" for? And where is the option on the Ant Movie Catalog that changes it from false to true?
It is written in Java an will output the info to the console, so you must use it from the console, and display a JDialog with an image.
Jar file, just run "java -jar K_Movie_Cataloger_Spikes.jar": http://www.sergio-lopes.org/projectfile ... Spikes.jar
My acm file, must be at "c:\": http://www.sergio-lopes.org/projectfile ... /Anime.amc
The important class: http://www.sergio-lopes.org/projectfile ... eader.java
The Main class, not important: http://www.sergio-lopes.org/projectfile ... /Main.java
The image i used, not necessary, but if you want to compare with the one on the catalog file: http://www.sergio-lopes.org/projectfile ... enshin.jpg
I have yet another question
What is the field "Export: Boolean;" for? And where is the option on the Ant Movie Catalog that changes it from false to true?
It is the "Checked" field that I forgot to rename in the help file It corresponds to the checkbox on the left of the title in the movie list. In earlier versions that checkbox was added to allow users to specify which movies had to be included in the HTML export, but later it was extended to other purposes, as it can be used for many things actually.