Setting start frame: coder needed to tweak the source???

Discuss Papagayo issues here

Moderators: Fahim, Distinct Sun, Víctor Paredes, erey, Belgarath, slowtiger

Post Reply
Posts: 244
Joined: Tue Dec 23, 2008 8:15 pm
Location: New Zealand

Setting start frame: coder needed to tweak the source???

Post by arfa » Wed Jan 21, 2009 1:11 pm

I have been only working with Papagayo for a short time but have come up against what seems an icky obstacle...

The scenario:
Several short sound clips over a several hundred frames.
Load each clip into Pgo - no problem exporting voice.
But, each .dat file starts at frame 1

When each .dat file is loaded it overwrites whatever is there.

HOW TO either:
copy/paste frames to?? another switch file or, by far the better solution,
set a start frame for each phoneme set. This requires tweaking the source code of Papagayo.

It seems like it would be a problem for you all. What other solutions can you suggest?

I have written a small PHP script that opens each .dat file and incrementally adds to the frame numbers, sets a gap between each set and then outputs a single file. It works fine enough but requires a local server (or online setup). I could put this up for download if anyone is interested.

Being able to set the start frame directly in PGO would be much more elegant.

thanks - arfa
User avatar
Posts: 7216
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma

Post by synthsin75 » Wed Jan 21, 2009 1:36 pm

Wouldn't you still need to pad the sound file so that it starts at the right place on export? Seems you could just do that before importing it to Papagayo.

Let me know if I'm missing something here. :wink:
User avatar
Posts: 1646
Joined: Fri Nov 02, 2007 5:29 pm
Location: Sunny Florida

Post by mkelley » Wed Jan 21, 2009 2:27 pm

Most (all) folks who use PG do it with a single sound clip -- in the "icky" example you mention the far easier solution is to use any decent sound editor to combine all the clips before PG import.

In point of fact this is what you'll have to do at some point anyway -- which is to say either you will edit the sound together to use in AS as a single soundtrack (assuming export from AS directly into an animation) or combining the sound files in your video editor when you output from AS as single frames. But it's going to be *very* difficult to work with such separate clips until and unless you combine them.

I can't think of a single scenerio where you would want to use such separate clips as you are mentioning -- but I'm glad you've generated a solution for your own workflow.
User avatar
Posts: 6964
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern » Wed Jan 21, 2009 9:03 pm

I had to do something similar and used jEdit (open source text editor) and a custom regex snippet to "add" a specified amount to each key frame in the dat file. Very similar to your PHP solution.

For instance, if one dat file needs to start at frame 40, I just do a search and replace and add 40 to every key frame in the dat file. I then just simply copied and pasted by hand each dat file into one file.

In another much worse case scenario I had done the lip sync in PGO at the wrong FPS. I just did the same thing with jEdit but instead of "adding" a number I multiplied the key frame times a percentage to make it match the AS file. I had a few dozen dat files to process and this went very quickly.

Stitching the sound files together or padding is a better solution... however there are issues with the length of the sound file in PGO and performance.

Why can't you use your PHP solution? It sounds great. Or why not post it online and have some sort of "upload" feature that spits out a text file in a browser window? It would never have to actually write to the drive and you could just save the window as text/dat.

p.s. I have my own local server and would like to see the PHP code.

Posts: 244
Joined: Tue Dec 23, 2008 8:15 pm
Location: New Zealand

yes yes

Post by arfa » Thu Jan 22, 2009 2:38 pm

Great to have such quick response.
I am new to AS and did the usual software comparisons - Ahhhh, Toon Boom, etc.. The lively forum was a real factor in my choice. Great work all.

So, yes...

Padding each sound file would be one solution.

>> mkelley
Combining the clips would also work - better.
But, should I change my mind and want to alter just one clip... I would then have to go back and recombine etc.

>> heyvern
|| add 40 to every key frame in the dat file
Yes, this is what I faced. Very tedious.
|| some sort of "upload" feature
Yes, I had thought of this but - oh how the hours of the day do disappear when I sit with the computer. Part of my hesitation is around how widely this would be used.

Here is my php - with lots of comments. Other than a 'well done' message there is no GUI
// Edit this in a text editor - not a word processor
/* My problem arose when using Papagayo to render several voice sound clips.
The start keyframe for each voice-export (*.dat) file was 1.
How to get each file's data into one consequtive string of keyframes in Anime Studio?
This script takes the output from several Papagayo voice-export (*.dat) files
and renumbers the keyframes for each subsequent file-set.
It compiles all the renumbered sets into one file.

The files produced by my copy of Papagayo have:
MohoSwitch1 on the first line
then the keyframes and switch-layer names on separate lines
then one blank line at the end.
This script relies on your files using this format.*/

// It is generally easier, but not essential, to have all files in the same folder.


// 1) The path and name of your compiled, output file.
// This is the file you will use.
$end_file = 'final_papagayo.dat';

// 2) A list of all Papagayo files to be compiled.
// List them in the required order.
// Be sure to enclose each filename within '' and include the .dat extension
$file_names = array('1-new-lipsB.dat','2-justResponse.dat','3-lowFat.dat','4-highFibre.dat','5-good4U.dat','6-finCrunch.dat');

// 3) A number (of keyframes).
// This leaves a visible gap between each file-set of keyframes
$gap = '10';

/* Once the compiled, source data file ($end_file) has been loaded, into Anime Studio,
for the relevant switch file
it is then a matter of selecting each group-of-keyframes, for each sound file, and
dragging the group to the appropriate position.
In effect, closing up $gap */

// _^:^__^:^__^:^__^:^__^:^__^:^__^:^__^:^__^:^_
// NO EDITING below here should be required....
$increment = '0'; // add nothing on the first round
$final = "MohoSwitch1\n"; // MUST start the first line with this

for ($i=0; $i<count($file_names); $i++) { // read each file
$lines = file($file_names[$i]); // an array for each file
$file_num = count($lines); // that has 'x' number of lines

$new_lines = '';
for ($t=1; $t<$file_num; $t++) { // read each line
$ending = strstr($lines[$t],' '); // the switch info
$lines[$t] = str_replace($ending,'',$lines[$t]); // the keyframe number
$new_number = $lines[$t] + $increment;

$new_lines .= "$new_number$ending"; // (re)build the renumbered file

} // end loop lines

$increment = $new_number + $gap; // add that gap
$final .= $new_lines; // build the final data
} // end loop files

$fp = fopen( $end_file, "w" ); // open (or create) output file for writing
if (flock($fp, LOCK_EX)) { fwrite($fp, $final); flock($fp, LOCK_UN);}
fclose( $fp );

echo "<center><BR><BR>Your working file - <b><u>$end_file</u></b> - has been compiled.<P>
nice one.<P>nice";


Let me know how this looks/works. It is not such a major thing to write a basic interface. Uploading files is always a bit tricky from a security point of view.

cheers - arfa
User avatar
Posts: 6964
Joined: Fri Sep 02, 2005 4:49 am

Re: yes yes

Post by heyvern » Fri Jan 23, 2009 12:09 am

arfa wrote: >> mkelley
Combining the clips would also work - better.
But, should I change my mind and want to alter just one clip... I would then have to go back and recombine etc.
Changing the sound file or changing a clip is always going to require revisions. No way around that even if you could drop the dat files in anywhere you want in AS. Even if AS had multiple layered sound files you would still need to move things around. The key to avoid that would be to do a really good, tight animatic. Find all the timing and composition issues ahead of time so you don't have to make massive edits later on.

Try doing the dialog without any lip synch. Make sure you like the flow of the action before worrying about dropping in your dat lip synch. Get it right then put together your sound/dat files.

p.s. Thanks for the code. I will take a look at it when I get a chance. I have the same issue with time flying away while in front of the computer. ;)

Posts: 244
Joined: Tue Dec 23, 2008 8:15 pm
Location: New Zealand


Post by arfa » Fri Jan 23, 2009 1:06 pm

Revision is always the name of the game. I like to think of it as evolving, inspired creativity :)

The php script is a workable work-around but, the real solution, in my mind, lies in having a wee text box in Papagayo - similar to the fps box - where you can specify the start frame for the voice clip. Some one who codes in C++ or whatever. The source code is available.

Perhaps I could have been clearer about my work process [as far as it has developed with AS so far].
I have all the sound clips separate.
Build the pgo for the voice bits and sync. them
Several .mov scenes.
Put all the bits together in my AV editor.
The separate sound clips means I get extra tweakability in the AV as well.

Sound like i know what I'm doing? Whoa.! I have barely got a working animation together. I is really a big time beginner with AS; a big fan thus far.
Posts: 17
Joined: Fri Jan 23, 2009 1:41 am

Post by JNandC » Sun Jan 25, 2009 6:47 am

What about not changing the .dat file or papagayo. But how AS inputs the info. Even if you can specify the start frame in Papagayo, say to start at frame 20, wouldnt you lose everything before frame 20 and after the end of the clip?

would it be better if there was a script that inputted the .dat file at the keyframe where you marked at? Kinda like copying actions. So you can still save different bits of papagayo .dat files, and then input them in through a script. I'm not a scripter, or have even looked at it, so let me know if this is possible.

Speaking of actions, Maybe as a workaround you can input the .dat files like usual but intead of using the mainline, you save it as a action. Then you can insert that action where ever you want. I'll have to try that out later.
Posts: 17
Joined: Fri Jan 23, 2009 1:41 am

Post by JNandC » Sun Jan 25, 2009 6:51 am

The saving the sound bits as actions instead of the main timelines works fine. You can input the actions anywhere u want.
Posts: 244
Joined: Tue Dec 23, 2008 8:15 pm
Location: New Zealand

mixing it

Post by arfa » Mon Jan 26, 2009 2:44 pm

>> wouldnt you lose everything before frame 20
Each *.dat would still have to be cut and pasted into a master .dat file.

I have worked very little with actions but, no time like when there is a need to get into it. My PHP script works fine (for me) but it is always nice to have a 'normal' way of doing things.

off - and into action

> arfa
Posts: 244
Joined: Tue Dec 23, 2008 8:15 pm
Location: New Zealand

just great

Post by arfa » Tue Jan 27, 2009 6:22 pm

yes, that works just fine using actions.
The only limitation, and minor at that, is editing the action - ie. switch keys - the timeline is not in synch with the animation. I guess I should (before it gets to be an action) have it tuned to the sound file. Then it is just a matter of sliding the action - on the main timeline - to start at the right place relative to the animation.

I am still very new to the program overall so will try both as I develop a few movies. thanks.

cheers - arfa
Posts: 244
Joined: Tue Dec 23, 2008 8:15 pm
Location: New Zealand

script update

Post by arfa » Sat Jan 31, 2009 1:10 pm

I have used my PHP script a few more times and, while still undecided actions v's PHP, I have made a few improvements to the script.

A bit of a user interface with the option to write to screen or file.
Here is a simple online example:

I posted a link previously but can't locate it.
Here is the latest download... ... pagayo.php

I hope this might be of some use.
Post Reply