Results 1 to 4 of 4

Thread: Wowza upload recorded stream to S3

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2014
    Posts
    4

    Default Wowza upload recorded stream to S3

    Hello I created and application that upload to S3 after writing

    But I have a problem with the libraries.

    I'm using aws-java-sdk-1.9.10.jar (tested too with the last one aws-java-sdk-1.9.30.jar ) and added 2 jars httpclient-4.3.6.jar and httpcore-4.3.3.jar
    Then when I try to upload shows an error

    java.lang.NoSuchMethodError: org.apache.http.impl.conn.DefaultClientConnectionOperator.<init>(Lorg/apache/http/conn/scheme/SchemeRegistry;Lorg/apache/http/conn/DnsResolverV: java.lang.NoSuchMethodError: org.apache.http.impl.conn.DefaultClientConnectionOperator.<init>(Lorg/apache/http/conn/scheme/SchemeRegistry;Lorg/apache/http/conn/DnsResolverV|at org.apache.http.impl.conn.PoolingClientConnectionManager.createConnectionOperator(PoolingClientConne ctionManager.java:138)|at org.apache.http.impl.conn.PoolingClientConnectionManager.<init>(PoolingClientConnectionManager.java: 112)|at org.apache.http.impl.conn.PoolingClientConnectionManager.<init>(PoolingClientConnectionManager.java: 101)|at com.amazonaws.http.ConnectionManagerFactory.createPoolingClientConnManager(ConnectionManagerFactory. java:29)|at com.amazonaws.http.HttpClientFactory.createHttpClient(HttpClientFactory.java:104)|


    The problem is the wms-restlet-2.1.jar has a old version of some of classes of httpclient-4.3.6.jar.

    I'm using Wowza 4.0.4, it is solved in the 4.1.2? Or there are any solution to that?

    Bests regards

  2. #2

    Default

    Hello there.

    Are you creating your own module for moving these files or are you using the built in file mover?
    How to move recordings from live streams (ModuleMediaWriterFileMover)

    It is not clear exactly how you are implementing this workflow and so it is hard to tell where the problem is.

    Can you please provide more detail about your workflow?

    Thank you.

    Salvadore

  3. #3
    Join Date
    Mar 2014
    Posts
    4

    Default

    Hello Salvatore, yes I developed a module based on ModuleMediaWriterFileMover.

    I found the solution, upgrade to the last version of Wowza

    My Code is like (I hove somebody we will reuse it!)

    Application XML add

    <!-- Properties defined here will be added to the IApplication.getProperties() and IApplicationInstance.getProperties() collections -->
    <Properties>
    <Property>
    <Name>bucketName</Name>
    <Value>MY_BUCKET_NAME</Value>
    </Property>
    <Property>
    <Name>region</Name>
    <Value>MY_REGION (for example eu-west-1)</Value>
    </Property>
    <Property>
    <Name>s3_folder</Name>
    <Value>MY_S3_FOLDER</Value>
    </Property>
    <Property>
    <Name>access_key_id</Name>
    <Value>MY_S3_ACCESS_KEY</Value>
    </Property>
    <Property>
    <Name>secret_access_key</Name>
    <Value>MY_S3_SECRET</Value>
    </Property>
    </Properties>

    New Module

    public class UploadToS3 extends ModuleBase {

    public void onAppStart(IApplicationInstance appInstance) {

    _appInstance = appInstance;

    WMSProperties props = appInstance.getProperties();

    String access_key_id = props.getPropertyStr("access_key_id", null);
    String bucketName = props.getPropertyStr("bucketName", null);
    String secret_access_key = props.getPropertyStr("secret_access_key", null);
    getLogger().info("Videochat on app es bucketName "+bucketName);

    if (access_key_id!=null) {
    String region = props.getPropertyStr("region", null);
    String s3_folder = props.getPropertyStr("s3_folder", null);
    String fileMoverFileExtension = props.getPropertyStr("fileMoverFileExtension", null);
    boolean fileMoverDeleteOriginal = props.getPropertyBoolean("fileMoverDeleteOriginal", false);
    appInstance.addMediaWriterListener(new WriteListener( bucketName, region, s3_folder, access_key_id, secret_access_key,
    fileMoverFileExtension,
    fileMoverDeleteOriginal));
    }
    }

    class WriteListener implements IMediaWriterActionNotify
    {
    private String bucketName = null;
    private String access_key_id = null;
    private String secret_access_key = null;
    private String s3_folder = null;
    private String region = null;
    private String fileMoverFileExtension = null;
    private boolean fileMoverDeleteOriginal = false;



    public WriteListener(String bucketName, String region, String s3_folder, String access_key_id, String secret_access_key, String fileMoverFileExtension,
    boolean fileMoverDeleteOriginal) {
    this.bucketName = bucketName;
    this.region = region;
    this.s3_folder = s3_folder;
    this.access_key_id = access_key_id;
    this.secret_access_key = secret_access_key;
    this.fileMoverFileExtension = fileMoverFileExtension;
    this.fileMoverDeleteOriginal = fileMoverDeleteOriginal;
    }


    /**
    * Onwrite complete move the file
    */
    public void onWriteComplete(IMediaStream stream, File file)
    {
    try {

    //using S3
    if (bucketName!=null && access_key_id != null && secret_access_key!= null) {
    Thread t = new Thread(new MoverThreadS3(bucketName, region, s3_folder, access_key_id, secret_access_key,
    fileMoverFileExtension,
    file, stream));
    getLogger().warn(" STARTED!!!");
    t.start();
    }
    } catch (Throwable e){
    getLogger().error("onWriteComplete - ERROR - ModuleMediaWriterFileMoverS3.onWriteComplete[version]: : "+e.toString(), e);
    }
    }

    public void onFLVAddMetadata(IMediaStream stream, Map<String, Object> extraMetadata)
    {
    }
    }

    private static class MoverThreadS3
    implements Runnable {
    private String bucketName = null;
    private String region = null;
    private String s3_folder = null;
    private String access_key_id = null;
    private String secret_access_key = null;
    private String fileMoverFileExtension = null;
    private File file;
    private IMediaStream stream;

    public MoverThreadS3(String bucketName, String region, String s3_folder, String access_key_id, String secret_access_key,
    String fileMoverFileExtension,
    File file, IMediaStream stream) {
    this.bucketName = bucketName ;
    this.region = region;
    this.s3_folder = s3_folder;
    this.access_key_id = access_key_id ;
    this.secret_access_key = secret_access_key;
    this.fileMoverFileExtension = fileMoverFileExtension;
    this.file = file;
    this.stream = stream;
    }

    public void run() {

    if (bucketName !=null && access_key_id != null && secret_access_key !=null)
    {
    try {
    BasicAWSCredentials awsCreds = new BasicAWSCredentials(access_key_id, secret_access_key);
    AmazonS3 s3 = null;
    String streamExt = getExtension(stream, fileMoverFileExtension);

    String key = stream.getName();
    if (!key.endsWith("."+streamExt)) {
    key += "."+streamExt;
    }
    if (s3_folder!=null && s3_folder.length()>0){
    key = s3_folder + "/" +key;
    }

    s3 = new AmazonS3Client(awsCreds);
    if (region!=null){
    Region customRegion = Region.getRegion(Regions.fromName(region));
    //s3.setEndpoint(customRegion.getServiceEndpoint(ServiceAbbreviations.S3));

    s3.setRegion(customRegion);
    }

    s3.putObject(new PutObjectRequest(bucketName, key,
    file));

    boolean deleted = file.delete();

    if (deleted) {
    getLogger().info("Thread Videochat - ModuleMediaWriterFileMoverS3.onWriteComplete[version]: S3 uploaded "+key+" SUCESSFULLY and deleted!!!");
    } else {
    getLogger().warn("Thread Videochat - ModuleMediaWriterFileMoverS3.onWriteComplete[version]: S3 uploaded "+key+" SUCESSFULLY and but can't deleted it!!! "+file.getAbsolutePath());
    }
    }
    catch(Throwable e)
    {
    getLogger().error("Thread Videochat - ERROR - ModuleMediaWriterFileMoverS3.onWriteComplete[version]: : "+e.toString(), e);
    }
    } else {
    getLogger().warn("Thread Videochat - WARN - ModuleMediaWriterFileMoverS3.onWriteComplete missing some required parameter : bucketName is not null: "+(bucketName !=null)+". access_key_id is not null: " + (access_key_id != null) + ". secret_access_key is not null: "+ (secret_access_key !=null));
    }
    }

    private static String getExtension(IMediaStream stream, String ext)
    {
    if (ext == null)
    {
    String mediaReaderType = stream.getExt().toLowerCase();
    MediaReaderItem mediaReaderItem = stream.getStreams().getVHost().getMediaReaders().getMediaReaderDef(mediaReaderType);
    return mediaReaderItem.getFileExtension();
    }

    return ext;
    }
    }
    }

    You will need 3 jars: the latest version of AWS Java (http://aws.amazon.com/sdk-for-java/), httpclient-4.3.6.jar and httpcore-4.3.3.jar

    Best regards
    Last edited by abertranb; 04-16-2015 at 12:03 AM.

  4. #4

    Default

    Okay great! I am glad you have this working and thanks for sharing your workflow.

    Regards,

    Salvadore

Similar Threads

  1. how to upload file by wowza API?
    By liqz2009 in forum Wowza Streaming Server Java API
    Replies: 2
    Last Post: 01-07-2015, 06:09 PM
  2. Workflow to Upload mp3s for Wowza Playback
    By skelleex in forum Integrating Wowza into your workflow
    Replies: 2
    Last Post: 06-21-2014, 10:30 PM
  3. Max upload - bitrate, fps and resolution to Wowza
    By Padre2k in forum General Forum
    Replies: 6
    Last Post: 04-14-2012, 09:29 PM
  4. Upload Stream from iOS Device
    By ankitthakur85 in forum Server-side Modules and Code Samples Discussion
    Replies: 5
    Last Post: 12-26-2011, 07:58 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •