Search in sources :

Example 11 with VideoStreamImpl

use of org.opencastproject.mediapackage.track.VideoStreamImpl in project opencast by opencast.

the class MediaInspector method addVideoStreamMetadata.

/**
 * Adds the video related metadata to the track.
 *
 * @param track
 *          the track
 * @param metadata
 *          the container metadata
 * @throws Exception
 *           Media analysis is fragile, and may throw any kind of runtime exceptions due to inconsistencies in the
 *           media's metadata
 */
private Track addVideoStreamMetadata(TrackImpl track, MediaContainerMetadata metadata) throws Exception {
    List<VideoStreamMetadata> videoList = metadata.getVideoStreamMetadata();
    if (videoList != null && !videoList.isEmpty()) {
        for (int i = 0; i < videoList.size(); i++) {
            VideoStreamImpl video = new VideoStreamImpl("video-" + (i + 1));
            VideoStreamMetadata v = videoList.get(i);
            video.setBitRate(v.getBitRate());
            video.setFormat(v.getFormat());
            video.setFormatVersion(v.getFormatVersion());
            video.setFrameCount(v.getFrames());
            video.setFrameHeight(v.getFrameHeight());
            video.setFrameRate(v.getFrameRate());
            video.setFrameWidth(v.getFrameWidth());
            video.setScanOrder(v.getScanOrder());
            video.setScanType(v.getScanType());
            // TODO: retain the original video metadata
            track.addStream(video);
        }
    }
    return track;
}
Also used : VideoStreamMetadata(org.opencastproject.inspection.ffmpeg.api.VideoStreamMetadata) VideoStreamImpl(org.opencastproject.mediapackage.track.VideoStreamImpl)

Example 12 with VideoStreamImpl

use of org.opencastproject.mediapackage.track.VideoStreamImpl in project opencast by opencast.

the class PartialImportWorkflowOperationHandlerTest method testDetermineDimension.

@Test
public void testDetermineDimension() throws Exception {
    // Setup tracks
    VideoStreamImpl videoStream = new VideoStreamImpl("test1");
    videoStream.setFrameWidth(80);
    videoStream.setFrameHeight(30);
    VideoStreamImpl videoStream2 = new VideoStreamImpl("test2");
    videoStream2.setFrameWidth(101);
    videoStream2.setFrameHeight(50);
    TrackImpl videoTrack = new TrackImpl();
    videoTrack.setURI(URI.create("/test"));
    videoTrack.setVideo(Collections.list((VideoStream) videoStream));
    TrackImpl videoTrack2 = new TrackImpl();
    videoTrack2.setURI(URI.create("/test"));
    videoTrack2.setVideo(Collections.list((VideoStream) videoStream2));
    List<Track> tracks = Collections.list((Track) videoTrack, (Track) videoTrack2);
    EncodingProfileImpl encodingProfile = new EncodingProfileImpl();
    encodingProfile.setIdentifier("test");
    ComposerService composerService = EasyMock.createMock(ComposerService.class);
    EasyMock.expect(composerService.concat(encodingProfile.getIdentifier(), Dimension.dimension(101, 50), tracks.toArray(new Track[tracks.size()]))).andReturn(null).once();
    EasyMock.expect(composerService.concat(encodingProfile.getIdentifier(), Dimension.dimension(100, 50), tracks.toArray(new Track[tracks.size()]))).andReturn(null).once();
    EasyMock.replay(composerService);
    PartialImportWorkflowOperationHandler handler = new PartialImportWorkflowOperationHandler();
    handler.setComposerService(composerService);
    handler.startConcatJob(encodingProfile, tracks, -1.0F, false);
    handler.startConcatJob(encodingProfile, tracks, -1.0F, true);
}
Also used : TrackImpl(org.opencastproject.mediapackage.track.TrackImpl) ComposerService(org.opencastproject.composer.api.ComposerService) VideoStream(org.opencastproject.mediapackage.VideoStream) VideoStreamImpl(org.opencastproject.mediapackage.track.VideoStreamImpl) EncodingProfileImpl(org.opencastproject.composer.api.EncodingProfileImpl) Track(org.opencastproject.mediapackage.Track) Test(org.junit.Test)

Example 13 with VideoStreamImpl

use of org.opencastproject.mediapackage.track.VideoStreamImpl in project opencast by opencast.

the class SmilServiceImplTest method testAddClipWithInvalidTrackURI.

@Test(expected = SmilException.class)
public void testAddClipWithInvalidTrackURI() throws Exception {
    TrackImpl videoTrack = new TrackImpl();
    videoTrack.setIdentifier("track-1");
    videoTrack.setFlavor(new MediaPackageElementFlavor("source", "presentation"));
    videoTrack.addStream(new VideoStreamImpl());
    videoTrack.setDuration(Long.MAX_VALUE);
    // no track URI set
    SmilResponse smilResponse = smilService.createNewSmil();
    smilResponse = smilService.addClip(smilResponse.getSmil(), null, videoTrack, 0, 10);
    fail("SmilException schould be thrown if you try to add an invalid track.");
}
Also used : TrackImpl(org.opencastproject.mediapackage.track.TrackImpl) SmilResponse(org.opencastproject.smil.api.SmilResponse) VideoStreamImpl(org.opencastproject.mediapackage.track.VideoStreamImpl) MediaPackageElementFlavor(org.opencastproject.mediapackage.MediaPackageElementFlavor) Test(org.junit.Test)

Example 14 with VideoStreamImpl

use of org.opencastproject.mediapackage.track.VideoStreamImpl in project opencast by opencast.

the class SmilServiceImplTest method testAddClipWithParamGroupId.

/**
 * passing a previously created paramGroupId
 */
@Test
public void testAddClipWithParamGroupId() throws Exception {
    // first, create SMIL with 1 par, 1 video
    TrackImpl videoTrack = new TrackImpl();
    videoTrack.setIdentifier("presenter-track-1");
    videoTrack.setFlavor(new MediaPackageElementFlavor("source", "presenter"));
    videoTrack.setURI(new URI("http://hostname/video.mp4"));
    videoTrack.addStream(new VideoStreamImpl());
    videoTrack.setDuration(1000000000000L);
    SmilResponse smilResponse = smilService.createNewSmil();
    smilResponse = smilService.addParallel(smilResponse.getSmil());
    SmilMediaContainer par = (SmilMediaContainer) smilResponse.getEntity();
    // add video track into parallel element
    smilResponse = smilService.addClip(smilResponse.getSmil(), par.getId(), videoTrack, 1000L, 1000000L);
    SmilMediaObject media = null;
    for (SmilObject entity : smilResponse.getEntities()) {
        if (entity instanceof SmilMediaObject) {
            media = (SmilMediaObject) entity;
            break;
        }
    }
    assertNotNull(media);
    assertEquals(media.getId(), ((SmilMediaContainer) smilResponse.getSmil().getBody().getMediaElements().get(0)).getElements().get(0).getId());
    assertTrue(media instanceof SmilMediaVideoImpl);
    assertSame(((SmilMediaElement) media).getMediaType(), SmilMediaElement.MediaType.VIDEO);
    // 1000 milliseconds = 1 second
    assertEquals(1000L, ((SmilMediaElement) media).getClipBeginMS());
    // duration is 1000000 milliseconds = 1000 soconds
    // start + duration = 1s + 1000s = 1001s
    assertEquals(1001000L, ((SmilMediaElement) media).getClipEndMS());
    // get param group id
    List<SmilMediaParamGroup> groups = smilResponse.getSmil().getHead().getParamGroups();
    assertEquals(1, groups.size());
    String paramGroupId = groups.get(0).getId();
    // then, create a 2nd par with 1 video with the same param group id
    TrackImpl videoTrack2 = new TrackImpl();
    videoTrack2.setIdentifier("presenter-track-2");
    videoTrack2.setFlavor(new MediaPackageElementFlavor("source2", "presenter"));
    videoTrack2.setURI(new URI("http://hostname/video2.mp4"));
    videoTrack2.addStream(new VideoStreamImpl());
    videoTrack2.setDuration(2000000000000L);
    smilResponse = smilService.addParallel(smilResponse.getSmil());
    SmilMediaContainer par2 = null;
    for (SmilObject entity : smilResponse.getEntities()) {
        if (entity instanceof SmilMediaContainer && !entity.getId().equals(par.getId())) {
            par2 = (SmilMediaContainer) entity;
            break;
        }
    }
    // add video track into parallel element
    smilResponse = smilService.addClip(smilResponse.getSmil(), par2.getId(), videoTrack2, 2000L, 2000000L, paramGroupId);
    SmilMediaObject media2 = null;
    for (SmilObject entity : smilResponse.getEntities()) {
        if (entity instanceof SmilMediaObject && !entity.getId().equals(media.getId())) {
            media2 = (SmilMediaObject) entity;
            break;
        }
    }
    assertNotNull(media2);
    SmilMediaElement mediaElement2 = (SmilMediaElement) ((SmilMediaContainer) smilResponse.getSmil().getBody().getMediaElements().get(1)).getElements().get(0);
    assertEquals(media2.getId(), mediaElement2.getId());
    assertTrue(media2 instanceof SmilMediaVideoImpl);
    assertSame(((SmilMediaElement) media2).getMediaType(), SmilMediaElement.MediaType.VIDEO);
    // 1000 milliseconds = 1 second
    assertEquals(2000L, ((SmilMediaElement) media2).getClipBeginMS());
    // duration is 2000000 milliseconds = 2000 seconds
    // start + duration = 2s + 2000s = 2002s
    assertEquals(2002000L, ((SmilMediaElement) media2).getClipEndMS());
    // make sure there's still 1 param group
    groups = smilResponse.getSmil().getHead().getParamGroups();
    assertEquals(1, groups.size());
    // make sure that the media element has the previous param groupo id
    assertEquals(paramGroupId, mediaElement2.getParamGroup());
}
Also used : SmilMediaVideoImpl(org.opencastproject.smil.entity.media.element.SmilMediaVideoImpl) TrackImpl(org.opencastproject.mediapackage.track.TrackImpl) SmilObject(org.opencastproject.smil.entity.api.SmilObject) VideoStreamImpl(org.opencastproject.mediapackage.track.VideoStreamImpl) MediaPackageElementFlavor(org.opencastproject.mediapackage.MediaPackageElementFlavor) URI(java.net.URI) SmilResponse(org.opencastproject.smil.api.SmilResponse) SmilMediaObject(org.opencastproject.smil.entity.media.api.SmilMediaObject) SmilMediaElement(org.opencastproject.smil.entity.media.element.api.SmilMediaElement) SmilMediaParamGroup(org.opencastproject.smil.entity.media.param.api.SmilMediaParamGroup) SmilMediaContainer(org.opencastproject.smil.entity.media.container.api.SmilMediaContainer) Test(org.junit.Test)

Example 15 with VideoStreamImpl

use of org.opencastproject.mediapackage.track.VideoStreamImpl in project opencast by opencast.

the class SmilServiceImplTest method testAddClipStartValueBiggerThanDuration.

@Test(expected = SmilException.class)
public void testAddClipStartValueBiggerThanDuration() throws Exception {
    TrackImpl videoTrack = new TrackImpl();
    videoTrack.setIdentifier("track-1");
    videoTrack.setFlavor(new MediaPackageElementFlavor("source", "presentation"));
    videoTrack.setURI(new URI("http://hostname/video.mp4"));
    videoTrack.addStream(new VideoStreamImpl());
    videoTrack.setDuration(new Long(1000));
    SmilResponse smilResponse = smilService.createNewSmil();
    smilResponse = smilService.addClip(smilResponse.getSmil(), null, videoTrack, 1000, 10);
    fail("Sequence start value is equal track duration but SmilService does not throw an SmilException.");
}
Also used : TrackImpl(org.opencastproject.mediapackage.track.TrackImpl) SmilResponse(org.opencastproject.smil.api.SmilResponse) VideoStreamImpl(org.opencastproject.mediapackage.track.VideoStreamImpl) MediaPackageElementFlavor(org.opencastproject.mediapackage.MediaPackageElementFlavor) URI(java.net.URI) Test(org.junit.Test)

Aggregations

VideoStreamImpl (org.opencastproject.mediapackage.track.VideoStreamImpl)17 TrackImpl (org.opencastproject.mediapackage.track.TrackImpl)12 Test (org.junit.Test)9 URI (java.net.URI)7 MediaPackageElementFlavor (org.opencastproject.mediapackage.MediaPackageElementFlavor)7 SmilResponse (org.opencastproject.smil.api.SmilResponse)6 AudioStreamImpl (org.opencastproject.mediapackage.track.AudioStreamImpl)4 BeforeClass (org.junit.BeforeClass)3 MediaPackage (org.opencastproject.mediapackage.MediaPackage)3 SmilMediaObject (org.opencastproject.smil.entity.media.api.SmilMediaObject)3 SmilMediaContainer (org.opencastproject.smil.entity.media.container.api.SmilMediaContainer)3 SmilMediaElement (org.opencastproject.smil.entity.media.element.api.SmilMediaElement)3 WorkflowInstance (org.opencastproject.workflow.api.WorkflowInstance)3 ArrayList (java.util.ArrayList)2 JobContext (org.opencastproject.job.api.JobContext)2 Track (org.opencastproject.mediapackage.Track)2 VideoStream (org.opencastproject.mediapackage.VideoStream)2 AccessControlList (org.opencastproject.security.api.AccessControlList)2 Field (com.entwinemedia.fn.data.json.Field)1 JValue (com.entwinemedia.fn.data.json.JValue)1