Recherche avancée

Médias (1)

Mot : - Tags -/MediaSPIP

Autres articles (43)

Sur d’autres sites (8557)

  • Use ffmpeg udp multicast to parse the external camera IP stream. On the iOS platform, cpu rises ? Hard decoding with videoToolBox sometimes fails

    25 février 2019, par AlfredFu

    I use the ffmpeg udp multicast function to connect an external camera on the iOS platform, use videoToolBox for hard decoding, and find that sometimes the decoding fails. The error that occurs in the successful callback is bad data error, cpu is a bit high, I don’t know what it is. Cause ? Have you encountered the same problem as me and solved it ? thank you very much

  • Record video with Media Recorder in WEBM format

    21 mai 2017, par Matho

    I need to record two videos via media recorder and process them with ffmpeg in Android. I want to read videos via pipe in ffmpeg command string. From what I have read, I could not use 3GPP/MP4 format, because these formats contains header at the end of video. Because of it, I want to use WEBM video format, but my app is crashing, when I use webm/vp8 setting in media recorder. Ffmpeg I’m using is : com.writingminds:FFmpegAndroid:0.3.2. Could you help me please ?

    RecorderPrepareTask :

    class RecorderPrepareTask extends AsyncTask {
    private Context mContext;

    public RecorderPrepareTask(Context context) {
       mContext = context;
    }

    @Override
    protected Boolean doInBackground(Void... voids) {
       Timber.d("Starting screen recording...");

       if (!outputRoot.exists() && !outputRoot.mkdirs()) {
           Timber.e("Unable to create output directory '%s'.", outputRoot.getAbsolutePath());
           return false;
       }

       recorder = new MediaRecorder();
       recorder.setVideoSource(SURFACE);
       recorder.setOutputFormat(MediaRecorder.OutputFormat.WEBM);
       recorder.setVideoEncoder(MediaRecorder.VideoEncoder.VP8);
       recorder.setVideoSize(Config.VIDEO_SIZE_W, Config.VIDEO_SIZE_H);
       recorder.setVideoFrameRate(Config.FRAME_RATE);

       Timber.i("Output file '%s'.", outputFileName);
       recorder.setOutputFile(RecordingActivity.pipe[1].getFileDescriptor());


       try {
           recorder.prepare();
       } catch (IOException e) {
           throw new RuntimeException("Unable to prepare MediaRecorder.", e);
       }


       projection = projectionManager.getMediaProjection(resultCode, data);

       Surface surface = recorder.getSurface();
       display = projection.createVirtualDisplay(DISPLAY_NAME, Config.VIDEO_SIZE_W, Config.VIDEO_SIZE_H, 560, VIRTUAL_DISPLAY_FLAG_PRESENTATION, surface, null, null);

       recorder.start();

       return true;
    }

    @Override
    protected void onPostExecute(Boolean result) {

    }

    }

    getConvertCmd :

    private String getConvertCmd(){
       return "-re -r 30 -f webm -c:v vp8 -i pipe:"+ RecordingActivity.pipe[0].getFd() + " -threads 2 -preset ultrafast -profile:v main -level 3.1 -b:v 440k -ar 44100 -ab 128k -s "+ Config.CAMERA_VIDEO_SIZE_W + "x" + Config.CAMERA_VIDEO_SIZE_H + " -vcodec vp8 -acodec vorbis " + outputFileName3;
    }

    Logs :

    D/SoftVPXEncoder: VP8: internalSetAndroidVp8Params. BRMode: 0. TS: 0. KF: 24. QP: 0 - 0 BR0: 100. BR1: 0. BR2: 0
    I/ACodec: setupVideoEncoder succeeded
    E/OMXNodeInstance: setConfig(1a:google.vp8.encoder, ConfigPriority(0x6f800002)) ERROR: Undefined(0x80001001)
    I/ACodec: codec does not support config priority (err -2147483648)
    W/ACodec: do not know color format 0x7f000789 = 2130708361
    I/SoftMPEG4Encoder: Construct SoftMPEG4Encoder
    I/MediaCodec: MediaCodec will operate in async mode
    E/OMXNodeInstance: getParameter(1b:google.mpeg4.encoder, ParamVideoErrorCorrection(0x6000007)) ERROR: NotImplemented(0x80001006)
    I/ACodec: setupVideoEncoder succeeded
    E/OMXNodeInstance: setConfig(1b:google.mpeg4.encoder, ConfigPriority(0x6f800002)) ERROR: Undefined(0x80001001)
    I/ACodec: codec does not support config priority (err -2147483648)
    D/SoftVPXEncoder: VP8: initEncoder. BRMode: 0. TSLayers: 0. KF: 24. QP: 0 - 0
    I/AudioFlinger: AudioFlinger's thread 0xb2440000 ready to run
    xW/AudioFlinger: acquireAudioSessionId() unknown client 10079 for session 7
    I/MediaCodec: MediaCodec will operate in async mode
    /system_process I/DisplayManagerService: Display device added: DisplayDeviceInfo{"RMR": uniqueId="virtual:sk.matho.rocket_monkeys.rocketmonkeysrecorder,10052,RMR,0", 480 x 640, modeId 6, defaultModeId 6, supportedModes [{id=6, width=480, height=640, fps=60.0}], density 560, 560.0 x 560.0 dpi, appVsyncOff 0, presDeadline 16666666, touch NONE, rotation 0, type VIRTUAL, state ON, owner sk.matho.rocket_monkeys.rocketmonkeysrecorder (uid 10052), FLAG_PRIVATE, FLAG_PRESENTATION}
    E/OMXNodeInstance: setConfig(1c:google.amrnb.encoder, ConfigPriority(0x6f800002)) ERROR: Undefined(0x80001001)
    I/ACodec: codec does not support config priority (err -2147483648)
    E/WebmElement: mmap64 failed; errno = 22
    E/WebmElement: fd 18; flags: 1
    E/WebmElement: mmap64 failed; errno = 22
    E/WebmElement: fd 18; flags: 1
    E/WebmElement: mmap64 failed; errno = 22
    E/WebmElement: fd 18; flags: 1
    E/WebmElement: mmap64 failed; errno = 22
    E/WebmElement: fd 18; flags: 1
    E/WebmElement: mmap64 failed; errno = 22
    E/WebmElement: fd 18; flags: 1
    E/WebmElement: mmap64 failed; errno = 22
    E/WebmElement: fd 18; flags: 1
    D/gralloc_ranchu: gralloc_alloc: format 1 and usage 0x10003 imply creation of host color buffer
    I/MediaCodecSource: MediaCodecSource (video) starting
    I/MediaCodecSource: MediaCodecSource (video) started
    D/MPEG4Writer: Video track stopping
    E/MPEG4Writer: Stop() called but track is not started
    D/MPEG4Writer: Audio track stopping
    E/MPEG4Writer: Stop() called but track is not started

    [ 05-21 13:03:44.101  9757: 9766 D/         ]
    HostConnection::get() New Host Connection established 0xb344f140, tid 9766
    /sk.matho.rocket_monkeys.rocketmonkeysrecorder E/MediaRecorder: start failed: -2147483648                                                                                                  
    /sk.matho.rocket_monkeys.rocketmonkeysrecorder E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #2
    Process: sk.matho.rocket_monkeys.rocketmonkeysrecorder, PID: 10079
    java.lang.RuntimeException: An error occurred while executing doInBackground()
    at android.os.AsyncTask$3.done(AsyncTask.java:309)
    at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
    at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
    at java.util.concurrent.FutureTask.run(FutureTask.java:242)
    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
    at java.lang.Thread.run(Thread.java:818)
    Caused by: java.lang.RuntimeException: start failed.
    at android.media.MediaRecorder.start(Native Method)
    at sk.matho.rocket_monkeys.rocketmonkeysrecorder.recording.CameraRecordingSession$MediaPrepareTask.doInBackground(CameraRecordingSession.java:181)
    at sk.matho.rocket_monkeys.rocketmonkeysrecorder.recording.CameraRecordingSession$MediaPrepareTask.doInBackground(CameraRecordingSession.java:173)
    at android.os.AsyncTask$2.call(AsyncTask.java:295)
    at java.util.concurrent.FutureTask.run(FutureTask.java:237)
    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) 
    at java.lang.Thread.run(Thread.java:818) 

    [ 05-21 13:03:44.109  9757:10315 D/         ]
    HostConnection::get() New Host Connection established 0xb307c1c0, tid 10315
  • Record video with Media Recorder in WEBM format

    21 mai 2017, par Matho

    I need to record two videos via media recorder and process them with ffmpeg in Android. I want to read videos via pipe in ffmpeg command string. From what I have read, I could not use 3GPP/MP4 format, because these formats contains header at the end of video. Because of it, I want to use WEBM video format, but my app is crashing, when I use webm/vp8 setting in media recorder. Ffmpeg I’m using is : com.writingminds:FFmpegAndroid:0.3.2. Could you help me please ?

    RecorderPrepareTask :

    class RecorderPrepareTask extends AsyncTask {
    private Context mContext;

    public RecorderPrepareTask(Context context) {
       mContext = context;
    }

    @Override
    protected Boolean doInBackground(Void... voids) {
       Timber.d("Starting screen recording...");

       if (!outputRoot.exists() && !outputRoot.mkdirs()) {
           Timber.e("Unable to create output directory '%s'.", outputRoot.getAbsolutePath());
           return false;
       }

       recorder = new MediaRecorder();
       recorder.setVideoSource(SURFACE);
       recorder.setOutputFormat(MediaRecorder.OutputFormat.WEBM);
       recorder.setVideoEncoder(MediaRecorder.VideoEncoder.VP8);
       recorder.setVideoSize(Config.VIDEO_SIZE_W, Config.VIDEO_SIZE_H);
       recorder.setVideoFrameRate(Config.FRAME_RATE);

       Timber.i("Output file '%s'.", outputFileName);
       recorder.setOutputFile(RecordingActivity.pipe[1].getFileDescriptor());


       try {
           recorder.prepare();
       } catch (IOException e) {
           throw new RuntimeException("Unable to prepare MediaRecorder.", e);
       }


       projection = projectionManager.getMediaProjection(resultCode, data);

       Surface surface = recorder.getSurface();
       display = projection.createVirtualDisplay(DISPLAY_NAME, Config.VIDEO_SIZE_W, Config.VIDEO_SIZE_H, 560, VIRTUAL_DISPLAY_FLAG_PRESENTATION, surface, null, null);

       recorder.start();

       return true;
    }

    @Override
    protected void onPostExecute(Boolean result) {

    }

    }

    getConvertCmd :

    private String getConvertCmd(){
       return "-re -r 30 -f webm -c:v vp8 -i pipe:"+ RecordingActivity.pipe[0].getFd() + " -threads 2 -preset ultrafast -profile:v main -level 3.1 -b:v 440k -ar 44100 -ab 128k -s "+ Config.CAMERA_VIDEO_SIZE_W + "x" + Config.CAMERA_VIDEO_SIZE_H + " -vcodec vp8 -acodec vorbis " + outputFileName3;
    }

    Logs :

    D/SoftVPXEncoder: VP8: internalSetAndroidVp8Params. BRMode: 0. TS: 0. KF: 24. QP: 0 - 0 BR0: 100. BR1: 0. BR2: 0
    I/ACodec: setupVideoEncoder succeeded
    E/OMXNodeInstance: setConfig(1a:google.vp8.encoder, ConfigPriority(0x6f800002)) ERROR: Undefined(0x80001001)
    I/ACodec: codec does not support config priority (err -2147483648)
    W/ACodec: do not know color format 0x7f000789 = 2130708361
    I/SoftMPEG4Encoder: Construct SoftMPEG4Encoder
    I/MediaCodec: MediaCodec will operate in async mode
    E/OMXNodeInstance: getParameter(1b:google.mpeg4.encoder, ParamVideoErrorCorrection(0x6000007)) ERROR: NotImplemented(0x80001006)
    I/ACodec: setupVideoEncoder succeeded
    E/OMXNodeInstance: setConfig(1b:google.mpeg4.encoder, ConfigPriority(0x6f800002)) ERROR: Undefined(0x80001001)
    I/ACodec: codec does not support config priority (err -2147483648)
    D/SoftVPXEncoder: VP8: initEncoder. BRMode: 0. TSLayers: 0. KF: 24. QP: 0 - 0
    I/AudioFlinger: AudioFlinger's thread 0xb2440000 ready to run
    xW/AudioFlinger: acquireAudioSessionId() unknown client 10079 for session 7
    I/MediaCodec: MediaCodec will operate in async mode
    /system_process I/DisplayManagerService: Display device added: DisplayDeviceInfo{"RMR": uniqueId="virtual:sk.matho.rocket_monkeys.rocketmonkeysrecorder,10052,RMR,0", 480 x 640, modeId 6, defaultModeId 6, supportedModes [{id=6, width=480, height=640, fps=60.0}], density 560, 560.0 x 560.0 dpi, appVsyncOff 0, presDeadline 16666666, touch NONE, rotation 0, type VIRTUAL, state ON, owner sk.matho.rocket_monkeys.rocketmonkeysrecorder (uid 10052), FLAG_PRIVATE, FLAG_PRESENTATION}
    E/OMXNodeInstance: setConfig(1c:google.amrnb.encoder, ConfigPriority(0x6f800002)) ERROR: Undefined(0x80001001)
    I/ACodec: codec does not support config priority (err -2147483648)
    E/WebmElement: mmap64 failed; errno = 22
    E/WebmElement: fd 18; flags: 1
    E/WebmElement: mmap64 failed; errno = 22
    E/WebmElement: fd 18; flags: 1
    E/WebmElement: mmap64 failed; errno = 22
    E/WebmElement: fd 18; flags: 1
    E/WebmElement: mmap64 failed; errno = 22
    E/WebmElement: fd 18; flags: 1
    E/WebmElement: mmap64 failed; errno = 22
    E/WebmElement: fd 18; flags: 1
    E/WebmElement: mmap64 failed; errno = 22
    E/WebmElement: fd 18; flags: 1
    D/gralloc_ranchu: gralloc_alloc: format 1 and usage 0x10003 imply creation of host color buffer
    I/MediaCodecSource: MediaCodecSource (video) starting
    I/MediaCodecSource: MediaCodecSource (video) started
    D/MPEG4Writer: Video track stopping
    E/MPEG4Writer: Stop() called but track is not started
    D/MPEG4Writer: Audio track stopping
    E/MPEG4Writer: Stop() called but track is not started

    [ 05-21 13:03:44.101  9757: 9766 D/         ]
    HostConnection::get() New Host Connection established 0xb344f140, tid 9766
    /sk.matho.rocket_monkeys.rocketmonkeysrecorder E/MediaRecorder: start failed: -2147483648                                                                                                  
    /sk.matho.rocket_monkeys.rocketmonkeysrecorder E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #2
    Process: sk.matho.rocket_monkeys.rocketmonkeysrecorder, PID: 10079
    java.lang.RuntimeException: An error occurred while executing doInBackground()
    at android.os.AsyncTask$3.done(AsyncTask.java:309)
    at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
    at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
    at java.util.concurrent.FutureTask.run(FutureTask.java:242)
    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
    at java.lang.Thread.run(Thread.java:818)
    Caused by: java.lang.RuntimeException: start failed.
    at android.media.MediaRecorder.start(Native Method)
    at sk.matho.rocket_monkeys.rocketmonkeysrecorder.recording.CameraRecordingSession$MediaPrepareTask.doInBackground(CameraRecordingSession.java:181)
    at sk.matho.rocket_monkeys.rocketmonkeysrecorder.recording.CameraRecordingSession$MediaPrepareTask.doInBackground(CameraRecordingSession.java:173)
    at android.os.AsyncTask$2.call(AsyncTask.java:295)
    at java.util.concurrent.FutureTask.run(FutureTask.java:237)
    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) 
    at java.lang.Thread.run(Thread.java:818) 

    [ 05-21 13:03:44.109  9757:10315 D/         ]
    HostConnection::get() New Host Connection established 0xb307c1c0, tid 10315