Wowza Community

Custom module to create single frame snapshots of live and VOD stream

Without some input from a user, it would have to be done on a timer.

But have you tried it with FMLE? If you know the name of the stream and you are connected to the same application, calling this function from Flash app while FMLE is publishing should work.

Richard

We are currently already doing it with a timer within the broadcasting application in flash. But to extract thumbnails for streams that are being broadcasted with an application (such as FME) we would like to do it entirely on the server side. Would there be a way to trigger the createsnapshot command from the serverside for a certain stream?

We’ll look into this, thanks a lot Richard!

Hi,

I am using ffmpeg and i am able to create thumbnails for regular mp4 movie files that i download from the internet. But when i try the same with the Extremists sample that i got from the Media Server downloads, it doesn’t work.

I noticed that the Extremists file has an extension .m4v (mp4 video). How is this different and how can i use ffmpeg to create a thumbnail for this?

Moreover when the live streams are recorded on the Media Server, what is the extension that they normally have(in case of a h264 video stream)?

Thanks,

Nish.

Richard and Charlie, thankyou for quick replies

I am using a JW Flash Player at the user end for my application. and the flashvars that i am using is like

streamer=rtmp://[wowza ip address]:1935/rtplive&file=udp://[stream-ip]:10000

and i want to write a VOD interface which accesses the recorded files in the content folder on the Wowza server. So to build a gallery in this page, i want to make sure i am writing suitable code for the right format of files. If it is an flv then i wouldn’t have a problem. I am using a HaiVision Makito encoder and H.264 video. So would they still be stored in .flv format?

Thanks!!

If i do use a mp4 as a prefix, can you tell me the extension that the stored file would have?

I want to make sure that it is playable in JW Flash Player. They cannot play .mp4 extensions but can play .m4v files.

I am trying to populate a gallery with VOD files on the Wowza Server. My client application uses ffmpeg to create thumbnails from the VOD videos (on the Wowza) and use them in the gallery. Thumbnail generation is done at runtime on the client application.

How can i access the VOD files on the Wowza Server from the client application in order to generate their thumbnails?

I am using this for thumbnail generation:

ffmpeg -i inputfile -vframes 1 -ss 00:00:07 -s 150x150 thumbname.jpg

Here in place of the inputfile i am trying to give the path to the video file.

Can you help me out on this? It would also help me greatly if you can tell me how to iterate through all the VOD files on Wowza so as to get their filenames and access them for thumbnail generation.

Do you have an example of how to call the server side function from client?

My client application is in ASP.NET and C#. Do i have to call the function using Action Script? Or can i call it from the C# code? I had a tough time trying to use NetConnection from the C# code. I couldn’t find a way of doing it.

I have followed the read me and installed the module in the application and changed the Application.xml file accordingly. But i do not understand how to proceed from there. Any help in this regard would be appreciated.

I got the web service to work by following the example code. I am using a proxy of the web service and now i need to access the Wowza modules to iterate over the files in the content folder and run ffmpeg on them. I am stuck here. Can you please help me out with some example code or ways to do this?

PS: i tried to do it through HTTProvider but failed. It didn’t make much sense to me as i am new to it. So i am going through web services.

Thank you for the reply.

I built the ModuleVideoNameList in the IDE and i put the jar file in the [install]/lib . I created and set up the web service and i am able to get the server version by using getServerVersion(). I added the module inthe application.xml files for all the applications(live,vod,etc) that i am using.

I am able to get methods like startmediacasterstream, stopmediacasterstream,getserverversion, bind and so on. But i do not find any methods associated to the ModuleVideoNameList module. How do i access that module? I read through the user guide but i cannot use netconnection as i am using .net.

Please help me out. :confused:

I looked at that code before but i am using a .NET client application so i do not have any scope to use the AS code.

I just want to know how to access the ModuleVideoNameList after building it and i also have the web service running. I just need to figure out a way to access the module from the .NET client application using a web service.:confused:

I basically cannot use “NetConnection”

Do you have a HTTProvider version of the ModuleVideoNameList?

Else can you tell me how to tweak the Module to make it HTTProvider?

The Module version extends from ModuleBase.

(OR)

I configured the web service and its running so if you can help me with the Web Service method, that would work too.

PS: I did not find any XML output related stuff in the second link you sent.

Thanks a lot!!

[PHP]

package com.YOURCOMPANY.wms.previews;

import java.io.OutputStream;

import java.util.List;

import java.util.Map;

import com.wowza.util.FLVUtils;

import com.wowza.wms.amf.AMFPacket;

import com.wowza.wms.application.IApplicationInstance;

import com.wowza.wms.application.WMSProperties;

import com.wowza.wms.http.IHTTPProvider;

import com.wowza.wms.http.IHTTPRequest;

import com.wowza.wms.http.IHTTPResponse;

import com.wowza.wms.stream.IMediaStream;

import com.wowza.wms.stream.MediaStreamMap;

import com.wowza.wms.vhost.HostPort;

import com.wowza.wms.vhost.IVHost;

public class StreamsPreview implements IHTTPProvider {

IApplicationInstance appInstance;

public void onHTTPRequest(IVHost vhost, IHTTPRequest req, IHTTPResponse resp) {

if(appInstance == null)

appInstance = vhost.getApplication(“YOURAPP”).getAppInstance(“definst”);

resp.setHeader(“Content-Type”, “video/x-flv”);

OutputStream out = resp.getOutputStream();

Map<String, List> params = req.getParameterMap();

if (params.containsKey(“preview”))

{

String action = params.get(“preview”).get(0);

MediaStreamMap streams = appInstance.getStreams();

IMediaStream stream = streams.getStream(action);

if (stream != null)

{

AMFPacket packet = stream.getLastKeyFrame();

if (packet != null)

{

FLVUtils.writeHeader(out, 0, null);

AMFPacket codecConfig = stream.getVideoCodecConfigPacket(packet.getAbsTimecode());

if (codecConfig != null)

FLVUtils.writeChunk(out, codecConfig.getDataBuffer(), codecConfig.getSize(), 0, (byte)codecConfig.getType());

FLVUtils.writeChunk(out, packet.getDataBuffer(), packet.getSize(), 0, (byte)packet.getType());

}

}

}

}

public void onBind(IVHost vhost, HostPort hostPort) {

}

public void onUnbind(IVHost vhost, HostPort hostPort) {

}

public void setProperties(WMSProperties properties) {

}

}

[/PHP]

have fun :cool:

Is this working for getting one frame from mp4 h264 file ?

Hello, I need to do wowza screenshot every 2 minutes all publish live stream

I need to write a custom module? Or is there existing solutions?

I looked https://www.wowza.com/docs/how-to-take-a-single-frame-snapshot-of-a-live-stream-for-thumbnail-creation-modulecreatesnapshot, but I need to do wowza screenshots without calling functions from flash client.

del

is it possible to do this without Action Script? that

WoWza save snapshot of stream every 10 minutes?

would it be possible to create single frame snapshot from a frame between 2 keyframes? the code take the packet from last keyframe in the stream.

The keyframe interval of my source video (Live H.264 MP4 stream from a camera) is set to 25 (unfortunately the camera doesn’t let me set the interval to smaller than 25)

but I need to create a snapshot every 2 seconds.

Thanks

Thank you for your quick response, but I can’t set the FPS to a high number because we don’t have enough upstream bandwidth at the camera location :frowning:

probably have to find another camera

Dear all,

I’m integrating this module into our Wowza and got a problem when running ffmpeg.

The command is

ffmpeg -i deathemperor_99050400.flv -vcodec png -vframes 1 -an -f rawvideo -s 320x240 thumbnail.png

The error I got from ffpmeg:

FFmpeg version 0.6.5, Copyright (c) 2000-2010 the FFmpeg developers
  built on Jan 29 2012 17:52:15 with gcc 4.4.5 20110214 (Red Hat 4.4.5-6)
  configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --mandir=/usr/share/man --incdir=/usr/include --disable-avisynth --extra-cflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fPIC' --enable-avfilter --enable-avfilter-lavf --enable-libdc1394 --enable-libdirac --enable-libfaac --enable-libfaad --enable-libfaadbin --enable-libgsm --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libx264 --enable-gpl --enable-nonfree --enable-postproc --enable-pthreads --enable-shared --enable-swscale --enable-vdpau --enable-version3 --enable-x11grab
  libavutil     50.15. 1 / 50.15. 1
  libavcodec    52.72. 2 / 52.72. 2
  libavformat   52.64. 2 / 52.64. 2
  libavdevice   52. 2. 0 / 52. 2. 0
  libavfilter    1.19. 0 /  1.19. 0
  libswscale     0.11. 0 /  0.11. 0
  libpostproc   51. 2. 0 / 51. 2. 0
[flv @ 0x209b670]Could not find codec parameters (Audio: 0x0000, 0 channels)
[flv @ 0x209b670]Estimating duration from bitrate, this may be inaccurate
Seems stream 0 codec frame rate differs from container frame rate: 50.00 (50/1) -> 25.00 (50/2)
Input #0, flv, from 'deathemperor_99050400.flv':
  Metadata:
    duration        : 0
    creationdate    : Sun Jun 23 01:09:09
  Duration: 00:00:00.00, start: 0.080000, bitrate: N/A
    Stream #0.0: Video: h264, yuv420p, 1280x720, 25 tbr, 1k tbn, 50 tbc
    Stream #0.1: Audio: 0x0000, 0 channels
File 'thumbnail.png' already exists. Overwrite ? [y/N] y
Output #0, rawvideo, to 'thumbnail.png':
  Metadata:
    encoder         : Lavf52.64.2
    Stream #0.0: Video: png, rgb24, 320x240, q=2-31, 200 kb/s, 90k tbn, 25 tbc
Stream mapping:
  Stream #0.0 -> #0.0
Press [q] to stop encoding
frame=    0 fps=  0 q=0.0 Lsize=       0kB time=10000000000.00 bitrate=   0.0kbits/s dup=0 drop=1
video:0kB audio:0kB global headers:0kB muxing overhead -nan%

I tried opening the FLV file with VLC, it shows an error while opening with Media Player Classic is fine. I then went to check the file’s header it’s something like this:

General
Complete name                    : F:\tmp\deathemperor_100850400.flv
Format                           : Flash Video
File size                        : 45.7 KiB
Duration                         : 40ms
Overall bit rate                 : 9 356 Kbps
Video
Format                           : AVC
Format/Info                      : Advanced Video Codec
Format profile                   : High@L3.1
Format settings, CABAC           : Yes
Format settings, ReFrames        : 4 frames
Codec ID                         : 7
Duration                         : 40ms
Width                            : 1 280 pixels
Height                           : 720 pixels
Display aspect ratio             : 16:9
Frame rate mode                  : Variable
Color space                      : YUV
Chroma subsampling               : 4:2:0
Bit depth                        : 8 bits
Scan type                        : Progressive
Audio

This gives me a meaning that the FLV with one frame is missing a lot of info in its header. Not sure if this causes the problem when running ffmpeg?

The FLV file is here: http://tv.csmtalk.vcdn.vn/death/deathemperor_100850400.flv, created by Wowza the same method guided in this thread

I got it working, thanks.