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

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.