我有自动脚本每晚运行(大约350个脚本或测试用例).我想录制每个测试用例的视频(Python脚本).是否有一种工具或方法可用于分别控制每个测试用例的视频录制?
例如,在测试用例设置开始录制期间和拆除停止录制期间,并使用指定的名称和日期在本地保存视频.因此,我应该为每个测试用例提供350个视频(更优选地,仅为失败的测试用例保存视频).
有没有办法在我用于我的设置和拆卸的代码中集成此功能?
python selenium webdriver video-recording selenium-webdriver
我一直试图解决这个问题,但出于某种原因,当我开始使用相机录制视频时,预览会放大.我从以下示例中获得以下代码:
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
Camera.Parameters myParameters = mCamera.getParameters();
List<Camera.Size> sizes = myParameters.getSupportedPreviewSizes();
Camera.Size myBestSize = getBestPreviewSize(sizes, width, height);
if (myBestSize != null) {
myParameters.setPreviewSize(myBestSize.width, myBestSize.height);
myParameters.setVideoStabilization(false);
mCamera.setParameters(myParameters);
mCamera.startPreview();
mCamera.unlock();
}
}
private Camera.Size getBestPreviewSize(List<Camera.Size> sizes, int width, int height) {
final double ASPECT_TOLERANCE = 0.05;
double targetRatio = (double) width / height;
if (sizes == null) return null;
Camera.Size optimalSize = null;
double minDiff = Double.MAX_VALUE;
int targetHeight = height;
// …Run Code Online (Sandbox Code Playgroud) 在尝试修复简单的视频录制应用程序*时,我遇到了一些问题.我想我正确地遵循了一系列步骤.以下是对我提出问题的代码部分的简化.按下按钮后,此代码仅作为回调执行:
if ( mRecorder != null){
mRecorder.reset();
mRecorder.release();
}
mRecorder = new MediaRecorder();
if(mViewer.hasSurface){
mRecorder.setPreviewDisplay(mViewer.holder.getSurface());
Log.d(TAG,"Surface has been set");
}
try {
Log.d(TAG,"Sleeping for 4000 mili");
Thread.sleep(4000);
Log.d(TAG,"Waking up");
} catch (InterruptedException e) {
Log.e(TAG,"InterruptedException");
e.printStackTrace();
}
mRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
mRecorder.setVideoFrameRate(12);
mRecorder.setVideoSize(176, 144);
mRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.MPEG_4_SP);
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
mRecorder.setMaxDuration(MAX_DURATION_TEST);
String targetFile = "/sdcard/webcamera/temp.mp4";
File localFile = new File(targetFile);
if(localFile.exists()){
Log.d(TAG,"Local file exists");
}else{
Log.d(TAG,"Local file does not exist");
}
mRecorder.setOutputFile(targetFile);
try {
mRecorder.prepare();
bPrepared = true;
Log.i(TAG,"prepared");
return;
} catch (IllegalStateException e) { …Run Code Online (Sandbox Code Playgroud) 我可以在一个带有http服务器连接的流媒体视频中播放SurfaceView.我是创造ContextMenu了一种通过添加菜单项录制视频的StartRecording和StopRecording.但我可以通过电话录制相机视频mediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
在这里,我想将视频源设置为流式视频源.这样做有可能吗?
但我想在播放时录制流媒体视频.你能告诉我如何在播放时做唱片吗?
请您提供此问题的示例代码吗?
我的示例代码如下所示:
main.xml中:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<FrameLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/frameLayoutRoot">
<SurfaceView android:id="@+id/surfaceViewFrame" android:layout_gravity="center" android:layout_height="wrap_content" android:layout_width="wrap_content"></SurfaceView>
<LinearLayout android:layout_width="fill_parent" android:id="@+id/linearLayoutMediaController" android:layout_height="wrap_content" android:paddingBottom="5dp"
android:paddingTop="5dp" android:layout_gravity="bottom" android:gravity="center_vertical" android:background="@color/media_controller_bg_color">
<TextView android:layout_width="wrap_content" android:id="@+id/textViewPlayed" android:layout_marginLeft="5dp" android:layout_marginRight="5dp"
android:textColor="@color/media_controller_text_color" android:textStyle="bold" android:text="0:00:00" android:padding="0dp" android:textSize="13sp" android:gravity="center"
android:layout_height="wrap_content"></TextView>
<SeekBar android:id="@+id/seekBarProgress" android:layout_weight="1" style="@style/MyCustomProgressStyle" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:progress="50"></SeekBar>
<TextView android:layout_width="wrap_content" android:id="@+id/textViewLength" android:layout_marginLeft="5dp" android:layout_marginRight="5dp"
android:textColor="@color/media_controller_text_color" android:textStyle="bold" android:text="0:00:00" android:textSize="13sp" android:padding="0dp" android:gravity="center"
android:layout_height="wrap_content"></TextView>
</LinearLayout>
<ProgressBar style="?android:attr/progressBarStyleLarge" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" …Run Code Online (Sandbox Code Playgroud) 要求:
我想开发一个具有暂停和恢复功能的视频重新编码的应用.
我试过:
我已经开发了应用程序,通过使用表面视图重新编码视频.
已经研究过:
我已经搜索了所有的网站,也喜欢但直到现在我无法得到解决方案,我知道android中暂停和恢复视频没有默认选项,也知道通过合并视频,我们可以实现它.
我需要的是:
如果有任何可用的外部插件,请分享我,指导我如何实现这一点,如果你已经实现了,并分享我任何与如何合并视频相关的资源..我搜索但没有适当的资源我见过请分享任何事情,如果你发现..
我正在尝试录制视频,并希望显示正在录制的秒数.
我该怎么办?
public void startRecording(View v){
flipCamera.setVisibility(View.GONE);
captureImage.setVisibility(View.GONE);
String deviceMan = android.os.Build.MANUFACTURER;
this.mediaRecorder = new MediaRecorder();
this.mediaRecorder.setCamera(this.camera);
camera.unlock();
this.mediaRecorder.setCamera(camera);
this.mediaRecorder.setOrientationHint(90);
this.mediaRecorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
this.mediaRecorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
CamcorderProfile camcorderProfile_HQ = CamcorderProfile
.get(CamcorderProfile.QUALITY_480P);
this.mediaRecorder.setProfile(camcorderProfile_HQ);
this.mediaRecorder.setOutputFile(this.initFile().getAbsolutePath());
this.mediaRecorder.setMaxDuration(60000); // Set max duration 60 sec.
this.mediaRecorder.setMaxFileSize(5000000);
this.mediaRecorder.setPreviewDisplay(this.cameraPreview.getHolder()
.getSurface());
this.mediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.MPEG_4_SP);
try {
this.mediaRecorder.prepare();
// start the actual recording
// throws IllegalStateException if not prepared
this.mediaRecorder.start();
Toast.makeText(this, R.string.recording, Toast.LENGTH_SHORT).show();
this.toggleButtons(true);
} catch (Exception e) {
Log.wtf(TAG, "Failed to prepare MediaRecorder", e);
Toast.makeText(this, R.string.cannot_record, Toast.LENGTH_SHORT)
.show();
this.releaseMediaRecorder();
}
}
Run Code Online (Sandbox Code Playgroud)
我对Android很新,所以请任何人都可以提供帮助.
我正在使用FFmpeg录制视频,我希望它写入的帧速率至少在正确的球场.现在我采用输入声称拥有的帧速率,并使用它来设置输出视频流的帧速率(time_base).然而,这有时与我得到的实际帧速率大不相同(我看到一个流声称50 fps但以9 fps发布).
我想要做的是使用经过时间的计时器并计算我记录的帧数来计算我在完成录制时记录的实际帧速率.我似乎在我编写任何帧之前,我在AVStream中设置的帧速率在avcodec_open2中使用.如果我稍后设置它(例如在我写帧的时候),而ffplay可以播放它(抱怨时间增量位是6而不是4)其他视频播放器不能.有没有办法在写入帧后设置整个文件的帧速率?如果没有办法在我录制时告诉帧本身某种时间戳或帧速率会产生有效的录制文件?
在按照与此类似的教程后,我正在使用MediaRecorder类使用相机录制视频
我希望在录音时能够将麦克风静音/取消静音.怎么可能?
我正在设置音频源
mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
Run Code Online (Sandbox Code Playgroud)
但是,如果我想在某些时候没有声音录音怎么办?
我使用Retrofit 2将视频文件(从相机捕获)发送到我的PHP服务器,视频成功上传到服务器中的文件夹(我使用FileZilla检查,视频存在于文件夹中),我将视频分配给URL,我去同一个网址(使用浏览器)它无法播放视频.
它只是在Url中显示(例如:mydomain.cc/video/VID_2014.mp4)
所以我用随机视频测试,通过邮递员发送,该视频的URL能够播放.
像这样:
Android中我在onActivityResult捕获视频后进入的视频文件路径如下所示
/storage/emulated/0/DCIM/ABC/VID_20171008_183129.mp4
这是我发送视频文件的代码
private void uploadVideoToServer(String pathToVideoFile){
File videoFile = new File(pathToVideoFile);
RequestBody videoBody = RequestBody.create(MediaType.parse("video/*"), videoFile);
MultipartBody.Part vFile = MultipartBody.Part.createFormData("video", videoFile.getName(), videoBody);
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(SERVER_PATH)
.addConverterFactory(GsonConverterFactory.create())
.build();
VideoInterface vInterface = retrofit.create(VideoInterface.class);
Call<ResultObject> serverCom = vInterface.uploadVideoToServer(vFile);
serverCom.enqueue(new Callback<ResultObject>() {
@Override
public void onResponse(Call<ResultObject> call, Response<ResultObject> response) {
ResultObject result = response.body();
if(!TextUtils.isEmpty(result.getSuccess())){
Toast.makeText(MainActivity.this, "Result " + result.getSuccess(), Toast.LENGTH_LONG).show();
Log.d(TAG, "Result " + result.getSuccess());
}
}
@Override
public void onFailure(Call<ResultObject> call, …Run Code Online (Sandbox Code Playgroud) android video-recording mediarecorder android-mediarecorder retrofit2
video-recording ×10
android ×7
codec ×1
express ×1
ffmpeg ×1
frame-rate ×1
h.264 ×1
javascript ×1
libavcodec ×1
libavformat ×1
node.js ×1
python ×1
retrofit2 ×1
selenium ×1
surfaceview ×1
video ×1
webdriver ×1
webrtc ×1