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

**URL:** <https://community.wowza.com/t/custom-module-to-create-single-frame-snapshots-of-live-and-vod-stream/38>\
**Category:** Wowza Streaming Engine\
**Created:** [November 7, 2007, 7:44am UTC](https://community.wowza.com/t/custom-module-to-create-single-frame-snapshots-of-live-and-vod-stream/38 "2007-11-07T07:44:04Z")\
**Posts on this page:** 20\
**Page:** 3

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [August 5, 2011, 9:36pm UTC](https://community.wowza.com/t/custom-module-to-create-single-frame-snapshots-of-live-and-vod-stream/38/41 "2011-08-05T21:36:34Z")

</div>

You can create an HTTProvider version of this application module.

[https://www.wowza.com/docs/http-providers](https://www.wowza.com/docs/http-providers)

You need the IDE:

[http://wowza.com/ide.html](http://wowza.com/ide.html)

It would take some understanding of Wowza Application module and HTTProviders. There is a pretty good example of an HTTProvider version of an application Module in the [LiveStreamRecord addon](https://www.wowza.com/docs/how-to-record-live-streams-httplivestreamrecord)

Richard

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [March 15, 2012, 1:49pm UTC](https://community.wowza.com/t/custom-module-to-create-single-frame-snapshots-of-live-and-vod-stream/38/42 "2012-03-15T13:49:55Z")

</div>

Looking at the code, I think it will, but the output will be one frame flv.

Richard

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [July 2, 2012, 1:31pm UTC](https://community.wowza.com/t/custom-module-to-create-single-frame-snapshots-of-live-and-vod-stream/38/43 "2012-07-02T13:31:21Z")

</div>

No, I am pretty sure that is not possible.

Richard

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [July 2, 2012, 1:34pm UTC](https://community.wowza.com/t/custom-module-to-create-single-frame-snapshots-of-live-and-vod-stream/38/44 "2012-07-02T13:34:08Z")

</div>

However, on the camera side, try setting key frame interval to 60, and the FPS to 30. Then you will have a key frame every 2 seconds

Richard

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [July 2, 2012, 5:33pm UTC](https://community.wowza.com/t/custom-module-to-create-single-frame-snapshots-of-live-and-vod-stream/38/45 "2012-07-02T17:33:38Z")

</div>

You could lower bitrate or higher compression setting (If Axis cam) so you can set fps higher. I don’t know another solution otherwise

Richard

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [June 24, 2013, 3:42pm UTC](https://community.wowza.com/t/custom-module-to-create-single-frame-snapshots-of-live-and-vod-stream/38/46 "2013-06-24T15:42:34Z")

</div>

It opens in FFprobe and should be suitable to make a jpg from.

Richard

---

<div class="post-metadata">

**Author:** ![Kosso\_Kosso](https://avatars.discourse-cdn.com/v4/letter/k/85e7bf/32.png) [@Kosso\_Kosso](https://community.wowza.com/u/Kosso_Kosso)\
**Post date:** [January 13, 2008, 11:56am UTC](https://community.wowza.com/t/custom-module-to-create-single-frame-snapshots-of-live-and-vod-stream/38/47 "2008-01-13T11:56:02Z")

</div>

hi,

this should work for you 😉

ffmpeg -i yourvideo.flv -s 160x120 -ss 00:00:02 -f mjpeg -t 0.001 -y yourthumbnail.jpg

hope this helps 😉

koz

---

<div class="post-metadata">

**Author:** ![Kosso\_Kosso](https://avatars.discourse-cdn.com/v4/letter/k/85e7bf/32.png) [@Kosso\_Kosso](https://community.wowza.com/u/Kosso_Kosso)\
**Post date:** [January 13, 2008, 1:40pm UTC](https://community.wowza.com/t/custom-module-to-create-single-frame-snapshots-of-live-and-vod-stream/38/48 "2008-01-13T13:40:43Z")

</div>

in fact this will work better, giving you better compresison on the JPEG

ffmpeg -i yourvideo.flv -vcodec mjpeg -vframes 1 -an -f rawvideo -s 160x120 -ss 00:00:02 -y yourthumbnail.jpg

this takes an image from two seconds in to the video and creates a 160x120 jpeg

hope this helps,

koz

---

<div class="post-metadata">

**Author:** ![robert\_lebreux](https://avatars.discourse-cdn.com/v4/letter/r/47e85d/32.png) [@robert\_lebreux](https://community.wowza.com/u/robert_lebreux)\
**Post date:** [April 8, 2008, 8:43am UTC](https://community.wowza.com/t/custom-module-to-create-single-frame-snapshots-of-live-and-vod-stream/38/49 "2008-04-08T08:43:38Z")

</div>

thx, I’m really stupid. I don’t see it 😛

---

<div class="post-metadata">

**Author:** ![robert\_lebreux](https://avatars.discourse-cdn.com/v4/letter/r/47e85d/32.png) [@robert\_lebreux](https://community.wowza.com/u/robert_lebreux)\
**Post date:** [May 7, 2008, 12:57pm UTC](https://community.wowza.com/t/custom-module-to-create-single-frame-snapshots-of-live-and-vod-stream/38/50 "2008-05-07T12:57:47Z")

</div>

a new problem, it’s not relative to wowza server but to conversion with ffmpeg. I usually use :

```auto
ffmpeg -i file.flv -vcodec png -vframes 1 -ss 0:0:5.000 -an -f rawvideo -y snapshot.png

```

something which usally works fine. With the last version of wowza, there is now support for h264 so i try it and it’s really usefull. Streaming get a really better quality . But when I want to generate snapshots from those video, the command failed.

```auto
FFmpeg version SVN-r12665, Copyright (c) 2000-2008 Fabrice Bellard, et al.
  configuration: --enable-gpl --enable-postproc --enable-swscale --enable-avfilt
er-lavf --enable-pthreads --enable-liba52 --enable-avisynth --enable-libfaac --e
nable-libfaad --enable-libgsm --enable-memalign-hack --enable-libmp3lame --enabl
e-libnut --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid
 --cpu=i686 --extra-ldflags=-static
  libavutil version: 49.6.0
  libavcodec version: 51.54.0
  libavformat version: 52.13.0
  libavdevice version: 52.0.0
  built on Apr 2 2008 22:35:11, gcc: 4.2.3
[flv @ 00AA6C70]Unsupported video codec (7)
[flv @ 00AA6C70]Unsupported video codec (7)
[flv @ 00AA6C70]Unsupported video codec (7)
[flv @ 00AA6C70]Unsupported video codec (7)
[flv @ 00AA6C70]Unsupported video codec (7)
...
[flv @ 00AA6C70]Unsupported video codec (7)
[flv @ 00AA6C70]Unsupported video codec (7)
[flv @ 00AA6C70]Unsupported video codec (7)
[flv @ 00AA6C70]Unsupported video codec (7)
[flv @ 00AA6C70]Unsupported video codec (7)
Seems stream 0 codec frame rate differs from container frame rate: 1000.00 (1000
/1) -> 25.00 (25/1)
Input #0, flv, from 'file.flv':
  Duration: 00:00:50.3, start: 0.000000, bitrate: 80 kb/s
    Stream #0.0: Video: 0x0007, 25.00 tb(r)
    Stream #0.1: Audio: mp3, 22050 Hz, stereo, 80 kb/s
picture size invalid (0x0)
Cannot allocate temp picture, check pix fmt

```

it seems for me that ffmpeg doesn’t support H264, this is the only thing which change since before. But surprise, the documentation and official website of ffmpeg clearly say that flv & h264 is supported. If somebody get and idea or already get this error.

---

<div class="post-metadata">

**Author:** ![Kadir\_ERDOGAN](https://avatars.discourse-cdn.com/v4/letter/k/49beb7/32.png) [@Kadir\_ERDOGAN](https://community.wowza.com/u/Kadir_ERDOGAN)\
**Post date:** [April 4, 2008, 2:25pm UTC](https://community.wowza.com/t/custom-module-to-create-single-frame-snapshots-of-live-and-vod-stream/38/51 "2008-04-04T14:25:07Z")

</div>

is it possible to show captured frame in the flash client?

I want to save snapshots of live streams to the database so that later i can see them from the admin panel which is a flex client.

Thanks

---

<div class="post-metadata">

**Author:** ![Markus\_Beh](https://avatars.discourse-cdn.com/v4/letter/m/dec6dc/32.png) [@Markus\_Beh](https://community.wowza.com/u/Markus_Beh)\
**Post date:** [April 27, 2009, 12:43pm UTC](https://community.wowza.com/t/custom-module-to-create-single-frame-snapshots-of-live-and-vod-stream/38/52 "2009-04-27T12:43:00Z")

</div>

> I modified the Java code in the first post. See if that does the trick. I did not have time to test it.
> 
> Charlie

Hi Charlie,

where do I find the code snippet, mentioned above?

Regards,

Markus

---

<div class="post-metadata">

**Author:** ![Markus\_Beh](https://avatars.discourse-cdn.com/v4/letter/m/dec6dc/32.png) [@Markus\_Beh](https://community.wowza.com/u/Markus_Beh)\
**Post date:** [April 27, 2009, 6:55pm UTC](https://community.wowza.com/t/custom-module-to-create-single-frame-snapshots-of-live-and-vod-stream/38/53 "2009-04-27T18:55:24Z")

</div>

Hi Richard,

I use the code you at the first page for creating snapshots.

The problem is that this code don’t seems to work for recorded H264-Streams.

On top of page 3 Charlie mentioned, that he has modified

the code on page 1, so that ist worked for H264 also.

I’am especially interested in this modifications.

For the sake of completeness follows the code I use at the moment for creating snapshots (it is a slightly modified version of the code for createSnapshotVOD(…) on page 1):

```auto
public void createFlvSnapshot(Snapshot snapshot) 
	{
		long timecodeInMillis = Integer.valueOf(snapshot.getStreamPosInSec())*1000;
		
		if (!snapshot.getSnapshotDirectory().isDirectory()){
			snapshot.getSnapshotDirectory().mkdirs();
		}
		
		if (snapshot.getFlvFile().exists())
		{
      log.info("create flv snapshot from: "+snapshot.getFlvFile().getAbsolutePath()+" dst: "+snapshot.getFlvSnapshotFile().getAbsolutePath());
			AMFPacket lastVideoKeyFrame = null;
			try
			{
				BufferedInputStream is = new BufferedInputStream(new FileInputStream(snapshot.getFlvFile()));
				FLVUtils.readHeader(is);
				AMFPacket amfPacket;
				while ((amfPacket = FLVUtils.readChunk(is)) != null)
				{
					if (lastVideoKeyFrame != null && amfPacket.getTimecode() > timecodeInMillis)
						break;
					if (amfPacket.getType() != IVHost.CONTENTTYPE_VIDEO)
						continue;
					if (FLVUtils.getFrameType(amfPacket.getFirstByte()) == FLVUtils.FLV_KFRAME)
						lastVideoKeyFrame = amfPacket;
				}
				is.close();
			}
			catch (Exception e)
			{
				log.error("Error: createSnapshotVOD: reading flv: "+e.toString());
			}
			
			if (lastVideoKeyFrame != null)
			{
				try
				{
					BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(snapshot.getFlvSnapshotFile(), false));
					FLVUtils.writeHeader(out, 0, null);
					FLVUtils.writeChunk(out, lastVideoKeyFrame.getDataBuffer(), lastVideoKeyFrame.getSize(), 0, (byte)lastVideoKeyFrame.getType());
					out.close();
				}
				catch (Exception e)
				{
					log.error("Error: createSnapshotVOD: writing flv: "+e.toString());
				}
			}
		}
	}

```

---

<div class="post-metadata">

**Author:** ![Markus\_Beh](https://avatars.discourse-cdn.com/v4/letter/m/dec6dc/32.png) [@Markus\_Beh](https://community.wowza.com/u/Markus_Beh)\
**Post date:** [April 28, 2009, 1:08pm UTC](https://community.wowza.com/t/custom-module-to-create-single-frame-snapshots-of-live-and-vod-stream/38/54 "2009-04-28T13:08:42Z")

</div>

Hi Charlie,

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

```

how do I extract such a codecConfig Packet from a recorded h264 file?

Regards

Markus

---

<div class="post-metadata">

**Author:** ![Markus\_Beh](https://avatars.discourse-cdn.com/v4/letter/m/dec6dc/32.png) [@Markus\_Beh](https://community.wowza.com/u/Markus_Beh)\
**Post date:** [April 28, 2009, 2:07pm UTC](https://community.wowza.com/t/custom-module-to-create-single-frame-snapshots-of-live-and-vod-stream/38/55 "2009-04-28T14:07:04Z")

</div>

Hi Charlie,

I want to take a snapshot from a FLV-File which was recorded some time ago.

Therefore I don’t have a IMediaStream Object at the

time I want to create the snapshot.

My first step is to “load” the file via:

```auto
BufferedInputStream is = new BufferedInputStream(new FileInputStream(snapshot.getFlvFile()));

```

Then I search the AMFPacket at the given timecode by:

```auto
FLVUtils.readHeader(is);
				AMFPacket amfPacket;
				
				while ((amfPacket = FLVUtils.readChunk(is)) != null)
				{
					if (lastVideoKeyFrame != null && amfPacket.getTimecode() > timecodeInMillis)
						break;
					if (amfPacket.getType() != IVHost.CONTENTTYPE_VIDEO)
						continue;
					if (FLVUtils.getFrameType(amfPacket.getFirstByte()) == FLVUtils.FLV_KFRAME)
						lastVideoKeyFrame = amfPacket;
				}
				is.close();

```

In a last step I write this packet (lastVideoKeyFrame) to a new flv-File.

The code for this step is:

```auto
BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(snapshot.getFlvSnapshotFile(), false));
					FLVUtils.writeHeader(out, 0, null);
					//FLVUtils.writeChunk(out, lastVideoKeyFrame.getDataBuffer(), lastVideoKeyFrame.getSize(), 0, (byte)lastVideoKeyFrame.getType());
					
					
					AMFPacket codecConfig = [COLOR="Red"]stream[/COLOR].getVideoCodecConfigPacket(packet.getAbsTimecode());
					if (codecConfig != null){
						FLVUtils.writeChunk(out, codecConfig.getDataBuffer(), codecConfig.getSize(), 0, (byte)codecConfig.getType());
					}
					FLVUtils.writeChunk(out, lastVideoKeyFrame.getDataBuffer(), lastVideoKeyFrame.getSize(), 0, (byte)lastVideoKeyFrame.getType());
					
					
					out.close();

```

Regards,

Markus

---

<div class="post-metadata">

**Author:** ![Markus\_Beh](https://avatars.discourse-cdn.com/v4/letter/m/dec6dc/32.png) [@Markus\_Beh](https://community.wowza.com/u/Markus_Beh)\
**Post date:** [April 28, 2009, 2:46pm UTC](https://community.wowza.com/t/custom-module-to-create-single-frame-snapshots-of-live-and-vod-stream/38/56 "2009-04-28T14:46:00Z")

</div>

Hi Charlie,

grabbing a image directly from a saved flv-file by ffmpeg

is much slower than creating a mini-flv and convert this mini-flv to an image afterwards.

Regards,

Markus

---

<div class="post-metadata">

**Author:** ![Sebastien\_Faure](https://avatars.discourse-cdn.com/v4/letter/s/9f8e36/32.png) [@Sebastien\_Faure](https://community.wowza.com/u/Sebastien_Faure)\
**Post date:** [August 6, 2009, 9:18am UTC](https://community.wowza.com/t/custom-module-to-create-single-frame-snapshots-of-live-and-vod-stream/38/57 "2009-08-06T09:18:07Z")

</div>

Yesterday, I tried to grab 3 thumbnails (beginning, middle, end) from a recorded FLV file (H264), using ffmpeg in an external command line. Everything works fine.

Now I’m wondering about ffmepg behaviour when grabbing frames. A few years ago, when I tried this, I notice ffmpeg browse the whole file to seek in the file. When the FLV file is 2 hours long for instance, it could be really slow !

Let’s say FLVUtils offer a native PNG/JPG export function of a given frame, what would be FLVUtils behaviour in this case ?

---

<div class="post-metadata">

**Author:** ![Sebastien\_Faure](https://avatars.discourse-cdn.com/v4/letter/s/9f8e36/32.png) [@Sebastien\_Faure](https://community.wowza.com/u/Sebastien_Faure)\
**Post date:** [August 7, 2009, 11:22am UTC](https://community.wowza.com/t/custom-module-to-create-single-frame-snapshots-of-live-and-vod-stream/38/58 "2009-08-07T11:22:19Z")

</div>

No matter, your module works great and the feature is really impressive (using ffmpeg to convert to png then delete flv frame) …

Thank you !

---

<div class="post-metadata">

**Author:** ![Sebastien\_Faure](https://avatars.discourse-cdn.com/v4/letter/s/9f8e36/32.png) [@Sebastien\_Faure](https://community.wowza.com/u/Sebastien_Faure)\
**Post date:** [July 26, 2010, 3:33pm UTC](https://community.wowza.com/t/custom-module-to-create-single-frame-snapshots-of-live-and-vod-stream/38/59 "2010-07-26T15:33:52Z")

</div>

As I know, NetConnection object is ActionScript.

You can’t call server-side functions with C#, you need either Flash or Flex piece of code …

---

<div class="post-metadata">

**Author:** ![Patricio\_Cornejo](https://avatars.discourse-cdn.com/v4/letter/p/5f8ce5/32.png) [@Patricio\_Cornejo](https://community.wowza.com/u/Patricio_Cornejo)\
**Post date:** [December 10, 2008, 4:07am UTC](https://community.wowza.com/t/custom-module-to-create-single-frame-snapshots-of-live-and-vod-stream/38/60 "2008-12-10T04:07:52Z")

</div>

how do you use it on AS3… Â¿? nc.call() ? any example… please…

[Previous page](https://community.wowza.com/t/custom-module-to-create-single-frame-snapshots-of-live-and-vod-stream/38.md?page=2)

[Next page](https://community.wowza.com/t/custom-module-to-create-single-frame-snapshots-of-live-and-vod-stream/38.md?page=4)
