Search in sources :

Example 1 with UnsupportedBitRateCompression

use of com.bixly.pastevid.recorders.UnsupportedBitRateCompression in project screenbird by adamhub.

the class RecorderPanel method prepareVideo.

/**
     * Processes all images captured to create a Quicktime movie.
     */
public void prepareVideo() {
    this.showUploadForm();
    this.setEnableUploadForm(false);
    this.btnUpload.setEnabled(true);
    this.showUploadMessage("Processing Video...", MESSAGE_INFO);
    Boolean movieCreated = false;
    JFrame jf = (JFrame) RecorderPanel.this.getTopLevelAncestor();
    jf.setTitle("Screen Recorder - Processing Video...");
    // Place in encoding state
    this.isEncoding = true;
    this.pbEncoding.setIndeterminate(true);
    this.pbEncoding.setStringPainted(false);
    this.showUploadMessage("Rendering Video...", MESSAGE_INFO);
    // Converts screen shots to video file
    try {
        movieCreated = recorder.compileVideo();
    } catch (Exception e) {
        log(e);
    }
    // Converts audio clips to single audio file
    if (recorder.hasAudioToCompile()) {
        this.showUploadMessage("Rendering Audio...", MESSAGE_INFO);
        recorder.compileAudio();
        while (recorder.isWaitingForAudio()) {
            // we need to wait for the audio file.
            TimeUtil.skipToMyLou(0.1);
        }
    }
    // Check for ffmpeg executable on the computer
    // Download if not yet available
    DownloadThread ffmpegDownload = DownloadManager.getInstance().getDownload(Settings.getFFMpegExecutable());
    if (!ffmpegDownload.checkStatus(DownloadStatus.FINISHED)) {
        this.pbEncoding.setIndeterminate(true);
        this.pbEncoding.setStringPainted(false);
        this.showUploadMessage("Preparing Files", MESSAGE_INFO);
    }
    // Wait for ffmpeg download to finish
    while (!ffmpegDownload.checkStatus(DownloadStatus.FINISHED)) {
        TimeUtil.skipToMyLouMS(500L);
        log("Current Status :" + ffmpegDownload.getStatus());
    }
    this.pbEncoding.setIndeterminate(false);
    this.pbEncoding.setStringPainted(true);
    jf.setTitle("Screen Recorder - Done.");
    // Encode video/audio
    if (movieCreated) {
        try {
            int numOfTasks = 1;
            // Assign number of tasks via the operating system of the client
            if (recorder.hasPreviousCompiledVideo()) {
                numOfTasks = (MediaUtil.osIsMac() || MediaUtil.osIsUnix()) ? 5 : 4;
            }
            if (this.scrubManager.isVideoEdited()) {
                numOfTasks += (4 + this.scrubManager.getScrubs().size());
            }
            // Set up encoding progress bar
            this.pbEncodingListener = new FFMpegProgressBarListener(pbEncoding, numOfTasks, FFMpegProgressBarListener.FFMPEG);
            this.showUploadMessage("Encoding Video...", MESSAGE_INFO);
            // Encode the video
            this.recordingOutput = FileUtil.encodeVideoMp4(recorder.getFile(), recorder.getOffset(), recorder.getBitRateCompresion(), this.pbEncodingListener);
            // Append to previously rendered video if continuing
            if (recorder.hasPreviousCompiledVideo()) {
                this.recordingOutput = FileUtil.mergeVideoMp4(recorder.getPrevVideoFileName(), this.recordingOutput, this.pbEncodingListener);
            }
            this.recorder.setResultVideoPath(this.recordingOutput);
            log("Compiled Video Location: " + this.recordingOutput);
        } catch (FileNotFoundException ex) {
            log(ex);
        } catch (IOException ex) {
            log(ex);
        } catch (UnsupportedBitRateCompression e) {
            log(e);
        }
        // Disable scrub feature for resuming previous recordings
        if (this.scrubManager != null && this.scrubManager.isVideoEdited() && !this.recorder.hasPreviousCompiledVideo()) {
            // Give it a few seconds for the video to finish encoding
            TimeUtil.skipToMyLou(3);
            this.scrubManager.scrubVideo(this.recordingOutput, this.pbEncodingListener);
        }
        this.setEnableUploadForm(true);
        // Mark applet as a non-encoding state
        this.isEncoding = false;
        // Start uploading copy if auto-upload is checked
        if (this.chkAutoUpload.isSelected()) {
            // Disable checkbox since is useless after encoding is done
            this.chkAutoUpload.setEnabled(false);
            this.btnUpload.setEnabled(false);
            FileUtil.removeMarker(UPLOAD_ON_ENCODE);
            // Wait a few seconds for client's system to catch up
            TimeUtil.skipToMyLou(5);
            uploadCopy();
        }
        // Set progress bar to 100%
        this.pbEncoding.setValue(pbEncoding.getMaximum());
        this.showUploadMessage("Ready for upload", MESSAGE_OK);
    } else {
        this.showRecorderMessage("Error processing video.", MESSAGE_ERROR);
        log("Movie not compiled properly.");
    }
}
Also used : DownloadThread(com.bixly.pastevid.download.DownloadThread) JFrame(javax.swing.JFrame) FileNotFoundException(java.io.FileNotFoundException) UnsupportedBitRateCompression(com.bixly.pastevid.recorders.UnsupportedBitRateCompression) IOException(java.io.IOException) MissingResourceException(java.util.MissingResourceException) FileNotFoundException(java.io.FileNotFoundException) LineUnavailableException(javax.sound.sampled.LineUnavailableException) IOException(java.io.IOException) FFMpegProgressBarListener(com.bixly.pastevid.screencap.components.progressbar.FFMpegProgressBarListener)

Aggregations

DownloadThread (com.bixly.pastevid.download.DownloadThread)1 UnsupportedBitRateCompression (com.bixly.pastevid.recorders.UnsupportedBitRateCompression)1 FFMpegProgressBarListener (com.bixly.pastevid.screencap.components.progressbar.FFMpegProgressBarListener)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 MissingResourceException (java.util.MissingResourceException)1 LineUnavailableException (javax.sound.sampled.LineUnavailableException)1 JFrame (javax.swing.JFrame)1