5

I am using red5 for streaming videos in my project and I am able to play the videos from the local system which are saved in default folder "streams".

Now i want to customize the path and want to get the videos from S3. How do i configure red5 to work with S3. Is this a good practice?

madth3
  • 7,275
  • 12
  • 50
  • 74
user1903224
  • 161
  • 1
  • 1
  • 6

2 Answers2

1

I've got code using the IStreamFilenameGenerator works with S3; I'll warn you now that it may not work with the latest jets3 library, but you'll get the point of how it works by looking through the source. One problem / issue that you must understand when using S3 is that you cannot "record" to the bucket on-the-fly; your flv files can only be transferred to S3 once the file is finalized; there is an example upload call in the Application.class. Whereas "play" from S3 will work as expected.

I added the S3 code to the red5-examples repo: https://github.com/Red5/red5-examples

Paul Gregoire
  • 9,715
  • 11
  • 67
  • 131
  • How does recordPath get set? It is not set in your example code and not part of the interface. Also, why are these values static? Does Red5 start a a new VM per stream? – Douglas Ferguson May 06 '15 at 16:28
  • Red5 uses the Spring Framework and most properties, classes, settings are set using dependency injection. – Paul Gregoire May 06 '15 at 18:23
  • The source of my confusion was around the missing apis. Seems like things have changed on the head of the git repo. IBroadcastStream doesn't even exist anymore – Douglas Ferguson May 06 '15 at 22:16
  • Latest version is here: https://github.com/Red5/red5-server-common/blob/master/src/main/java/org/red5/server/api/stream/IBroadcastStream.java – Paul Gregoire May 06 '15 at 22:28
  • Ah. Thanks. Also, is seems a bit unsafe to depend on a static for the recordPath, is that guaranteed to be the same for all instances? – Douglas Ferguson May 07 '15 at 00:33
  • A static will be the same for all instances in the same vm. – Paul Gregoire May 07 '15 at 11:42
  • Yes. But you are using a non static method to set a static variable. This non static function appears to be called whenever a new instance of the class is created. This means that the value of that static could be inconsistent and not thread safe. – Douglas Ferguson May 07 '15 at 15:29
  • Do you know where to find ActionScript files for any of the examples, i.e. VOD or publisher? I've only been able to find compiled versions... – Douglas Ferguson May 07 '15 at 21:41
  • I found that earlier. The only AS file is a the player4, tons of others that are only fla. I'm like to implement a recorder/player with ui in html and send events via javascript. – Douglas Ferguson May 08 '15 at 02:22
  • The older apps were all or mostly in the fla file; if you look in the classes directory, you'll find the "missing" code – Paul Gregoire May 08 '15 at 12:18
  • Thanks! I found them. – Douglas Ferguson May 08 '15 at 16:35
  • Is there a coresponding server side example for messagerecorder? – Douglas Ferguson May 08 '15 at 18:32
  • Has anyone been able to get this example to work? I'm manually hard coding the file name to the full path of my S3 file, and it's not working (tried with and without http:// preface). If I set the filename to the full path on my local file system it works fine. In the sample, I'm not really seeing the path string builder creating the full path to the S3 file. Am I misunderstanding the sample? I can see how its persisting the recording via upload, but I'm only seeing the playback constructing a playback path/filename that is local. Any help would be appreciated! – Sharbel Nov 12 '15 at 02:23
0

Search for: https://stackoverflow.com/search?q=IStreamFilenameGenerator

Or https://www.google.com.au/search?q=IStreamFilenameGenerator+example&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:de:official&client=firefox-a

and you will find some examples howto modify the path(s).

You could alternatively also of course simply mount some drive into the streams folder or I guess a symbolic link would even work. But it might be not that flexible as if you can do it with IStreamFilenameGenerator and generate really some string completely like you want it.

Sebastian

Community
  • 1
  • 1
seba.wagner
  • 3,800
  • 4
  • 28
  • 52
  • thanks for your reply.I have tried with IStreamFilenameGenerator but iam strucked it says it could not find the URL in the system.The below is my code snippet. – user1903224 Dec 17 '12 at 05:18
  • public class CustomFileGenerator implements IStreamFilenameGenerator { private static final Log log = LogFactory.getLog(DemoServiceImpl.class); /** Path to get streams... */ public String playbackPath = "http://myproject.s3.amazonaws.com/"; /** Set if the path is absolute or relative */ public boolean resolvesAbsolutePath = false; @Override public String generateFilename(IScope scope, String name, GenerationType type) { // TODO Auto-generated method stub return generateFilename(scope, name, null, type); } – user1903224 Dec 17 '12 at 05:25
  • @Override public String generateFilename(IScope scope, String name, String extension, GenerationType type) { // TODO Auto-generated method stub String filename; filename = playbackPath + name; log.debug("######################"+playbackPath); log.debug("*****************************"+filename); if (extension != null) // Add extension filename += extension; return filename; } – user1903224 Dec 17 '12 at 05:59
  • @Override public boolean resolvesToAbsolutePath() { // TODO Auto-generated method stub return resolvesAbsolutePath; } /*public void setRecordPath(String path) { recordPath = path; } */ public void setPlaybackPath(String path) { playbackPath = path; } public void setAbsolutePath(Boolean absolute) { resolvesAbsolutePath = absolute; } } – user1903224 Dec 17 '12 at 05:59