source.connect(enoughDataListener);
bufferDispatcher = new BufferDispatcher();
executor = Gst.getScheduledExecutorService();
Element formatConverter = ElementFactory.make("ffmpegcolorspace", "formatConverter");
Element formatFilter = ElementFactory.make("capsfilter", "formatFilter");
Caps capsFormat = Caps.fromString("video/x-raw-yuv,format=(fourcc)I420,width=" + width + ",height=" + height);
formatFilter.setCaps(capsFormat);
Element encoder = ElementFactory.make(encoderStr, "encoder");
if (encoderPropertyNames != null && encoderPropertyData != null)
{
// Setting encoder properties.
int n0 = encoderPropertyNames.length;
int n1 = encoderPropertyData.length;
int n = n0 < n1 ? n0 : n1;
for (int i = 0; i < n; i++) encoder.set(encoderPropertyNames[i], encoderPropertyData[i]);
}
Element muxer = ElementFactory.make(muxerStr, "muxer");
Element sink = ElementFactory.make("filesink", "sink");
sink.set("location", file.toString());
addMany(source, formatConverter, formatFilter, encoder, muxer, sink);
Element.linkMany(source, formatConverter, formatFilter, encoder, muxer, sink);
sendingData = false;