这是我用来以MP4格式记录来自Android设备的视频的代码.正在创建文件,但大小为0字节.我似乎不明白出了什么问题.任何帮助将不胜感激.
if(mCamera == null) {
mCamera = Camera.open();
mCamera.unlock();
}
if(mediaRecorder == null)
mediaRecorder = new MediaRecorder();
mediaRecorder.setCamera(mCamera);
mediaRecorder.setCamera(mCamera);
mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
mediaRecorder.setMaxDuration(maxDurationInMs);
mediaRecorder.setOutputFile("/sdcard/1.mp4");
mediaRecorder.setVideoFrameRate(videoFramesPerSecond);
mediaRecorder.setVideoSize(176,144);
mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT);
mediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.MPEG_4_SP);
mediaRecorder.setPreviewDisplay(surface);
mediaRecorder.setMaxFileSize(maxFileSizeInBytes);
mediaRecorder.prepare();
try {
mediaRecorder.prepare();
} catch (IllegalStateException e) {
// This is thrown if the previous calls are not called with the
// proper order
e.printStackTrace();
}
mediaRecorder.start();
Run Code Online (Sandbox Code Playgroud) 我想在使用媒体录制器录制视频时显示已过滤的相机预览.要过滤预览,我需要正常的帧,我可以从onPreviewFrame()函数获得,但在使用媒体记录器录制视频时,onPreviewFrame()函数不会被调用.所以我想知道的是,有没有其他方法可以让这些帧进行过滤,然后在修改后显示它们?我查看了Google Play中的一些应用,例如Videocam Illusion.它在录制视频时显示预览效果.我想做类似的事情,但没有提示如何这样做.所以我将非常感谢有关该问题的任何帮助/提示/代码/示例.谢谢.
我正在这样的Android录制视频
List<Camera.Size> list = myCamera.getParameters().getSupportedPictureSizes();
Parameters parameters = myCamera.getParameters();
parameters.setColorEffect(coloreffects.get(index_color_effect));
myCamera.setParameters(parameters);
mediaRecorder = new MediaRecorder();
myCamera.unlock();
mediaRecorder.setCamera(myCamera);
mediaRecorder.setOrientationHint(90);
mediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
mediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
mediaRecorder.setAudioEncoder(AudioEncoder.HE_AAC);
mediaRecorder.setVideoEncoder(VideoEncoder.H264);
mediaRecorder.setOutputFile(Constants.videourl);
mediaRecorder.setMaxDuration(30000); // Set max duration 60 sec.
mediaRecorder.setVideoFrameRate(24);
mediaRecorder.setVideoFrameRate(30);
mediaRecorder.setVideoSize(720, 480);
mediaRecorder.setPreviewDisplay(myCameraSurfaceView.getHolder().getSurface());
Run Code Online (Sandbox Code Playgroud)
这个录制的视频,能够在Android上播放,但无法在iPhone上播放.
如果使用此代码进行录制
// work two
{
mediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
mediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
mediaRecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH));
mediaRecorder.setOutputFile(videourl);
mediaRecorder.setMaxDuration(30000); // Set max duration 60 sec.
}
Run Code Online (Sandbox Code Playgroud)
这与iphone记录视频兼容.但是这会在三星note2上录制30秒左右的视频大约47 mbs.
有帮助吗?
我一直在努力寻找更好的解决方案来暂停和恢复视频录制.据我所知,Media Recorder类不允许在Android 4.3或更低版本的录制期间暂停.
我发现mp4parser库可以将多个视频文件合并为一个视频文件.我正在使用以下罐子:
aspectjrt-1.7.3.jar
isoparser-1.0.6.jar
问题是将它们合并在一起需要太长时间.例如,总共约5分钟的2-3个视频文件需要至少2分钟才能合并它们!
我的Galaxy S3和Note 2附带的默认Camera应用程序,在视频录制中有暂停选项.他们暂停的视频只需不到1秒即可完成合并.
有人可以告诉我这里我做错了什么吗?
我使用下面的代码合并视频文件:
for (ArrayList<String> PathList : VideoList) {
VideoPathList = PathList;
}
for (String mMovie : VideoPathList) {
Movie movie = MovieCreator.build(mMovie);
MovieList.add(movie);
}
List<Track> videoTracks = new LinkedList<Track>();
List<Track> audioTracks = new LinkedList<Track>();
for (Movie mMovie : MovieList) {
for (Track t : mMovie.getTracks()) {
if (t.getHandler().equals("soun")) {
audioTracks.add(t);
}
if (t.getHandler().equals("vide")) {
videoTracks.add(t);
}
}
}
Movie result = new Movie();
if(audioTracks.size() > 0) {
result.addTrack(new AppendTrack(audioTracks.toArray(new Track[audioTracks.size()]))); …
Run Code Online (Sandbox Code Playgroud) 在录制视频时是否有任何方法可以添加叠加,这样当我从相机胶卷播放视频时,我可以看到叠加.
我创建了 android 应用程序,其中有m3u8
流链接。现在我希望用户在视频播放期间的任何阶段录制视频,并且也可以在我想要的地方停止。但是我用谷歌搜索了它,堆栈溢出和其他 android 帮助站点没有可用的解决方案。我是本节的新手请尽快帮助我。现在我被困在这个部分。我得到一个链接但没有帮助
我把它做成了一个自定义的m3u8
媒体播放器,我只是给了那个媒体播放器的链接,它使用安卓的默认媒体播放器播放
<FrameLayout
android:id="@+id/videoSurfaceContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/videoplayer_title">
<SurfaceView
android:id="@+id/videoSurface"
android:background="@android:color/transparent"
android:layout_width="match_parent"
android:layout_below="@+id/videoplayer_title"
android:layout_height="200dp"
/>
<ImageView
android:id="@+id/videoplayer_icon"
android:layout_width="match_parent"
android:layout_height="200dp"
android:background="@android:color/transparent"
android:visibility="gone"
/>
<ProgressBar
android:id="@+id/progressbar"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="center"
android:layout_below="@+id/videoplayer_title"
android:background="@android:color/transparent"
android:visibility="gone"
/>
<LinearLayout
android:id="@+id/ll_controls_layout"
android:layout_width="match_parent"
android:layout_height="40dp"
android:background="@drawable/media_controls_bg"
android:orientation="vertical"
android:layout_gravity="bottom"
android:visibility="visible">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="40dp"
>
<ImageButton
android:id="@+id/pause"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_centerVertical="true"
android:layout_marginLeft="5dp"
android:background="@android:color/transparent"
android:src="@drawable/pause_btn" />
<SeekBar
android:id="@+id/mediacontroller_progress"
android:layout_width="match_parent"
android:minHeight="6dip"
android:layout_toRightOf="@+id/pause"
android:maxHeight="6dip"
android:thumb="@drawable/abc_switch_thumb_material"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:progressDrawable="@drawable/styled_progress"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:layout_toLeftOf="@+id/time_current"
android:layout_marginLeft="3dp"
android:indeterminate="false" …
Run Code Online (Sandbox Code Playgroud) android video-capture video-streaming video-recording android-mediaplayer
我正在研究社交移动应用.它可以选择录制个人资料视频.我的刻录机的问题是它反映了实际的视频.我知道这是默认行为,但希望它像sanpchat一样工作.
预习
录制和播放后
这是我的代码
// return camera instance when activity open first time
private Camera getCameraInstance() {
// TODO Auto-generated method stub
releaseCamera();
releaseMediaRecorder();
Camera c = null;
try {
cameraId = findFrontFacingCamera();
if (cameraId < 0) {
cameraId = findBackFacingCamera();
}
c = Camera.open(cameraId);
// setCameraDisplayOrientation(this,cameraId,c);
//setCameraDisplayOrientation(this, cameraId, c);
c.setDisplayOrientation(90);
} catch (Exception e) {
// Camera is not available (in use or does not exist)
}
return c; // returns null if camera is unavailable
}
// return …
Run Code Online (Sandbox Code Playgroud) android video-recording android-camera android-mediaplayer android-mediarecorder
我最近开始使用 flutter,在我的项目中我必须用计时器录制视频。当我单击停止按钮停止视频录制时,出现此错误。我尝试显示路径并得到了路径
I/flutter (19037): Video recorded to /data/user/0/app.package/cache/REC8929992591965700575.mp4
I/flutter (19037): Error: INVALID_PATH
I/flutter (19037): Error Message: The platform "TargetPlatform.android" did not return a path while reporting success. The platform should always return a valid path or report an error.
I/flutter (21723): Video recorded to /data/user/0/app.package/cache/REC4634449859696013797.mp4
E/flutter (21723): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: CameraException(INVALID_PATH, The platform "TargetPlatform.android" did not return a path while reporting success. The platform should always return a valid path or report an error.)
Run Code Online (Sandbox Code Playgroud)
使用这个插件:
camera: ^0.9.4+5
video_player: ^2.2.10
Run Code Online (Sandbox Code Playgroud)
我的代码: …
在浏览器上使用MediaRecorder录制视频流时,根据浏览器(Chrome、Safari 或 Firefox),MediaRecorder 可以以特定格式录制视频。
下表显示了 MediaRecorder 可以在每个浏览器中录制的视频格式/容器(我通过使用 isTypeSupported静态方法获得此信息)。本文还使用 isTypeSupported 方法显示了不同浏览器上所有支持的 MediaRecorder 格式的表格。
浏览器 | 录音格式 |
---|---|
铬合金 | .WEBM、.MKV |
歌剧 | .WEBM、.MKV |
边缘 | .WEBM、.MKV |
火狐浏览器 | .WEBM |
苹果浏览器 | .MP4 |
当您想播放视频时,并非所有浏览器都支持相同的格式。下表显示了每个浏览器可以播放的视频格式(可能不准确)。
浏览器 | 可以播放视频格式 |
---|---|
铬合金 | .MP4、.WEBM、.MKV |
歌剧 | .MP4、.WEBM、.MKV |
边缘 | .MP4、.WEBM、.MKV |
火狐浏览器 | .MP4、.WEBM |
苹果浏览器 | .MP4 |
我有一个网络应用程序,用户可以在他/她的浏览器上录制视频,然后将该视频上传到数据库。
之后,其他用户可以访问该网站并在其浏览器上观看该视频。如果用户在Safari浏览器上录制视频,则录制的视频格式为所有浏览器支持(MP4),但如果用户使用Chrome或Firefox,则录制的视频格式为除Safari之外的所有浏览器支持(WEBM)。
有没有办法以可以在所有浏览器上播放的格式录制视频(例如 MP4)?
我正在寻找一种只能在浏览器上完成而无需转换视频格式的解决方案。
javascript cross-browser video-recording web web-mediarecorder
video-recording ×10
android ×7
camera ×3
ios ×2
video ×2
camera-roll ×1
flutter ×1
frames ×1
iphone ×1
javascript ×1
live-preview ×1
objective-c ×1
swift ×1
web ×1