OS2 World.Com Forum
2012.02.09, 11:57:55 *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: 1 2 [3] 4 5 ... 11
  Print  
Author Topic: CE2mp3  (Read 32227 times)
CDRWSel
Sr. Member
****
Posts: 392


View Profile
« Reply #30 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       
« Last Edit: 2009.06.24, 23:28:17 by CDRWSel » Logged
cyber
Sr. Member
****
Posts: 253


View Profile
« Reply #31 on: 2009.06.25, 14:52:57 »

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).
Logged
jep
Global Moderator
Sr. Member
*****
Posts: 388


View Profile
« Reply #32 on: 2009.06.25, 17:51:58 »

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
Logged
RobertM
Global Moderator
Hero Member
*****
Posts: 1936



View Profile WWW
« Reply #33 on: 2009.06.25, 20:29:30 »

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
Logged

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

CDRWSel
Sr. Member
****
Posts: 392


View Profile
« Reply #34 on: 2009.06.25, 23:16:24 »

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. 
Logged
jep
Global Moderator
Sr. Member
*****
Posts: 388


View Profile
« Reply #35 on: 2009.06.30, 14:22:12 »

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...
Code:
/**
 * 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
Logged
cyber
Sr. Member
****
Posts: 253


View Profile
« Reply #36 on: 2009.07.06, 17:07:28 »

After some delay, on the code again.  Cool

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.
Logged
RobertM
Global Moderator
Hero Member
*****
Posts: 1936



View Profile WWW
« Reply #37 on: 2009.07.06, 18:53:12 »

After some delay, on the code again.  Cool

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
« Last Edit: 2009.07.06, 18:54:51 by RobertM » Logged

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

CDRWSel
Sr. Member
****
Posts: 392


View Profile
« Reply #38 on: 2009.07.06, 19:12:19 »

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
Logged
CDRWSel
Sr. Member
****
Posts: 392


View Profile
« Reply #39 on: 2009.07.07, 00:38:29 »

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

 
                 
         
« Last Edit: 2009.07.09, 02:52:35 by CDRWSel » Logged
cyber
Sr. Member
****
Posts: 253


View Profile
« Reply #40 on: 2009.07.08, 09:44:06 »

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) 

« Last Edit: 2009.07.08, 17:11:26 by cyber » Logged
CDRWSel
Sr. Member
****
Posts: 392


View Profile
« Reply #41 on: 2009.07.08, 21:39:57 »

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.
 
« Last Edit: 2009.07.08, 22:02:25 by CDRWSel » Logged
cyber
Sr. Member
****
Posts: 253


View Profile
« Reply #42 on: 2009.07.09, 01:12:43 »

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.  Cry
Logged
CDRWSel
Sr. Member
****
Posts: 392


View Profile
« Reply #43 on: 2009.07.09, 02:58:12 »

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   Roll Eyes
 
With good dll, it should be ok now.
Remy       

PS: This wiki page may be usefull for control characters translation  Wink
       http://fr.wikipedia.org/wiki/Fin_de_ligne  (French)
       http://en.wikipedia.org/wiki/Newline (in English with much more comments)
« Last Edit: 2009.07.09, 03:10:13 by CDRWSel » Logged
cyber
Sr. Member
****
Posts: 253


View Profile
« Reply #44 on: 2009.07.09, 10:01:46 »

Why I can not use funtion NOT like this
Code:
If NOT artisttag  = ""   Then writetag

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

modyfy to test behaviour.
« Last Edit: 2009.07.13, 12:09:54 by cyber » Logged
Pages: 1 2 [3] 4 5 ... 11
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.14 | SMF © 2006-2011, Simple Machines LLC Valid XHTML 1.0! Valid CSS!