标签: video-recording

使用AVFoundation更改视频帧大小

我试图将视频帧大小更改为方形,即100 x 100.以下是代码:

- (void) changeSize :(NSURL *) url
{

//Create audio/video Settings
NSDictionary *videoSettings = [NSDictionary dictionaryWithObjectsAndKeys:
                               AVVideoCodecH264, AVVideoCodecKey,
                               [NSNumber numberWithInt: 100], AVVideoWidthKey, 
                               [NSNumber numberWithInt:100], AVVideoHeightKey, 
                               nil];

NSDictionary * audioSettings = [NSDictionary dictionaryWithObjectsAndKeys: 
                               [NSNumber numberWithFloat: 44100.0], AVSampleRateKey, 
                               [NSNumber numberWithInt: 2], AVNumberOfChannelsKey, 
                               [NSNumber numberWithInt: kAudioFormatAppleLossless], AVFormatIDKey, 
                               [NSData data], AVChannelLayoutKey, nil];



//Read Asset 
AVURLAsset *myAsset = [AVURLAsset URLAssetWithURL:url options:nil];

NSArray *videoTracks = [myAsset tracksWithMediaType:AVMediaTypeVideo];
AVAssetTrack *audioTrack = [[myAsset tracksWithMediaType:AVMediaTypeAudio]objectAtIndex:0];


AVAssetReader *assetReader = [[AVAssetReader alloc]initWithAsset:myAsset error:nil];

AVAssetReaderOutput *videoOutput = [AVAssetReaderVideoCompositionOutput assetReaderVideoCompositionOutputWithVideoTracks:videoTracks videoSettings:nil]; …
Run Code Online (Sandbox Code Playgroud)

iphone avfoundation video-editing core-video video-recording

5
推荐指数
1
解决办法
5899
查看次数

MediaRecorder - 固件升级后代码停止工作

我有一个在Android 2.2上运行的三星Galaxy选项卡.我开发了一个简单的程序来分别录制音频和视频.它在我的galaxy选项卡上正常工作.但是,在将其升级到android 2.3.3后,一切都发生了变化.我的代码从那一刻开始停止工作.这是我的代码显示这个意外(对我:) :)行为:

// import statements

public class CameraPreview extends Activity implements SurfaceHolder.Callback {
    Camera camera;
    SurfaceView surfaceView;
    SurfaceHolder surfaceHolder;
    boolean previewing = false;
    LayoutInflater controlInflater = null;
    Button recordButton;

    /** Called when the activity is first created. */
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.camera);
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

        getWindow().setFormat(PixelFormat.UNKNOWN);
        surfaceView = (SurfaceView) findViewById(R.id.camerapreview);
        surfaceHolder = surfaceView.getHolder();
        surfaceHolder.addCallback(this);
        surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);

        controlInflater = LayoutInflater.from(getBaseContext());
        View viewControl = controlInflater.inflate(R.layout.control, null);
        LayoutParams layoutParamsControl = new LayoutParams(
                LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
        this.addContentView(viewControl, layoutParamsControl);

        recordButton = (Button)viewControl.findViewById(R.id.start_recording);
        recordButton.setOnClickListener(new View.OnClickListener() …
Run Code Online (Sandbox Code Playgroud)

android audio-recording video-recording mediarecorder android-mediarecorder

5
推荐指数
1
解决办法
1611
查看次数

Camera Server死机 - 某些设备仍然存在错误100

我正在尝试用前后摄像头开发录像机.该应用程序可以在后部(默认)和前置摄像头之间切换.当应用程序激活前置摄像头,然后我按下录制按钮,应用程序进入错误方法,然后我释放并启动摄像头和录制,但错误仍然存​​在.任何的想法?更新:我更新了onError方法,使用下面的代码,我认为我没有很好地发布和初始化相机,因为当应用程序执行此方法时,表面支架是黑色的,并没有给我什么相机看到

在这里,我的代码:

onError方法:

 public void onError(MediaRecorder mr, int what, int extra) {
    stopRecording();

    //if Error 100, app must release the Camera object and instantiate a new one.
    if (what == 100) {
        if (error_100  == 2) { //Error 100 persists, change camera
            if (Camera.getNumberOfCameras() <= 1) {
                //No mas camaras para app
            } else {
                if (selected_camera == FRONT_CAMERA) {
                    selected_camera=BACK_CAMERA;
                } else {
                    selected_camera=FRONT_CAMERA;
                }
                selected_camera_button.setEnabled(false);
                Toast.makeText(this, "Initializing other camera", Toast.LENGTH_SHORT).show();
            }

        } else { //No camera init finish …
Run Code Online (Sandbox Code Playgroud)

camera android video-recording

5
推荐指数
0
解决办法
1393
查看次数

Android onActivityResult

我陷入困境,根据我的应用程序图表流程描述如下:

假设我在活动A上,在按钮上点击我从图库中选择图像并在选择之后,我将转移到活动B(它来自onActivity结果 - 通过传递Intent).现在,当我在活动B上并单击按钮时,会调用自定义视频制作者.在这里,我捕捉视频10秒,然后我完成(活动C)使用

C.this.finish();
Run Code Online (Sandbox Code Playgroud)

现在根据Android活动流程我应该回到活动B,但在我的情况下,我得到一个黑屏几秒钟,然后获得活动A,而不是活动B.我不能透露我的代码,所以我我没附上它.对不起,同样的.如果有人可以帮我提供这么多信息,请帮助我

码:

单击按钮的活动B代码段:

 btnTakeVideo.setOnClickListener(new OnClickListener() {
            public void onClick(View arg0) {                
                Intent takePictureIntent = new Intent(TakeAnotherPhoto.this,Recorder.class);

                startActivityForResult(takePictureIntent,CreateAuctionScreen.ACTION_TAKE_VIDEO);
            }
        });
Run Code Online (Sandbox Code Playgroud)

这是onActivityResult

onActivityResult()
if(requestCode == CreateAuctionScreen.ACTION_TAKE_VIDEO) {
            if (resultCode == RESULT_OK) {
                if(CreateAuctionScreen.resetBitmap!=null)
                {                
                    CreateAuctionScreen.resetBitmap = null;
                }                
                Drawable dd;
                dd = getResources().getDrawable(R.drawable.list_pic_frame2x);
                CreateAuctionScreen.bmpSize = ((BitmapDrawable)dd).getBitmap();

                if(data != null){


                    Uri str = data.getData();
                    String path = getRealPathFromURI(str);
                    System.out.println(path);

                    Bitmap bmp = ThumbnailUtils.createVideoThumbnail(path, MediaStore.Images.Thumbnails.MINI_KIND);
                    CreateAuctionScreen.resetBitmap = Bitmap.createScaledBitmap(bmp, CreateAuctionScreen.bmpSize.getWidth(), CreateAuctionScreen.bmpSize.getHeight(), true);

                    if(CreateAuctionScreen.resetBitmap != null){

                        if(CreateAuctionScreen.thumbList.size() < 20){
                            dpv.set_chkString("Video");
                            dpv.get_chkString(); …
Run Code Online (Sandbox Code Playgroud)

android video-recording android-activity

5
推荐指数
1
解决办法
842
查看次数

如何使用ffmpeg从网络摄像头录制视频和音频?

我想使用ffmpeg录制网络摄像头的视频和音频,

我使用以下代码来了解可用的设备:

ffmpeg -list_devices true -f dshow -i dummy
Run Code Online (Sandbox Code Playgroud)

并得到结果:

ffmpeg version N-54082-g96b33dd Copyright (c) 2000-2013 the FFmpeg developers
built on Jun 17 2013 02:05:16 with gcc 4.7.3 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-av
isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab
le-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetyp
e --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --ena
ble-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-l
ibopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libsp
eex --enable-libtheora --enable-libtwolame --enable-libvo-aacenc --enable-libvo-
amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --
enable-libxvid --enable-zlib
libavutil      52. 37.101 / 52. 37.101
libavcodec …
Run Code Online (Sandbox Code Playgroud)

audio video webcam ffmpeg video-recording

5
推荐指数
1
解决办法
3512
查看次数

Android Studio 3.0录制视频无法正常工作

我试图在模拟器上录制视频。我可以在logcat选项卡中看到record选项,它可以进行记录,但是保存的文件不在mp4中,并且无法打开。如何解决这个问题?我正在尝试模拟器。录制视频的分辨率是否有限制

android android-emulator video-recording android-studio

5
推荐指数
1
解决办法
1281
查看次数

使用Objective-C中的SCRecorder以改进的播放速度保存视频

使用SCRecorder希望在录制后保存视频,用户选择不同的播放速度ex:2x,3x.使用AVPlayer,可以使用以下代码实现:

//create mutable composition
AVMutableComposition *mixComposition = [AVMutableComposition composition];

AVMutableCompositionTrack *compositionVideoTrack = [mixComposition addMutableTrackWithMediaType:AVMediaTypeVideo
                                                                               preferredTrackID:kCMPersistentTrackID_Invalid];
NSError *videoInsertError = nil;
BOOL videoInsertResult = [compositionVideoTrack insertTimeRange:CMTimeRangeMake(kCMTimeZero, asset.duration)
                                                        ofTrack:[[asset tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0]
                                                         atTime:kCMTimeZero
                                                          error:&videoInsertError];
if (!videoInsertResult || nil != videoInsertError) {
    //handle error
    return;
}

//slow down whole video by 2.0
double videoScaleFactor = 2.0;
CMTime videoDuration = asset.duration;

[compositionVideoTrack scaleTimeRange:CMTimeRangeMake(kCMTimeZero, videoDuration)
                           toDuration:CMTimeMake(videoDuration.value*videoScaleFactor, videoDuration.timescale)];

//export
AVAssetExportSession* assetExport = [[AVAssetExportSession alloc] initWithAsset:mixComposition
                                                                  //   presetName:AVAssetExportPresetLowQuality];
Run Code Online (Sandbox Code Playgroud)

但是,没有得到如何使用SCRecorder库实现相同的功能.请指导.提前致谢.

iphone objective-c playback video-recording ios

5
推荐指数
1
解决办法
214
查看次数

如何用块中的FFMPEG记录UDP流?

我正在寻找一种方法来使用ffmpeg记录视频UDP流,但是在10mn块中.我目前使用以下内容获得1000万的视频(使用h264转码).

"ffmpeg -i udp://239.0.77.15:5000 -map 0:0 -map 0:1 -s 640x360 -vcodec libx264 -g 100 -vb 500000 -r 25 -strict experimental -vf yadif -acodec aac -ab 96000 -ac 2 -t 600 -y /media/test.m4"

我的问题是使用命令行ffmpeg需要时间与udp流重新同步,每次丢失2秒的视频.这是正常的吗?

知道是否有办法在命令行中执行此操作或者我是否应该尝试使用ffmpeg API?

提前致谢

udp ffmpeg video-recording

4
推荐指数
2
解决办法
2万
查看次数

iOS录制视频第一帧是黑色的

我制作了一个录制视频应用程序,但第一帧始终是黑色的.

我用:

- (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection 
Run Code Online (Sandbox Code Playgroud)

和assetWriter编写样本缓冲区.

我发现第一个样本缓冲区是mediaType:'soun',这是问题所在.

我应该怎么做

video-recording ios

4
推荐指数
1
解决办法
1324
查看次数

ffmpeg - 生成moov原子

我目前正在用blackmagic的prorecorder录制视频.我使用ffmpeg将视频动态转码为mp4视频容器.持续时间是未知的,因为我正在转码.s,prorecorder输出到命名管道.

我的目标是尝试使用浏览器播放此文件,而流仍在录制 - 播放很棒,但问题是当我打开文件时,持续时间定义为当前录制时间.

所以,问题是 - 我想在fe的持续时间内产生"假的"moov原子.使用ffmpeg 8小时,然后开始录制mp4文件,因为我已经在做了.我怎么能这样做?

我检查过的文档,我认为它是相关的 - https://ffmpeg.org/ffmpeg-formats.html#MOV_002fMP4_002fISMV 我也在堆栈上看到了这个:是否有可能伪造一个(mp4)moov原子?

mp4 ffmpeg video-recording

4
推荐指数
1
解决办法
4559
查看次数