. AMR for mobile device audio, compression of the larger, more for the voice, call, the effect is ok! therefore, the mobile device uses AMR format to carry on the storage record! A more common example: recording!
This ghost, in two words to describe, is "egg ache", because HTML5 does not support it at all (amr: I am an orphan, director: Zomi Chilla); so, The audition effect is very difficult to achieve! Although it is provided for audition, once you leave the page, it means that you can no longer play your recordings!
So you have to convert the file under the format!
At present, there are two ways to master the conversion format: one is to upload to the seven Cow cloud service for conversion download, and the other is through the FFmpeg application to convert!
Seven-ox Conversion Method:
1. first, Register seven Qiniu storage!
2. Seven cattle will return to you "two" pass, the pass is the communication seven cattle indispensable tool! A picture:
AK and SK are the prerequisites for program execution!
3. Create a space and add a queue! The space name, and the queue name are used to!
Space is the warehouse where you upload files, and the queue is the factory of processing files! You can create multiple!
Space needs to configure the domain name!
4. Download the source code provided by the seven kn: I am the link
There is a file named "Qiniu.4.0.dll" in the file that references it to your project!
// <summary> ///set up your ak, SK, and domain names/// </summary> Private Static voidSetkey () {//set up an account for AK and SKConfig.access_key ="########################################"; Config.secret_key="****************************************"; Config.api_host="http://###.***.com"; }
5. Upload the file and notify seven cows to convert the format to file, the following example Is:. AMR format to Go. MP3 Format.
/// <summary> ///upload files and Pre-format/// </summary> /// <param name= "key" >the file name to convert the format to</param> /// <param name= "filePath" >file path</param> /// <returns></returns> Private stringUploadstringKeystringFilePath) {ioclient Target=Newioclient (); PutExtra Extra=NewPutExtra (); //Set the space name stored after the file is uploadedString bucket ="amrtest"; //normal upload, only need to set the upload space name on it, The second parameter can be set token expiration timePutpolicy put =NewPutpolicy (bucket,3600); //use the SaveAs parameter to customize the name of the transcoded file, or do not specify that the file will be named by default and saved in the current space. stringMp3tpname = Key. Split ('.')[0]. ToString () +". mp3"; String urlbase64= Qiniu.Util.Base64URLSafe.Encode (bucket +":"+mp3tpname); //generally refers to the target storage space (bucket) to upload the file to. If it is "Bucket",//indicates that the limit can only be passed to the Bucket (new file only); If "bucket:key" means that a specific file is qualified, the file can be Modified. Put. Scope = bucket +":"+key; //Optional. If not 0, even if the scope is bucket:key, insert only is the Form.Put. Insertonly =0; // "|" The vertical bar is the command you want to convert the format to, and the vertical bar is the name of the file and the space to store after the conversion is complete! Put. Persistentops ="avthumb/mp3/ab/128k/ar/44100/acodec/libmp3lame|saveas/"+urlbase64; //the required documents to be modified in that "factory", that is, the queue name! Put. Persistentpipeline ="Littlebai"; //after the audio and video transcoding is persisted, the seven server sends a notification of processing results to the User. The URL specified here is the interface for receiving Notifications. //set the ' Persistentops ', you need to set this field at the same timePut. Persistentnotifyurl ="http://***.###.com/***/default.aspx"; //Generate upload token stringUptoken =Put. Token (); //Uploading FilesPutret ret =Target. Putfile (uptoken, key, filePath, extra); //return Data format: {"hash": "fvipqyymwi0gvgc7_nud8ovbuj85", "key": "55456.amr", "persistentid": " z0.57eb86a945a2652644d64308 "} returnRet. Response.tostring (); }
6. finally, Download the converted file from the seven bull space to the current server.
/// <summary> ///Download/// </summary> /// <param name= "key" >well-formatted file name</param> /// <param name= "savepath" >save path after download</param> /// <returns></returns> Private stringDownloadstringKeystringSavepath) { //constructs the private space needs to generate the download link you help set the domain name in the space plus the file name to download stringBASEURL ="http://***.###.com/"+key; //call the MakeRequest method to generate a private download link stringPrivate_url =getpolicy.makerequest (baseUrl); download file HttpWebRequest req=(httpwebrequest) httpwebrequest.create (private_url); Req. Method="GET"; using(webresponse WR =Req. GetResponse ()) {httpwebresponse myresponse=(httpwebresponse) Req. GetResponse (); stringstrpath =myResponse.ResponseUri.ToString (); WebClient mywebclient=NewWebClient (); Try{mywebclient. DownloadFile (strpath, savepath); } Catch(Exception Ex) {savepath=Ex. ToString (); } } returnsavepath; }
OK, the conversion is complete! Attach One:
All right, that's It! A piece of humble article, hope haihan!
If in doubt, welcome harassment, q group: 225443677 tks!
. NET Audio conversion. amr turn. mp3 (method i)