• Welcome to OS2World OLD-STATIC-BACKUP Forum.
 

News:

This is an old OS2World backup forum for reference only. IT IS READ ONLY!!!

If you need help with OS/2 - eComStation visit http://www.os2world.com/forum

Main Menu

CE2mp3

Started by cyber, 2009.06.12, 12:05:45

Previous topic - Next topic

CDRWSel

#30
About ffmpeg,
After a few more test, adding 2> \pipename should be ok to get verbose data into the pipe
RD       

cyber

Quote from: CDRWSel on 2009.06.24, 18:02:44
About ffmpeg, After a few more test, adding 2> \pipename should be ok to get verbose data into the pipe
RD       

Could You give more info, please, how exactly to start ffmpeg with 2> \pipename, and how to catch this in Rexx ?

Here is newest release, please do intensive tests on GUI version and report any problem.
New is that now both versions will overwrite target mp3 if they exist without asking, and with GUI version now is possible to cancel by presing ESC at any window (text mode can cancel using [CTRL+Break] at any time).

jep

Hi,

I've added 2 functions to rxtnsion.dll that I test to see if I can get the desired behaviour to redirect output from other text mode applications.
I have to write some more code but have had a bit much to do at work, but can hopefully look at it in the comming week.

My initial test leave me pussled as the output look like garbage, but it'll hopefully turn out right some time in the future.

//Jan-Erik

RobertM

jep,

Could it be because certain programs send ascii character positioning and other ansi codes with it? I had that problem with a parser I wrote for curl or wget (forget which), and had to parse out those codes. I found whenever there was a cursor move (reposition for text output for instance), or a color change, that there was an ansii sequence appended at that char output location.

Rob


|
|
Kirk's 5 Year Mission Continues at:
Star Trek New Voyages
|
|


CDRWSel

Quote from: cyber on 2009.06.25, 14:52:57
Quote from: CDRWSel on 2009.06.24, 18:02:44
About ffmpeg, After a few more test, adding 2> \pipename should be ok to get verbose data into the pipe
RD       

Could You give more info, please, how exactly to start ffmpeg with 2> \pipename, and how to catch this in Rexx ?

Here is newest release, please do intensive tests on GUI version and report any problem.
New is that now both versions will overwrite target mp3 if they exist without asking, and with GUI version now is possible to cancel by presing ESC at any window (text mode can cancel using [CTRL+Break] at any time).


First get RXU dll from hobbes:
http://hobbes.nmsu.edu/download/pub/os2/dev/rexx/rxu1a.zip

May be something like:

/* load RXU functions for PIPE process */
If rxfuncquery('rxuinit') then do
Call RxFuncAdd 'rxuinit','rxu','rxuinit'
Call rxuinit
End
/* ---------------------------------------------- */
pipename = '\pipe\ffmpeg'
openmode = 'WIN'
pipemode = 'WTR'
instance_count = '1'
outbuf = '4096'
inbuf = '4096'
timeout = '-1'
readbufsize = '4096'
EOFCR=x2c("0D0A")
EOF = x2c(4)
EOF1=x2c("0D")
/* -- */
Ddosrc = rxcreatenpipe('hpipe',pipename,openmode,pipemode,instance_count,
    ,outbuf,inbuf,timeout)
If Ddosrc \= 0 then say 'RxCreateNPipe failed with rc =' Ddosrc
Ddosrc = rxconnectnpipe(hpipe)
Ddosrc = RxDosRead( 'data', hpipe, readbufsize )
Do while word(Ddosrc,1) = 0 & word(Ddosrc,2) > 0
     /* may be you'll have to translate every EOF and EOF1 into CDTEST with something like
         If (pos(CRTEST, data, 3) > 0)|(pos(EOF, data, 3) > 0)|(pos(EOF1, data, 3) > 0)  then do
         pipe_line_in=translate(data,EOFCR,EOF)
         pipe_line_in=translate(data,EOFCR,EOF1)
         ... add your code to pickup data from the messages sent through the pipe ....     
     */
     Ddosrc = RxDosRead( 'data', hpipe, readbufsize )
End
...
...
--------------------------------------------------

Start your ffmpeg after starting your rexx programm which opens the pipe and add as last ffmpeg argument  2> \pipe\ffmpeg
You should get all messages issued by ffmpeg into the pipe. 

jep

Hi,

CDRWSel has provided you with a very powerful example...

In the mean time, I wrote a couple of functions to do about the same thing, please see attached file with example and source code.
The exemple contains the executable "loop.exe" that run and just write a number (0 to 9999) to the screen.

Here's the C/C++ code for the rexx dll while we're at it...
/**
* function: rxExecPrgm( app_name, <parameters>, <environment> )
*
* This function returns an empty string if it couldn't start the application.
*/
APIRET APIENTRY __export rxExecPrgm( CHAR *name, ULONG numargs, RXSTRING  args[], char* queuename, RXSTRING *retstr )
{

   if( numargs < 1 )
      return INVALID_ROUTINE;

   var appName( args[0].strptr );
   var params( ( numargs > 1 ) ? args[1].strptr : "" );
   var appEnv( ( numargs > 2 ) ? args[2].strptr : "" );

    HPIPE hpW;
    CHAR szFailName[256];

    HFILE hfSave = -1, hfNew = HF_STDOUT;

    DosDupHandle( HF_STDOUT, &hfSave ); /* Saves standard output handle      */

    DosCreatePipe( &Output.hpR, &hpW, PIPESIZE ); /* Creates pipe                      */

    DosDupHandle( hpW, &hfNew ); /* Duplicates standard output handle */

    DosExecPgm( szFailName, sizeof( szFailName ), EXEC_ASYNCRESULT, params, appEnv, &Output.resCode, appName );  /* Starts child process      */

    DosClose( hpW );                /* Closes write handle to ensure     */
                                  /* Notification at child termination */
    DosDupHandle( hfSave, &hfNew );     /* Brings stdout back                */

   appName.cpy( "pid=" ).cat( Output.resCode.codeTerminate ).set( retstr );

   Output.ulRead = 1;

   return VALID_ROUTINE;
}

/**
* function: rxPrgmOut( <none> )
*
* This function returns an empty string if it couldn't start the application.
*/
APIRET APIENTRY __export rxPrgmOut( CHAR *name, ULONG numargs, RXSTRING  args[], char* queuename, RXSTRING *retstr )
{
   char achBuf[1024];
   PID pidChild = 0;
   var tmpBuf;

   if ( Output.ulRead )
      DosRead( Output.hpR, achBuf, sizeof( achBuf ), &Output.ulRead );

   if ( Output.ulRead ) {
      tmpBuf.cpy( Output.buffer ).cat( achBuf, Output.ulRead );
      Output.buffer.cpy( tmpBuf.splitAtLast( '\n', true ) );   //Remove delimiter
   } else {
      DosWaitChild( DCWA_PROCESS,    /* Look at only the process specified */
                 DCWW_WAIT,       /* Wait until a child terminates      */
                 &Output.resCode,        /* Termination codes returned         */
                 &pidChild,       /* pid of terminating process         */
                 Output.resCode.codeTerminate );   /* Process (pid) to look at */

      tmpBuf.cpy( "rc=" ).cat( (int) Output.resCode.codeTerminate );
   }

   tmpBuf.set( retstr );

   return VALID_ROUTINE;
}


//Jan-Erik

cyber

After some delay, on the code again.  8)

How to strip tab character from text string using Rexx ?
    26 +++     tagpart = STRIP(tagpart, '?');
REX0040: Error 40 running C:\Tools\M600\ce2mp3\CE2MP3tag.cmd, line 26:
Incorrect call to routine

Using spaces in tagpart = STRIP(tagpart, '        '); does not help in finding this character.

RobertM

#37
Quote from: cyber on 2009.07.06, 17:07:28
After some delay, on the code again.  8)

How to strip tab character from text string using Rexx ?
    26 +++     tagpart = STRIP(tagpart, '?');
REX0040: Error 40 running C:\Tools\M600\ce2mp3\CE2MP3tag.cmd, line 26:
Incorrect call to routine

Using spaces in tagpart = STRIP(tagpart, '        '); does not help in finding this character.

All you need to do is look for it's ASCII character code. That works for Carriage Returns and Line Breaks as well.

TAB= 9

Thus, look for D2C(9) instead of spaces or such.

tagpart = STRIP(tagpart, d2C(9))

And of course, this works for any character not representable in typed code (such as any below 32)

Rob


|
|
Kirk's 5 Year Mission Continues at:
Star Trek New Voyages
|
|


CDRWSel

Hi !
From my previous update, you'll have EOF for End Of File x'0D' end CR x'0A' for Carriage return
To remove these special characters, use the translate instruction
eof=x2c('0D')
tagpart=translate(tagpart,'',eof)
If you have more than one chars to 'translate', just append it after first chars to be translated as follow
cr=x2c('0A')
eof=x2c('0D')
tagpart=translate(tagpart,'',eof||cr)

Remy

CDRWSel

#39
Hi !
Here is my updated "progress bar" used with cdrwsel but this version is usable separatly and supports incoming pipe datas from 'DVDDAO', 'FFMPEG'
How to use it !
start it as a separate thread using a '@det ' command under your program and give a process type parameter.
e.g. '@start cdrwbar.exe dvddao'  for dvddao
e.g. '@start cdrwbar.exe ffmpeg' for 1 ffmpeg (video) process and close
       or
       '@start cdrwbar.exe ffmpeg5' for 5 ffmpeg (video) processes and close after the 5th process
       (it will not close until 5th ffmpeg is processed)
       This is usefull if you run ffmpeg in 2 pass mode (use ffmpeg2)
e.g '@start cdrwbar.exe affmpeg'  or replace affmpeg by affmpegX (X = any number) - for Audio 
       You can follow progress of each started ffmpeg process through one opened progress bar (be carrefull to run as many processes as you specified into the parameter)
.
Add at end of your ffmpeg command line the corresponding pipe option:
  2>/pipe/dvddao    (for dvddao)
  2>/pipe/ffmpeg     (for any ffmpeg type)

Cheers/2
Remy

e.g.
/* rexx example script */
/* ------------------------------------------------------------------------------------------------------- */
/* Start cdrwbar with the number of tracks to convert - % + time + progress Indicator */
/* ------------------------------------------------------------------------------------------------------- */
'@start cdrwbar.exe affmpeg3'
/* ------------------------------------------------------------------------------------------------------- */
/* May be you add here a process to check cdrwbar PID is available before continue */
/* ------------------------------------------------------------------------------------------------------- */
Call syssleep 3  /* wait for full initialized cdrwbar + open pipe */
'ffmpeg -y -i C:\MUSIC\my_track1.ogg C:\MP3\my_track1.mp3 2>/pipe/ffmpeg'
say rc
'ffmpeg -y -i C:\MUSIC\my_track2.ogg C:\MP3\my_track2.mp3 2>/pipe/ffmpeg'
say rc
'ffmpeg -y -i C:\MUSIC\my_track3.ogg C:\MP3\my_track3.mp3 2>/pipe/ffmpeg'
say rc
return


                 
         

cyber

#40
To: CDRWSel

Progress bar does not work in my enviroment:
SYNTAX ERROR: Routine not found in:
Ddosrc = rxcreatenpipe('hpipe',pipename, openmode,pipemode,instance_count,
Added later: I wonder... did I put right dll in path or not... need to check this at home.


UPDATED:

[C:\TOOLS\M600\ce2mp3-cdrw]ffmpeg.exe -i Hydrate-Kenny_Beltrey.ogg  -acodec libm
p3lame -ac 2 -ar 44100 -ab 64k -vol 256 "Hydrate-Kenny_Beltrey.mp3"  2>/pipe/ffm
peg
SYS0003: The system cannot find the path specified.
conversion complete

It still have trouble. All exe, dll, cmd and ogg files in same path. Some references to path in cdrwbar.exe ?


To: RobertM

Thanks

Where I can find those character codes, help.exe is sometime useless;

tagstr=d2C(9)
tagpart  = LINEIN("tag.nfo")
tagpart  = strip( tagpart , L, tagstr) 


CDRWSel

#41
Hi cyber !
You must have the RXU.DLL under a dllpath. I suggest you to copy the RXU.DLL under [boot_drive]:\ecs\dll or under [boot_drive]:\os2\dll 
At start of cdrwbar, I load both dlls :
/* load general REXXUTIL functions */
If rxfuncquery('SysLoadFuncs') then do
call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
call SysLoadFuncs
End
/* load RXU functions for PIPE process */
If rxfuncquery('rxuinit') then do
Call RxFuncAdd 'rxuinit','rxu','rxuinit'
Call rxuinit
End

According the error you have, rxu dll isn't loaded or it fails !
Verify you have Rexxutl.dll too and do a try after a copy of dll's into dll path as previous writen.

As soon the pipe isn't created and opened by cdrwbar, the error
SYS0003: The system cannot find the path specified.
you have is correct because /pipe/ffmpeg doens't exist

Cheers/2
Remy
 
PS: here are 2 screencopy about cdrwbar result on video or audio tracks.

cyber

Quote from: CDRWSel on 2009.07.08, 21:39:57
You must have the RXU.DLL under a dllpath. I suggest you to copy the RXU.DLL under [boot_drive]:\ecs\dll or under [boot_drive]:\os2\dll 

Looks like I've been too tired.  First I was try with wrong dll, and then on wrong place.  :'(

CDRWSel

#43
Hi!
You are not alone, I'm probably tied too.
Here is an updated build.
* Corrected seconds display to have it right align with padded '0' (now, 1.00s is 01.00s)
* I just realized that I left a duplicate var for the first arg which made cdrwbar start in dvddao mode only   ::)

With good dll, it should be ok now.
Remy       

PS: This wiki page may be usefull for control characters translation  ;)
       http://fr.wikipedia.org/wiki/Fin_de_ligne  (French)
       http://en.wikipedia.org/wiki/Newline (in English with much more comments)

cyber

#44
Why I can not use funtion NOT like this
If NOT artisttag  = ""   Then writetag

and this is working ok:
If artisttag = ""  Then z=1
else writetag


modyfy to test behaviour.