# Programatic cropping of transcoded stream

**URL:** <https://community.wowza.com/t/programatic-cropping-of-transcoded-stream/304>\
**Category:** Wowza Streaming Engine\
**Created:** [December 17, 2015, 6:27pm UTC](https://community.wowza.com/t/programatic-cropping-of-transcoded-stream/304 "2015-12-17T18:27:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/system/32/447_2.png) [@system](https://community.wowza.com/u/system)\
**Post date:** [December 17, 2015, 6:27pm UTC](https://community.wowza.com/t/programatic-cropping-of-transcoded-stream/304/1 "2015-12-17T18:27:36Z")

</div>

Hi,

I would like to be able to apply a crop to the output of the transcoder. i.e. we define a region of the video and the output is only that region, the height and width of the video would change according to the dimensions of the crop.

The resize only has to happen once (we know what the target dimensions will be), so, if it is not possible crop and resize, is it possible to just crop a region of the video and have it placed in the resized output, without scaling?

So far, we have tried using the SetCrop, SetDstRect, SetSrcRect. We have not had any luck affecting changes in real-time.

Thanks!

adam.

---

<div class="post-metadata">

**Author:** ![Matt\_Young](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/matt_young/32/389_2.png) [@Matt\_Young](https://community.wowza.com/u/Matt_Young)\
**Post date:** [January 22, 2016, 7:50am UTC](https://community.wowza.com/t/programatic-cropping-of-transcoded-stream/304/2 "2016-01-22T07:50:55Z")

</div>

Hello Adam

You can look at the ILiveStreamTranscoderActionNotify interface and leverage the setCrop function similar to the following:

```auto
// event handler in ILiveStreamTranscoderActionNotify
 public void onInitAfterLoadTemplate(LiveStreamTranscoder liveStreamTranscoder) { 
       TranscoderStreamDestination streamDest = ... reference to your destination ...;
   		 
		int[] cropDef = new int[4];
		cropDef[0] = 10;
		cropDef[1] = 20;
		cropDef[2] = 20;
		cropDef[3] = 10;
	 streamDest.getVideo().setCrop(cropDef);
 }

```

Thanks,

Matt

---

<div class="post-metadata">

**Author:** ![Jeff\_Chandler](https://avatars.discourse-cdn.com/v4/letter/j/f9ae1b/32.png) [@Jeff\_Chandler](https://community.wowza.com/u/Jeff_Chandler)\
**Post date:** [January 9, 2018, 4:31am UTC](https://community.wowza.com/t/programatic-cropping-of-transcoded-stream/304/3 "2018-01-09T04:31:00Z")

</div>

Hi @Matt Young,

Can setCrop() be called any time? Such as from onBeforeEncode or onBeforeScale()?

Thanks,

Jeff
