Search in sources :

Example 6 with Recording

use of org.apache.openmeetings.db.entity.record.Recording in project openmeetings by apache.

the class OmTreeProvider method createRoot.

static BaseFileItem createRoot(String name, String hash, boolean rec) {
    BaseFileItem f = rec ? new Recording() : new FileItem();
    f.setType(Type.Folder);
    f.setName(name);
    f.setHash(hash);
    return f;
}
Also used : BaseFileItem(org.apache.openmeetings.db.entity.file.BaseFileItem) FileItem(org.apache.openmeetings.db.entity.file.FileItem) BaseFileItem(org.apache.openmeetings.db.entity.file.BaseFileItem) Recording(org.apache.openmeetings.db.entity.record.Recording)

Example 7 with Recording

use of org.apache.openmeetings.db.entity.record.Recording in project openmeetings by apache.

the class BackupExport method exportRecording.

/*
	 * ##################### Recordings
	 */
private void exportRecording(ZipOutputStream zos, ProgressHolder progressHolder) throws Exception {
    List<Recording> list = recordingDao.get();
    Registry registry = new Registry();
    Strategy strategy = new RegistryStrategy(registry);
    Serializer serializer = new Persister(strategy);
    bindDate(registry, list);
    writeList(serializer, zos, "flvRecordings.xml", "flvrecordings", list);
    progressHolder.setProgress(70);
}
Also used : RegistryStrategy(org.simpleframework.xml.convert.RegistryStrategy) Strategy(org.simpleframework.xml.strategy.Strategy) RegistryStrategy(org.simpleframework.xml.convert.RegistryStrategy) Recording(org.apache.openmeetings.db.entity.record.Recording) Registry(org.simpleframework.xml.convert.Registry) Persister(org.simpleframework.xml.core.Persister) Serializer(org.simpleframework.xml.Serializer)

Example 8 with Recording

use of org.apache.openmeetings.db.entity.record.Recording in project openmeetings by apache.

the class CleanupHelper method getRecUnit.

public static CleanupEntityUnit getRecUnit(final RecordingDao recordDao) {
    File parent = OmFileHelper.getStreamsDir();
    List<File> invalid = new ArrayList<>();
    List<File> deleted = new ArrayList<>();
    int missing = 0;
    for (File f : list(hibernateDir, (dir, name) -> name.endsWith(EXTENSION_MP4))) {
        if (!f.isFile()) {
            log.warn("Recording found is not a file: " + f);
            continue;
        }
        String hash = f.getName().substring(0, f.getName().length() - EXTENSION_MP4.length() - 1);
        Recording item = recordDao.getByHash(hash);
        if (item == null) {
            add(invalid, hash);
        } else if (item.isDeleted()) {
            add(deleted, hash);
        }
    }
    for (Recording item : recordDao.get()) {
        if (!item.isDeleted() && item.getHash() != null && list(item.getHash()).length == 0) {
            missing++;
        }
    }
    return new CleanupEntityUnit(parent, invalid, deleted, missing) {

        private static final long serialVersionUID = 1L;

        @Override
        public void cleanup() throws IOException {
            String hiberPath = hibernateDir.getCanonicalPath();
            for (File f : list(getParent(), null)) {
                if (!f.getCanonicalPath().equals(hiberPath)) {
                    FileUtils.deleteQuietly(f);
                }
            }
            super.cleanup();
        }
    };
}
Also used : ArrayList(java.util.ArrayList) Recording(org.apache.openmeetings.db.entity.record.Recording) File(java.io.File)

Example 9 with Recording

use of org.apache.openmeetings.db.entity.record.Recording in project openmeetings by apache.

the class AbstractJob method processExpiringRecordings.

void processExpiringRecordings(boolean notified, BiConsumer<Recording, Long> consumer) {
    if (!isInitComplete()) {
        return;
    }
    for (Group g : groupDao.getLimited()) {
        for (Recording rec : recordingDao.getExpiring(g.getId(), g.getReminderDays(), notified)) {
            try {
                long days = g.getRecordingTtl() - ChronoUnit.DAYS.between(rec.getInserted().toInstant(), Instant.now());
                consumer.accept(rec, days);
            } catch (Exception e) {
                log.error("Uexpected exception while processing expiring recordings emails", e);
            }
        }
    }
}
Also used : Group(org.apache.openmeetings.db.entity.user.Group) Recording(org.apache.openmeetings.db.entity.record.Recording)

Example 10 with Recording

use of org.apache.openmeetings.db.entity.record.Recording in project openmeetings by apache.

the class InterviewConverter method startConversion.

public void startConversion(Long id, boolean reconversion, ReConverterParams rcv) {
    Recording r = null;
    try {
        r = recordingDao.get(id);
        log.debug("recording {}", r.getId());
        if (Strings.isEmpty(r.getHash())) {
            r.setHash(UUID.randomUUID().toString());
        }
        r.setStatus(Recording.Status.CONVERTING);
        r = recordingDao.update(r);
        ProcessResultList logs = new ProcessResultList();
        List<File> waveFiles = new ArrayList<>();
        File streamFolder = getStreamFolder(r);
        List<RecordingMetaData> metaDataList = metaDataDao.getAudioMetaDataByRecording(r.getId());
        stripAudioFirstPass(r, logs, waveFiles, streamFolder, metaDataList);
        // Merge Wave to Full Length
        File streamFolderGeneral = getStreamsHibernateDir();
        File wav = new File(streamFolder, String.format("INTERVIEW_%s_FINAL_WAVE.wav", r.getId()));
        deleteFileIfExists(wav);
        if (waveFiles.isEmpty()) {
            // create default Audio to merge it.
            // strip to content length
            File outputWav = new File(streamFolderGeneral, "one_second.wav");
            // Calculate delta at beginning
            double deltaPadding = diffSeconds(r.getRecordEnd(), r.getRecordStart());
            String[] cmdSox = new String[] { getPathToSoX(), outputWav.getCanonicalPath(), wav.getCanonicalPath(), "pad", "0", String.valueOf(deltaPadding) };
            logs.add(ProcessHelper.executeScript("generateSampleAudio", cmdSox));
        } else if (waveFiles.size() == 1) {
            wav = waveFiles.get(0);
        } else {
            String[] soxArgs;
            if (reconversion) {
                soxArgs = mergeAudioToWaves(waveFiles, wav, metaDataList, rcv);
            } else {
                soxArgs = mergeAudioToWaves(waveFiles, wav);
            }
            logs.add(ProcessHelper.executeScript("mergeAudioToWaves", soxArgs));
        }
        // Default Image for empty interview video pods
        final File defaultInterviewImageFile = new File(streamFolderGeneral, "default_interview_image.png");
        if (!defaultInterviewImageFile.exists()) {
            throw new ConversionException("defaultInterviewImageFile does not exist!");
        }
        final int flvWidth = 320;
        final int flvHeight = 260;
        // Merge Audio with Video / Calculate resulting FLV
        String[] pods = new String[2];
        boolean found = false;
        for (RecordingMetaData meta : metaDataList) {
            File flv = getRecordingMetaData(r.getRoomId(), meta.getStreamName());
            Integer pod = meta.getInteriewPodId();
            if (flv.exists() && pod != null && pod > 0 && pod < 3) {
                String path = flv.getCanonicalPath();
                /*
					 * CHECK FILE:
					 * ffmpeg -i rec_316_stream_567_2013_08_28_11_51_45.flv -v error -f null file.null
					 */
                String[] args = new String[] { getPathToFFMPEG(), "-y", "-i", path, // only input files with video will be treated as video sources
                "-an", "-v", "error", "-f", "null", "file.null" };
                ProcessResult res = ProcessHelper.executeScript("checkFlvPod_" + pod, args, true);
                logs.add(res);
                if (res.isOk()) {
                    long diff = diff(meta.getRecordStart(), meta.getRecording().getRecordStart());
                    if (diff != 0L) {
                        // stub to add
                        // ffmpeg -y -loop 1 -i /home/solomax/work/openmeetings/branches/3.0.x/dist/red5/webapps/openmeetings/streams/hibernate/default_interview_image.jpg -filter_complex '[0:0]scale=320:260' -c:v libx264 -t 00:00:29.059 -pix_fmt yuv420p out.flv
                        File podFB = new File(streamFolder, String.format("%s_pod_%s_blank.flv", meta.getStreamName(), pod));
                        String podPB = podFB.getCanonicalPath();
                        String[] argsPodB = new String[] { // 
                        getPathToFFMPEG(), // 
                        "-y", // 
                        "-loop", // 
                        "1", // 
                        "-i", // 
                        defaultInterviewImageFile.getCanonicalPath(), // 
                        "-filter_complex", // 
                        String.format("[0:0]scale=%1$d:%2$d", flvWidth, flvHeight), // 
                        "-c:v", // 
                        "libx264", // 
                        "-t", // 
                        formatMillis(diff), // 
                        "-pix_fmt", // 
                        "yuv420p", podPB };
                        logs.add(ProcessHelper.executeScript("blankFlvPod_" + pod, argsPodB));
                        // ffmpeg -y -i out.flv -i rec_15_stream_4_2014_07_15_20_41_03.flv -filter_complex '[0:0]setsar=1/1[sarfix];[1:0]scale=320:260,setsar=1/1[scale];[sarfix] [scale] concat=n=2:v=1:a=0 [v]' -map '[v]'  output1.flv
                        File podF = new File(streamFolder, OmFileHelper.getName(meta.getStreamName() + "_pod_" + pod, EXTENSION_FLV));
                        String podP = podF.getCanonicalPath();
                        String[] argsPod = new String[] { // 
                        getPathToFFMPEG(), // 
                        "-y", // 
                        "-i", // 
                        podPB, // 
                        "-i", // 
                        path, // 
                        "-filter_complex", // 
                        String.format("[0:0]setsar=1/1[sarfix];[1:0]scale=%1$d:%2$d,setsar=1/1[scale];[sarfix] [scale] concat=n=2:v=1:a=0 [v]", flvWidth, flvHeight), // 
                        "-map", // 
                        "[v]", podP };
                        logs.add(ProcessHelper.executeScript("shiftedFlvPod_" + pod, argsPod));
                        pods[pod - 1] = podP;
                    } else {
                        pods[pod - 1] = path;
                    }
                }
                found = true;
            }
        }
        if (!found) {
            ProcessResult res = new ProcessResult();
            res.setProcess("CheckFlvFilesExists");
            res.setError("No valid pods found");
            res.setExitCode(-1);
            logs.add(res);
            return;
        }
        boolean shortest = false;
        List<String> args = new ArrayList<>();
        for (int i = 0; i < 2; ++i) {
            /*
				 * INSERT BLANK INSTEAD OF BAD PAD:
				 * ffmpeg -loop 1 -i default_interview_image.jpg -i rec_316_stream_569_2013_08_28_11_51_45.flv -filter_complex '[0:v]scale=320:260,pad=2*320:260[left];[1:v]scale=320:260[right];[left][right]overlay=main_w/2:0' -shortest -y out4.flv
				 *
				 * JUST MERGE:
				 * ffmpeg -i rec_316_stream_569_2013_08_28_11_51_45.flv -i rec_316_stream_569_2013_08_28_11_51_45.flv -filter_complex '[0:v]scale=320:260,pad=2*320:260[left];[1:v]scale=320:260[right];[left][right]overlay=main_w/2:0' -y out4.flv
				 */
            if (pods[i] == null) {
                shortest = true;
                args.add("-loop");
                args.add("1");
                args.add("-i");
                args.add(defaultInterviewImageFile.getCanonicalPath());
            } else {
                args.add("-i");
                args.add(pods[i]);
            }
        }
        args.add("-i");
        args.add(wav.getCanonicalPath());
        args.add("-filter_complex");
        args.add(String.format("[0:v]scale=%1$d:%2$d,pad=2*%1$d:%2$d[left];[1:v]scale=%1$d:%2$d[right];[left][right]overlay=main_w/2:0%3$s", flvWidth, flvHeight, shortest ? ":shortest=1" : ""));
        if (shortest) {
            args.add("-shortest");
        }
        args.add("-map");
        args.add("0:0");
        args.add("-map");
        args.add("1:0");
        args.add("-map");
        args.add("2:0");
        args.add("-qmax");
        args.add("1");
        args.add("-qmin");
        args.add("1");
        r.setWidth(2 * flvWidth);
        r.setHeight(flvHeight);
        String mp4path = convertToMp4(r, args, logs);
        postProcess(r, mp4path, logs, waveFiles);
    } catch (Exception err) {
        log.error("[startConversion]", err);
        r.setStatus(Recording.Status.ERROR);
    }
    recordingDao.update(r);
}
Also used : ArrayList(java.util.ArrayList) ProcessResult(org.apache.openmeetings.util.process.ProcessResult) IOException(java.io.IOException) ProcessResultList(org.apache.openmeetings.util.process.ProcessResultList) OmFileHelper.getRecordingMetaData(org.apache.openmeetings.util.OmFileHelper.getRecordingMetaData) RecordingMetaData(org.apache.openmeetings.db.entity.record.RecordingMetaData) Recording(org.apache.openmeetings.db.entity.record.Recording) File(java.io.File)

Aggregations

Recording (org.apache.openmeetings.db.entity.record.Recording)19 ArrayList (java.util.ArrayList)4 RecordingMetaData (org.apache.openmeetings.db.entity.record.RecordingMetaData)4 User (org.apache.openmeetings.db.entity.user.User)4 File (java.io.File)3 BaseFileItem (org.apache.openmeetings.db.entity.file.BaseFileItem)3 FileItem (org.apache.openmeetings.db.entity.file.FileItem)3 Room (org.apache.openmeetings.db.entity.room.Room)3 OmFileHelper.getRecordingMetaData (org.apache.openmeetings.util.OmFileHelper.getRecordingMetaData)2 ProcessResultList (org.apache.openmeetings.util.process.ProcessResultList)2 PageParameters (org.apache.wicket.request.mapper.parameter.PageParameters)2 Test (org.junit.Test)2 Serializer (org.simpleframework.xml.Serializer)2 Registry (org.simpleframework.xml.convert.Registry)2 RegistryStrategy (org.simpleframework.xml.convert.RegistryStrategy)2 Persister (org.simpleframework.xml.core.Persister)2 Strategy (org.simpleframework.xml.strategy.Strategy)2 JQueryBehavior (com.googlecode.wicket.jquery.core.JQueryBehavior)1 DialogButton (com.googlecode.wicket.jquery.ui.widget.dialog.DialogButton)1 MessageDialog (com.googlecode.wicket.jquery.ui.widget.dialog.MessageDialog)1