nadeemshafi9 Posted September 2, 2006 Share Posted September 2, 2006 hii am trying to join two wma audio files together after taking them from the db, i need them to play in 1 sequence, has anyone done this before. i can only get one playing even thogh there is the data of two maybe theres a better teqnique (one that works).heres how im trying to join them but obviously the file end indicates its end and its still read as one and rest diguarded does anyone hav any ideas how i can do this in another way.[code] header("Content-type: audio/basic"); include("../db_con.php"); $sql = "SELECT audio FROM audio WHERE id='18';"; $result = mysql_query($sql, $conn); $row = mysql_fetch_array($result); $audio = $row["audio"]; $sql = "SELECT audio FROM audio WHERE id='19';"; $result = mysql_query($sql, $conn); $row = mysql_fetch_array($result); $audio = $audio." ".$row["audio"]; echo $audio;[/code]thhanx all Quote Link to comment https://forums.phpfreaks.com/topic/19505-joining-two-audio-file-binaries/ Share on other sites More sharing options...
pedroas Posted September 2, 2006 Share Posted September 2, 2006 I've never tried this, but there is a little program SoX at http://sox.sourceforge.net/ that you can use to concat sound fils.... you fetch first audio then write to a file$file1 = "/tmp/audio1.wma"; // maybe is better generate a random name for the file$descriptor = fopen ($file1, "w"); fwrite($descriptor,$audio);fclose($descriptor);.... you fetch second audio then write to another file$file2 = "/tmp/audio2.wma";$descriptor2 = fopen ($file2, "w"); fwrite($descriptor2,$audio);fclose($descriptor2);.... then you concat audio files with sox$finalfile = "/tmp/final.wma";$cmd = "sox $file1 $file2 $finalfile";shell_exec($cmd);... erase temporary filesunlink($file1);unlink($file2);... the last task is to open final.wma, read and return to client$descriptor3 = fopen($finalfile,"r");$audio = fread ($descriptor3, filesize ($finalfile));fclose($descriptor3)echo $audioA better solution would be put $finalfile in a directory under your document root in webserver and redirect header to it. Quote Link to comment https://forums.phpfreaks.com/topic/19505-joining-two-audio-file-binaries/#findComment-84893 Share on other sites More sharing options...
nadeemshafi9 Posted September 3, 2006 Author Share Posted September 3, 2006 everything looks like its working but i need to concat but i dont know were to put the SOX files for access by shell_exec() i never used a custom shell program so i dont know were to put it i tried a few.thanx this is very helpfull Quote Link to comment https://forums.phpfreaks.com/topic/19505-joining-two-audio-file-binaries/#findComment-85031 Share on other sites More sharing options...
nadeemshafi9 Posted September 3, 2006 Author Share Posted September 3, 2006 im using windows Quote Link to comment https://forums.phpfreaks.com/topic/19505-joining-two-audio-file-binaries/#findComment-85032 Share on other sites More sharing options...
pedroas Posted September 3, 2006 Share Posted September 3, 2006 Well, at a first sight you could put sox.exe in any directory, I suggest C:\WINDOWS (XP) or C:\WINNT (NT or 2000), but check before in PHP.INI wheater you're using safe_mode=true or 1, this directory should be inside safe_mode_exec_dir. Don't forget to call shell_exec with full pathname like shell_exec("c:/windows/sox $file1 $file2 $finalfile"); Quote Link to comment https://forums.phpfreaks.com/topic/19505-joining-two-audio-file-binaries/#findComment-85429 Share on other sites More sharing options...
nadeemshafi9 Posted September 4, 2006 Author Share Posted September 4, 2006 ok its all working BUTsoxmix only exepts wav files, i tryed with wav its doing the job but in my own upload script my wav files are not going in to my db properly they are loosing binaary data wen they go in to the db, the wma files go in perfectly but wav files are being reduced maybe they got special chars in them. here is how im uploading my audio files, [code] $audiodata = $_FILES['fileaudio']['tmp_name']; $fopen=fopen($audiodata, "r"); $size=filesize($audiodata); $fread=fread($fopen, $size); $audiodata = addslashes($fread); $sql = "INSERT INTO audio (audio) VALUES ('".$audiodata."');"; mysql_query($sql, $conn);[/code]wma files are going in perfect but wav files get reduced to 64 kbthanx alot uv been very helfull my proj is up and running almost. Quote Link to comment https://forums.phpfreaks.com/topic/19505-joining-two-audio-file-binaries/#findComment-85532 Share on other sites More sharing options...
nadeemshafi9 Posted September 4, 2006 Author Share Posted September 4, 2006 this kinda stuff is not uploaded [quote]}}}}}}kkppuuyy~~ƒƒ‡‡‹‹““––™™œœŸŸ¡¡¢¢££¤¤££¢¢ šš––’ååââÝÝÖÖÎÎÆƾ¾¶¶ŸŸ||mm_[/quote]i know about addcslashes($i,$i) but do you recon il hav to compensate for all of this, theres many more and i dont know the ascci.man i been awake for ages if (response){ thanx} Quote Link to comment https://forums.phpfreaks.com/topic/19505-joining-two-audio-file-binaries/#findComment-85576 Share on other sites More sharing options...
nadeemshafi9 Posted September 4, 2006 Author Share Posted September 4, 2006 heres some more thats getting knocked out at db insert even though i am using addslashes()[quote] $$**0066==EENNWW``kkvvƒƒ››§§±±¹¹ÁÁÈÈÎÎÓÓ××ÙÙÙÙØØÕÕÑÑÌÌÄļ¼²²¦¦ššŒŒ~~qqccUUXX[[^^aaccffhhkkmmnnppqqqqqqqqppnnlljjhhffddbb``__]]\\ZZYYXXWWVVUUTTTTSSSSSS’’’’’’’’’’’’’[/quote]these are ok[quote]€€€€€€€€€€€€€€€€€€[/quote] Quote Link to comment https://forums.phpfreaks.com/topic/19505-joining-two-audio-file-binaries/#findComment-85577 Share on other sites More sharing options...
pedroas Posted September 4, 2006 Share Posted September 4, 2006 Well, there are a lot of things that could get wrong:1) First, when we use fopen with binary files we should do this way$handle = fopen("file", "rb"); or $handle = fopen("file", "wb"); to make sure file will be treated like a binary file, else it will be treated like a text file where it could do text transformations on line terminators;2) What is the type of audio field in MySQL?Pedro A. S Quote Link to comment https://forums.phpfreaks.com/topic/19505-joining-two-audio-file-binaries/#findComment-85683 Share on other sites More sharing options...
nadeemshafi9 Posted September 4, 2006 Author Share Posted September 4, 2006 i tyed using wb it has no effect, the feild is a BLOB Quote Link to comment https://forums.phpfreaks.com/topic/19505-joining-two-audio-file-binaries/#findComment-85920 Share on other sites More sharing options...
nadeemshafi9 Posted September 4, 2006 Author Share Posted September 4, 2006 well i changed it to long blob, prob solved and used 'B' opperator in fopen.thanck you verry much for your help.il work to the next stage and il post my progress, the script is gona join the database audio to create speach.i will update you on my success, thanx verry much, im gona research what type of sounds i need, i have nero wav editor so i can clean up the sounds.once more thanx very much i dont think i would have got very far without ur help, and the help u given will stay with me through my up and comming projects.thancks nadeem shafips. stay tuned Quote Link to comment https://forums.phpfreaks.com/topic/19505-joining-two-audio-file-binaries/#findComment-85931 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.