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.(Lorg/apache/http/conn/scheme/SchemeRegistry;Lorg/apache/http/conn/DnsResolver;)V: java.lang.NoSuchMethodError: org.apache.http.impl.conn.DefaultClientConnectionOperator.(Lorg/apache/http/conn/scheme/SchemeRegistry;Lorg/apache/http/conn/DnsResolver;)V|at org.apache.http.impl.conn.PoolingClientConnectionManager.createConnectionOperator(PoolingClientConnectionManager.java:138)|at org.apache.http.impl.conn.PoolingClientConnectionManager.(PoolingClientConnectionManager.java:112)|at org.apache.http.impl.conn.PoolingClientConnectionManager.(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

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

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

Regards,

Salvadore

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

bucketName

MY_BUCKET_NAME

region

MY_REGION (for example eu-west-1)

s3_folder

MY_S3_FOLDER

access_key_id

MY_S3_ACCESS_KEY

secret_access_key

MY_S3_SECRET

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