Old 01-03-2015, 11:34 AM   #1
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 6,202
Default EEL: Create subtitles from regions names

Hi !

I wanted to share with you an EEL script I wrote, before it's "official" release on my website (I need to write some other scripts before that), so you can test it and tell me if you find any way to improve the code.

Link :
REAPER-EEL-Scripts/X-Raym_Create subtitles from regions names.eel at master · X-Raym/REAPER-EEL-Scripts

Purpose :
Creating subtitles from regions names. No need of Macros Software anymore ! (see A Detailed Guide to Subtitling with Reaper / ExtremRaym for my original worklow. This article will be updated soon !)

Requirements :
Reaper 5 (alpha) and SWS (last version).

Video demo :
createSubtitlesFromRegionsNames

Known limitations :
You have to do some code editing in your .rpp file because :
  • There is actually no way to write directly in the <EXTENSIONS part of the .rpp file
  • There is now way to write <EXTSTATE datas formated as needed for subtitles.

What do you think of that ?
Do you have any idea about how to improve it ?

Note :
There is a known issue with saved subtitles, but it should be fixed for the next SWS pre-release.
Bug: New lines created in subtitles when saving the project · Issue #686 · Jeff0S/sws

Cheers !


(thanks to planetnine and spk77, your code in "name" variable in RPR_EnumProjectMarkers3 was my reference !)

Console Version, v4 friendly (from heda's idea):
X-Raym_Create subtitles from regions and markers names - console version.eel

Last edited by X-Raym; 02-18-2015 at 03:20 AM.
X-Raym is offline   Reply With Quote
Old 02-16-2015, 12:02 PM   #2
heda
Human being with feelings
 
heda's Avatar
 
Join Date: Jun 2012
Location: Spain
Posts: 5,598
Default

Can't get this one working.

there is a msg(#name) line that should be msg_s(#name)

but then... running the script with some named regions to test.

error \X-Raym_Create subtitles from regions names.eel:47: 'loop' undefined: 'loop (EnumProjectMarkers(i, is_region, pos, rgn_end, #name'

and I don't see the need to replace the quotes as you indicate in the video.

using v5 pre12
heda is offline   Reply With Quote
Old 02-16-2015, 12:15 PM   #3
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 6,202
Default

@heda

Quote:
there is a msg(#name) line that should be msg_s(#name
Old custom console debug functions. Corrected!

Quote:
error \X-Raym_Create subtitles from regions names.eel:47: 'loop' undefined: 'loop (EnumProjectMarkers(i, is_region, pos, rgn_end, #name'
Convert to while loop. Now working!

Quote:
and I don't see the need to replace the quotes as you indicate in the video.
Arf, pre-release changes...
well that's now easier to convert to subtitles, just need to replace |space by |, and extsate by extensions !

Thanks for the report !

(edit : the script has been updated)
X-Raym is offline   Reply With Quote
Old 02-16-2015, 12:28 PM   #4
heda
Human being with feelings
 
heda's Avatar
 
Join Date: Jun 2012
Location: Spain
Posts: 5,598
Default

wow.. you are fast... realtime bug killer haha

I wonder if we should report the space thing after the | being introduced by SetProjExtState
or if SWS subtitles should use the space if the v5 EXTSTATE format is going to have the space. but it would break compatibility.
I also wonder why the | is needed. but that must be some low level reason that I don't see.
heda is offline   Reply With Quote
Old 02-16-2015, 12:34 PM   #5
heda
Human being with feelings
 
heda's Avatar
 
Join Date: Jun 2012
Location: Spain
Posts: 5,598
Default

Can I do a realtime feature request? hehe

compatible with v4, not using SetProjExtState. just output the lines to the Console...without the space after |. There we can copy easily and paste them inside <EXTENSIONS> in the project.
heda is offline   Reply With Quote
Old 02-16-2015, 12:40 PM   #6
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 6,202
Default

@heda
Yep, I was scripting and writing the forum thread for the script... so I was into it

Your solution is in fact quite good. Perhaps even better than the actual solution !
Did you try it on a full lenght movie ? display infos on the console can be very slow.
X-Raym is offline   Reply With Quote
Old 02-17-2015, 12:29 AM   #7
heda
Human being with feelings
 
heda's Avatar
 
Join Date: Jun 2012
Location: Spain
Posts: 5,598
Default

Quote:
Originally Posted by X-Raym View Post
@heda
Yep, I was scripting and writing the forum thread for the script... so I was into it

Your solution is in fact quite good. Perhaps even better than the actual solution !
Did you try it on a full lenght movie ? display infos on the console can be very slow.
I haven't tested, but I don't think it will be slower than having to replace the space and cutting and pasting, etc...
I didn't code it.. I just gave you the idea.
heda is offline   Reply With Quote
Old 02-17-2015, 09:13 AM   #8
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 6,202
Default

so let me bring life to it!



Download link:
X-Raym_Create subtitles from regions names - console version.eel

EDIT: I just add a more correct indentation. It was a very nice idea !!
X-Raym is offline   Reply With Quote
Old 02-17-2015, 06:17 PM   #9
heda
Human being with feelings
 
heda's Avatar
 
Join Date: Jun 2012
Location: Spain
Posts: 5,598
Default

Thank you
there is a small bug
regions start at 1073741824 not 1073741825
and markers start at 0
it could be easilly compatible with marker subtitles too
and you should include the marker id instead of the i of the loop. so here is the fix, replace the sub_id line with this:
Code:
is_region == 1 ? (
      sub_id = 1073741824 + markrgn_index_number; // SWS Region Subtitles ID start at 1073741824
    ) : (
      sub_id = markrgn_index_number; // SWS markers Subtitles ID start at 0
    );
this script should be integrated in SWS code to allow SWS to write the subtitles directly. Contact Jeffos
heda is offline   Reply With Quote
Old 02-17-2015, 06:50 PM   #10
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 6,202
Default

@heda
Weird, I'm pretty sure it start with 1073741825... Did you try to create a region subtitles in an empty project and check the .rpp in a code editor ?
But I may be wrong

I didn't support marker subtitles because I don't like it. Subtitles are determine by in and out time code, in all subtitles format. So I don't understand the point of markers subtitles. That's why I made nothing for them
Conditions for regions: it was one of my first script. I missed it, but of course, that's better :P

Thanks for the fix, it is now integrated!

SWS are written in C++, I already write for it (enhancement of subtitles importation). It was very hard

I updated the script with your bug fix, and will re-test it asap.

Thanks for all :P
X-Raym is offline   Reply With Quote
Old 02-17-2015, 07:24 PM   #11
heda
Human being with feelings
 
heda's Avatar
 
Join Date: Jun 2012
Location: Spain
Posts: 5,598
Default

Quote:
Originally Posted by X-Raym View Post
@heda
Weird, I'm pretty sure it start with 1073741825... Did you try to create a region subtitles in an empty project and check the .rpp in a code editor ?
But I may be wrong

I didn't support marker subtitles because I don't like it. Subtitles are determine by in and out time code, in all subtitles format. So I don't understand the point of markers subtitles. That's why I made nothing for them
Conditions for regions: it was one of my first script. I missed it, but of course, that's better :P

Thanks for the fix, it is now integrated!

SWS are written in C++, I already write for it (enhancement of subtitles importation). It was very hard

I updated the script with your bug fix, and will re-test it asap.

Thanks for all :P
id can be 0. When you create a region it will start with id 1.. but it can be 0.. That's why. Try putting 100 to an id manually.. and save. (guess why I am interested in ids starting at 100 or whatever you will see SWS creates S&M SUBTITLE 1073741924
1073741924-100 = 1073741824

yes regions are better for subtitles, and I want my script also to work with regions, but I wanted first to make it work with markers
heda is offline   Reply With Quote
Old 02-17-2015, 07:40 PM   #12
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 6,202
Default

Ok, so if you test it, that should be ok
Do you really use subtitles markers ? How are they useful ?
X-Raym is offline   Reply With Quote
Old 02-17-2015, 07:51 PM   #13
heda
Human being with feelings
 
heda's Avatar
 
Join Date: Jun 2012
Location: Spain
Posts: 5,598
Default

Quote:
Originally Posted by X-Raym View Post
Ok, so if you test it, that should be ok
Do you really use subtitles markers ? How are they useful ?
I like them because they don't overlap with other regions that I can have in REAPER that are not subtitles. to specify the end of a sentence.. just add another marker with empty text. Many times region subtitles are adjacent. But you are right that the right thing to use is regions. Since REAPER cannot display overlapped regions I can use markers for subtitles. I use it for lyrics of a song, while I use regions for parts of a song. They are useful to copy and move parts.
heda is offline   Reply With Quote
Old 02-18-2015, 03:18 AM   #14
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 6,202
Default Create subtitles from regions and markers names - console version

Well, I see!
Shouldn't be hard to implement.

I did the test:
here is what your fix display in console:
Code:
    <S&M_SUBTITLE 1073741825
      |Region
    >
    <S&M_SUBTITLE 1073741826
      |Region
    >
    <S&M_SUBTITLE 1
      |bonjour
    >
    <S&M_SUBTITLE 1073741827
      |Region3
    >
    <S&M_SUBTITLE 1073741829
      |Region 5
    >
    <S&M_SUBTITLE 1073741828
      |Region4
    >
and here is what SWS save in file:
Code:
    <S&M_SUBTITLE 1073741825
      |Region
    >
    <S&M_SUBTITLE 1073741826
      |Region
    >
    <S&M_SUBTITLE 1073741827
      |Region3
    >
    <S&M_SUBTITLE 1073741829
      |Region 5
    >
    <S&M_SUBTITLE 1073741828
      |Region4
    >
    <S&M_SUBTITLE 1
      |bonjour
    >
I just split the loop in two parts (region and markers) and now it is corrected :P

I also renamed the action, as it does something new.

here is the download link:
X-Raym_Create subtitles from regions and markers names - console version.eel

EDIT:
It would be nice to have the instructions in GFX, just as in your Markers script, so we can just CTRL+A the log in the console! How would you do? I'm stilltill a GFX newbie.

Last edited by X-Raym; 02-18-2015 at 05:54 AM.
X-Raym is offline   Reply With Quote
Old 02-18-2015, 09:29 AM   #15
heda
Human being with feelings
 
heda's Avatar
 
Join Date: Jun 2012
Location: Spain
Posts: 5,598
Default

edit: I don't know if splitting in two parts is needed. But indeed it is more tidy

I learnt a bit of the gfx stuff from some spk77's scripts

some basic UI:
Code:
function opengui() 
(

// text in the UI
	gfx_x = 20;
	gfx_y = 10;
	gfx_drawstr("==== INSTRUCTIONS ====");
	
	gfx_x = 20;
	gfx_y = 20;
	gfx_drawstr("line 2");
	
	

	//------- 
	char = gfx_getchar();
	// ctrl+lmb to Undo
	char == 26 ? (
	Main_OnCommand(40029, 0); // undo
	);
	// Esc to exit
	char == 27 ? (
	gfx_quit();
	);
	char >= 0 ? (					// if window is visible
	defer("opengui();");		// execute loop constantly
	);	
	gfx_update();
	
);


gfx_init("Create subtitles from regions and markers names", 420,200); // open window 
opengui();
create_subtitles_from_regions_names();

Last edited by heda; 02-18-2015 at 09:42 AM.
heda is offline   Reply With Quote
Old 02-18-2015, 10:01 AM   #16
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 6,202
Default

Many thanks for this!!
It open great opportunities for me!!



It is so awesome

Script updated and working more nicely than ever.
X-Raym is offline   Reply With Quote
Old 02-18-2015, 10:08 AM   #17
heda
Human being with feelings
 
heda's Avatar
 
Join Date: Jun 2012
Location: Spain
Posts: 5,598
Default

I'm happy we all learn together

edit: LOL I've seen your code comment that I rock.. hahah thanks
I've just noticed that we don't need to set gfx_x all the time to the same value. copypasting issues.

I tried to open github account but HeDa is taken by someone. I can't rename my reaper forum name to HeDa with the capital letters or to any other name. anyway.. I'll think a name for github. Ok I'm back to mixing session :P
heda is offline   Reply With Quote
Old 02-18-2015, 10:19 AM   #18
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 6,202
Default

@heda
that's what I call a community! :P

Just tried without all GFX and it was wrong so I keep it this way!

Mixing session? Oh yeah, that!

(I really like how the github updated make the upload process easier. Just have to name the commit, press synch and hop it is updated, without open any browser. And I can synch my files on all my computers. You wille like it.)
X-Raym is offline   Reply With Quote
Old 02-18-2015, 04:05 PM   #19
heda
Human being with feelings
 
heda's Avatar
 
Join Date: Jun 2012
Location: Spain
Posts: 5,598
Default

oh I see.. it's true. after gfx_drawstr the gfx_x points to the end of that created text. so we have to define gfx_x and gfx_y again

a small function for cleaner code:
Code:
function gfx_drawstr_xy(x,y,string) (
	gfx_x = x;
	gfx_y = y;
	gfx_drawstr(string);
);
heda is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 02:06 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.