java - 7牛怎么fetch到的amr音频转换成mp3格式
PHPz
PHPz 2017-04-17 17:41:52
0
3
1067
使用七牛抓取资源功能,将微信上的录音的音频抓取出来,放到七牛存储,但是抓取的是amr格式,不能播放,需要将音频转化为mp3格式的.
我用的是sdk是7.0.0版本,搞了一天,快崩溃了.已经成功抓取到了,就是没有办法转码.哪位仁兄知道呢?
感谢感谢!

我将OperationManager添加进来了,7.0.0版本没这个类.方法实现如下
    
Auth auth = Auth.create(QiNiuConstant.ACCESSKEY, QiNiuConstant.SECRETKEY);
OperationManager operater = new OperationManager(auth);
String bucket = event.getFetchVo().getBucket();
String key = event.getFetchVo().getFilePath().toString() 
    • event.getFetchVo().getKey();

      // 设置转码操作参数

    String fops = "avthumb/mp3/s/640x360/vb/1.25m";
    // 设置转码的队列
    String pipeline = "weixinteachervoice";
    // 可以对转码后的文件进行使用saveas参数自定义命名,当然也可以不指定文件会默认命名并保存在当前空间。
    String urlbase64 = UrlSafeBase64.encodeToString(bucket + ":" + key);
    String pfops = fops + "|saveas/" + urlbase64;
    // 设置pipeline参数
    StringMap params = new StringMap().putWhen("force", 1, true).putNotEmpty("persistentPipeline", pipeline);

    1. {

         String persistid = operater.pfop(bucket, key, pfops, params);
         System.out.println("transcod success : " + persistid);

      } catch (QiniuException e) {

         Response r = e.response;
         logger.info("transcod fail :" + r.toString());
         try {
             System.out.println(r.bodyString());
         } catch (QiniuException e1) {
             logger.info("transcod fail : can't print response");
         }

      }
      logger.info("transcode end " );

    PHPz
    PHPz

    学习是最好的投资!

    reply all(3)
    伊谢尔伦

    To trigger persistent transcoding, please refer to the demo collection
    http://7xnonj.com2.z0.glb.qiniucdn.com/i...

    左手右手慢动作

    After fetching, I called the conversion interface. I just did this function yesterday, but the conversion was successful, but it still cannot be played under ios, which is frustrating. . .
    In addition, the official documents are inconsistent in many places, and the sdk provided also has some errors. Only by combining the two can we come up with a conversion interface that can finally be used

    Sorry, it can be played after converting it to mp3. I didn't notice that my phone was in silent mode at the time, so there was no sound, but it can actually be played. For related codes, please refer to http://www.cnblogs.com /weiniu/p/qiniu_fetch_convert_php.html

    迷茫

    I use Python code, localfile is the path of your file.

    q = qiniu.Auth(settings["QiniuAccessKey"], settings["QiniuSecretKey"])
    key = "%s_%s.amr" % (save_id, name)
    policy = {}
    policy["persistentOps"] = "avthumb/m4a|saveas/"+base64.b64encode("audio:%s_%s" %(save_id, name))
    policy["persistentPipeline"] = "weixin"
    policy["callbackUrl"] = "http://XXX.XXX.com/api/audio/weixin_upload_notify"
    policy["callbackBody"] = "filename=$(fname)&filesize=$(fsize)&user_id=%s&save_id=%s&name=%s&duration=%s&created=%s" % (user_id, save_id, name, duration, created)
    uptoken = q.upload_token("audio", key, 3600, policy)
    ret, info = yield qiniu.put_file(uptoken, key, localfile)

    However, I encountered a problem when transcoding recently, and the callbackurl returned instantly... but it was successful.

    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!