我试图从GET请求发送一些身份验证标头,我尝试使用Volley JsonObjectRequest调用:
Map<String,String> params=new HashMap<String,String>();
params.put("token","fghjbvjhnjjk");
activity.showDialog();
JsonObjectRequest req = new JsonObjectRequest(Request.Method.GET,url,
new JSONObject(params), new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
Log.d(tag, response.toString());
activity.hideDialog();
try {
activity.onRequestServed(response, code);
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
VolleyLog.d(tag, "Error: " + error.getMessage());
Log.e(tag, "Site Info Error: " + error.getMessage());
Toast.makeText(activity.getApplicationContext(),
error.getMessage(), Toast.LENGTH_SHORT).show();
activity.hideDialog();
try {
activity.onRequestServed(null,code);
} catch (JSONException e) {
e.printStackTrace();
}
}
}); …Run Code Online (Sandbox Code Playgroud) 我试图使用Emgu CV VideoWriter捕获视频,但它显示:
无法创建VideoWriter.确保安装了特定的编解码器
我该如何处理?
这就是我的代码:
Bitmap back = new Bitmap("jpg image path");
Image<Bgr, Byte> bg;
bg = new Image(Bgr, byte)(back);
vw = new VideoWriter("c://work//test1.mp4",CvInvoke.CV_FOURCC('M','S','V','C'), 17, 640, 480, true);
Run Code Online (Sandbox Code Playgroud)
它适用于.avi扩展,但是只有几秒钟的大小相当大,所以我想更多地压缩它.请建议代码/库的任何变通方法或更改.