VideoFormat.RLE is not working.. please help
Hi all,
I am creating AVI file from Bitmap that are compressed(As well as non-compressed) throught RLE Algorithm
Code makes .AVI file. But this file is not accurate..
Please help me..
I am attaching the code with it.
========================================================
package animation;
import java.io.*;
import java.awt.Color;
import java.awt.Dimension;
import javax.media.*;
import javax.media.control.*;
import javax.media.protocol.*;
import javax.media.datasink.*;
import javax.media.format.VideoFormat;
import bmpCreation.BitmapImage;
public class AviCreator implements ControllerListener, DataSinkListener {
private Object waitSync = new Object();
private boolean stateTransitionOK = true;
private Object waitFileSync = new Object();
private boolean fileDone = false;
private boolean fileSuccess = true;
* A DataSource to read from a list of BITMAP Images
* turn that into a stream of JMF buffers.
* The DataSource is not seekable or positionable.
private class ImageDataSource extends PullBufferDataSource
private ImageSourceStream streams[];
ImageDataSource(int width, int height, int frameRate)
streams = new ImageSourceStream[1];
streams[0] = new ImageSourceStream(width, height, frameRate);
public void setLocator(MediaLocator source)
public MediaLocator getLocator()
return null;
* Content type is of RAW since we are sending buffers of video
* frames without a container format.
public String getContentType()
return ContentDescriptor.RAW;
public void connect()
public void disconnect()
public void start()
public void stop()
* Return the ImageSourceStreams.
public PullBufferStream[] getStreams()
return streams;
* We could have derived the duration from the number of
* frames and frame rate. But for the purpose of this program,
* it's not necessary.
public Time getDuration()
System.out.println("dur is " + streams[0].nextImage);
//return new Time(1000000000);
return DURATION_UNKNOWN;
public Object[] getControls()
return new Object[0];
public Object getControl(String type)
return null;
* The source stream to go along with ImageDataSource.
private class ImageSourceStream implements PullBufferStream
final int width, height;
final VideoFormat format;
// ColorPalette clrPal;
float frameRate;
long seqNo = 0;
int nextImage = 0; // index of the next image to be read.
boolean ended = false;
public ImageSourceStream(int width, int height, int frameRate)
this.width = width;
this.height = height;
// Bug fix from Forums (next line)
this.frameRate = (float) frameRate;
System.out.println("FrameRate = " + frameRate);
format = new javax.media.format.VideoFormat(VideoFormat.RLE,new Dimension(width, height),
Format.NOT_SPECIFIED,Format.byteArray,frameRate);
* We should never need to block assuming data are read from files.
public boolean willReadBlock()
return false;
* This is called from the Processor to read a frame worth
* of video data.
public void read(Buffer buf) throws IOException
// Check if we've finished all the frames.
if (nextImage >= 20)
// We are done. Set EndOfMedia.
System.err.println("Done reading all images.");
buf.setEOM(true);
buf.setOffset(0);
buf.setLength(0);
ended = true;
return;
//System.out.println("nextImage := " + nextImage);
nextImage++;
byte data[] = null;
byte data_copy[] = null;
// Check the input buffer type & size.
if (buf.getData() instanceof byte[])
data = (byte[]) buf.getData();
// Check to see the given buffer is big enough for the frame.
BitmapImage imgLoaded = new BitmapImage();
//Note that loadBitmapImage is my own function and works fine.
imgLoaded.loadBitmapImage("E:/Images/untitled.bmp");
int nDataLength = imgLoaded.getByteArray().length;
if (data == null || (data.length<nDataLength-118))
data = new byte[ nDataLength - 118];
Here I am not much sure but I think Bitmap Header will be 118 Bytes.
//Consider
data_copy = new byte[nDataLength];
buf.setData(data);
// Bug fix from Forums ( next 3 lines).
long time = (long) (seqNo * (1000 / frameRate) * 1000000);
buf.setTimeStamp(time);
buf.setSequenceNumber(seqNo++);
("E:/ApplicationDemo/ApplicationDemo/Compressed.bmp");
data_copy = imgLoaded.getByteArray();
for(int nCount=118;nCount<nDataLength;nCount++)
data[nCount-118] = data_copy[nCount];
buf.setOffset(0);
buf.setLength(nDataLength-118);
buf.setFormat(format);
buf.setFlags(buf.getFlags() | Buffer.FLAG_KEY_FRAME);
* Return the format of each video frame. That will be JPEG.
public Format getFormat()
return format;
public ContentDescriptor getContentDescriptor()
return new ContentDescriptor(ContentDescriptor.RAW);
public long getContentLength()
return 0;
public boolean endOfStream()
return ended;
public Object[] getControls()
return new Object[0];
public Object getControl(String type)
return null;
@Override
public void controllerUpdate(ControllerEvent evt) {
if (evt instanceof ConfigureCompleteEvent
|| evt instanceof RealizeCompleteEvent
|| evt instanceof PrefetchCompleteEvent)
synchronized (waitSync)
stateTransitionOK = true;
waitSync.notifyAll();
else if (evt instanceof ResourceUnavailableEvent)
synchronized (waitSync)
stateTransitionOK = false;
waitSync.notifyAll();
else if (evt instanceof EndOfMediaEvent)
evt.getSourceController().stop();
evt.getSourceController().close();
@Override
public void dataSinkUpdate(DataSinkEvent evt) {
if (evt instanceof EndOfStreamEvent)
synchronized (waitFileSync)
fileDone = true;
waitFileSync.notifyAll();
else if (evt instanceof DataSinkErrorEvent)
synchronized (waitFileSync)
fileDone = true;
fileSuccess = false;
waitFileSync.notifyAll();
public boolean createAvi(int width, int height, int frameRate, String outputFile){
// Generate the output media locators.
MediaLocator oml;
if ((oml = createMediaLocator(outputFile)) == null)
System.err.println("Cannot build media locator from: " + outputFile);
System.exit(0);
doIt(width, height, frameRate, oml);
return true;
* Create a media locator from the given string.
private static MediaLocator createMediaLocator(String url) {
MediaLocator ml;
// if (url.indexOf(":") > 0 && (ml = new MediaLocator(url)) != null)
// return ml;
// if (url.startsWith(File.separator))
// if ((ml = new MediaLocator("file:" + url)) != null)
// return ml;
// else
String file =
"file:" + /*System.getProperty("user.dir") + File.separator +*/ url;
if ((ml = new MediaLocator(file)) != null)
return ml;
return null;
private boolean doIt( int width, int height, int frameRate, MediaLocator outML) {
ImageDataSource ids = new ImageDataSource(width, height, frameRate);
Processor p;
try
System.err.println(
"- create processor for the image datasource ...");
p = Manager.createProcessor(ids);
catch (Exception e)
System.err.println(
"Yikes! Cannot create a processor from the data source.");
return false;
p.addControllerListener(this);
// Put the Processor into configured state so we can set
// some processing options on the processor.
p.configure();
if (!waitForState(p, Processor.Configured))
System.err.println("Failed to configure the processor.");
return false;
// Set the output content descriptor to QuickTime.
p.setContentDescriptor(
new ContentDescriptor(FileTypeDescriptor.MSVIDEO));
// Query for the processor for supported formats.
// Then set it on the processor.
TrackControl tcs[] = p.getTrackControls();
// for (int i = 0; i < tcs.length; i++) {
// Format format = tcs.getFormat();
// if (tcs[i].isEnabled() && format instanceof VideoFormat) {
//Dimension size = ((VideoFormat)format).getSize();
//float frameRate = ((VideoFormat)format).getFrameRate();
//int w = (size.width % 8 == 0 ? size.width :(int)(size.width / 8) * 8);
//int h = (size.height % 8 == 0 ? size.height :(int)(size.height / 8) * 8);
// VideoFormat jpegFormat = new VideoFormat(
// VideoFormat.JPEG_RTP, new Dimension(w, h), Format.NOT_SPECIFIED, Format.byteArray, frameRate);
/// messageLabel.setText("Status: Video transmitted as: " + jpegFormat.toString());
//int nLength = tcs.length;
// System.out.println(nLength);
Format f[] = tcs[0].getSupportedFormats();
if (f == null || f.length <= 0)
System.err.println(
"The mux does not support the input format: "
+ tcs[0].getFormat());
return false;
tcs[0].setFormat(f[0]);
System.err.println("Setting the track format to: " + f[0]);
// We are done with programming the processor. Let's just
// realize it.
p.realize();
if (!waitForState(p, Processor.Realized))
System.err.println("Failed to realize the processor.");
return false;
// Now, we'll need to create a DataSink.
DataSink dsink;
if ((dsink = createDataSink(p, outML)) == null)
System.err.println(
"Failed to create a DataSink for the given output MediaLocator: "
+ outML);
return false;
dsink.addDataSinkListener(this);
fileDone = false;
System.err.println("start processing...");
// OK, we can now start the actual transcoding.
try
p.start();
dsink.start();
catch (IOException e)
System.err.println("IO error during processing");
return false;
// Wait for EndOfStream event.
waitForFileDone();
// Cleanup.
try
dsink.close();
catch (Exception e)
p.removeControllerListener(this);
System.err.println("...done processing.");
return true;
* Block until the processor has transitioned to the given state.
* Return false if the transition failed.
private boolean waitForState(Processor p, int state)
synchronized (waitSync)
try
while (p.getState() < state && stateTransitionOK)
waitSync.wait();
catch (Exception e)
return stateTransitionOK;
* Create the DataSink.
private DataSink createDataSink(Processor p, MediaLocator outML)
DataSource ds;
if ((ds = p.getDataOutput()) == null)
System.err.println(
"Something is really wrong: the processor does not have an output DataSource");
return null;
DataSink dsink;
try
System.err.println("- create DataSink for: " + outML);
dsink = Manager.createDataSink(ds, outML);
dsink.open();
catch (Exception e)
System.err.println("Cannot create the DataSink: " + e);
return null;
return dsink;
* Block until file writing is done.
private boolean waitForFileDone()
synchronized (waitFileSync)
try
while (!fileDone)
waitFileSync.wait();
catch (Exception e)
return fileSuccess;
As I know getSupportedFormats doesn't support BMP files.
Similar Messages
-
my iphone 4s does not start by power switch, it starts when i connect to pc. the proximity sensor is not working. please help.
Sounds like it may be a hardware issue.
Please contact Apple Support in your country.
Here is a list of numbers: http://support.apple.com/kb/HE57
Regards
J -
I have unabled 5 fingure gesture now not able to perform any task,also my power button is not working,please help me in removing this gesture,using I phone 4
I have unabled 5 fingure gesture now not able to perform any task,also my power button is not working,please help me in removing this gesture,using I phone 4
-
I have 4s iPhone , I download the iOS 7. Now the front receiver microphone is not working , please help me that how to fix the problem.
I live in South Africa, and I had the same problem with my iPhone 4.
After weeks of frustration and swearing, I was in the process of restoring my phone to a previous iOS. To do that you need to turn the "Find my iPhone" option off, since i turned it off, my problem was solved. No need to repair anything or revert back to old iOS.
***** that i cant use Find my iPhone, but atleast i can use my phone. -
I installed windows 7 on my macbook pro. all is working but lan adaptor and sound od laptop is not working. please help me or send the link where i can download the these drivers.I have lost my resource cd .
If you are running Lion or Mountain Lion, the drivers are downloaded from within Bootcamp Assistant. If you are running Snow Leopard the drivers are on your Snow Leopard install disk.
Read the Bootcamp Install Guide for your version of OSx. http://www.apple.com/support/bootcamp/
Bootcamp questions should be asked in the Bootcamp forum where the Bootcamp gurus hang out https://discussions.apple.com/community/windows_software/boot_camp -
this is what my iphone 4 shows. iv tried switching off again and again, closing apps by double tapping the home button but still not working. please help.
is there any other method to download ios 6.1.2.
my phone is not being recognized by itunes on my new windows 8. neither its working on touch copy.
kindly help.
thankswell in thatcase, i need another help .
thanks for your instant reply.
i have currently bought a new laptop (windows 8) and my iphone is not being recognized by itunes.
because i have no backup on my previous laptop, i downloaded touchcopy but even touch copy is not recognizing my iphone. -
while updating 4.0 version to 5 version system shows sim card is not valid. My iphone is not working .Please help me
I would imagine your iPhone was hacked to make it work on your local carrier.
Updating the iOs to 5.xx will lock it back to the original carrier .The carrier holding the lock are the only
entity able to authorise the unlock .You will have to contact them and see if they unlock and the terms the apply -
HT1414 my handsfree is not working please help me
Hi There!
I am using Iphone 4s and ny handsfree in not working please help meTry restarting you iPhone by holding down the on/off and the home buttons at the same time until you see the Apple logo.
-
I have ne iphone 5, i been setting my email using AT&T global but it is not working, please help me on the correct configuration
Contact the email provider and obtain the correct setup information.
-
The built-in mic in g50 122ca laptop model is not working. please help me out.
the built-in mic in g50 122ca laptop model is not working. please help me out. OS: Windows Vista (32-bit)
here is a sample code .
so far you procedure looks good but
i bet you have to specify the name of report , instead of 'filename'.
see this
Plist_id := GET_PARAMETER_LIST('P_name');
IF NOT ID_NULL(Plist_id) THEN
DESTROY_PARAMETER_LIST(Plist_id);
END IF;
Plist_id := CREATE_PARAMETER_LIST('P_name');
ADD_PARAMETER( Plist_id, 'P_Receive_date', TEXT_PARAMETER, TO_CHAR(Receive_date,'mm/dd/yyyy'));
ADD_PARAMETER( Plist_id, 'P_Hearing_date', TEXT_PARAMETER, TO_CHAR(Hearing_date,'mm/dd/yyyy'));
ADD_PARAMETER( Plist_id, 'P_Hearing_time', TEXT_PARAMETER, TO_CHAR(Hearing_time,'mm/dd/yyyy'));
ADD_PARAMETER( Plist_id, 'P_Issue_date', TEXT_PARAMETER, TO_CHAR(Issue_date,'mm/dd/yyyy'));
ADD_PARAMETER( Plist_id, 'P_Workshop_date', TEXT_PARAMETER, TO_CHAR(Workshop_date,'mm/dd/yyyy'));
-- RUN_PRODCT(REPORTS,'..\Reports\Pro_License',SYNCHRONOUS, RUNTIME, FILESYSTEM, Plist_id, NULL);
-- here Pro_License is the name of report.
did you tried to see if the parameter passed using a message ?
try
message('parameter name'); pause; write this before "run_report". -
my itnues for pc is not working it shows that iTunes has stop working,I have downloaded Itnues many times but still it is not working, please help me
Please helppppp
-
All my old tv shows are not working please help my computer sed I have to Atheris 5 computers to play all my old tv shows I Pade for with eney Itunas cards.
What do y mean by not work?
What happens when y try to play them on yur iPod?
What happens when yo try to play them in iTunes on yur computer?
If you get a message what is the exact wording of the message?
You can redownload most iTunes purchases by:
Downloading past purchases from the App Store, iBookstore, and iTunes Store
Some countries do not allow redownloads some kinds of media -
The click at touchpad is not working, please help!!!
I use Macpro, recently the click at touchpad is not working, please help!!! Thank you !!
For this issue AppleCare support told me to so a SMC reset as follows:
Power the machine OFF.
At the SAME TIME hold down the following buttons:
Shift
Control
Option
Power
Then release all buttons. Power up the Macbook and see if the trackpad button work.
Hope this helps.
Bill -
hi
i tried to update to ios 8.2 on my iphone 5s when message popup to me now my iphone not working, please help i dont want to lose my dataWhat is the exact text of the message you got? And did you not back up before you updated?
-
After I updated my new Ipad with IOS 6, now Map& Dictation icon are not working. please help me
Thank you wjsten for your soon reply. Unfortunately on these days I'm in a country that Apple don't have any retail store here and for sake of time I prefer to fix it myself to DHL it to the nearest country to use its warranty. Do you have any idea how can I fix it? Do you think it's a software issue?
-
Whenever I go to facetime on my macbook air it says call failed. Both my WiFi and Facetime are connected. I tried turning my Facetime on, and off,yet it still does not work. please help.
Hey Ekfree95,
Thanks for the question, and great troubleshooting so far. The following article provides additional steps that may have to resolve your issue:
FaceTime for Mac: Troubleshooting FaceTime
http://support.apple.com/kb/TS4185
Thanks,
Matt M.
Maybe you are looking for
-
I need to download a c6500-fpd-pkg.151-1.SY.pkg patch
I need to download a c6500-fpd-pkg.151-1.SY.pkg patch, but I do not have this permission, no sales staff and Cisco contract number. Which friends can send a copy to me, thank you! My mail is [email protected] [email protected]-----------------
-
Purchase Requesition to Purchase Order
Hi Good Morning Friends I am facing some problem whicle using ME59 and ME59n (Automatic creation of purchase order from requesition) We are generation Req from Service Order or sales Order where Fixed vendor is coming by default but when we want to u
-
NIDAQmx: how to simultaneously acquire channels at different sample rates?
I have a PCI-6229 (M-series card). It has an advertised throughput of 250K/sec. I'd like to configure the card to simultaneously sample eight (8) AIN channels at 25K/sec, and none (9) AIN channels at 5K/sec. This results in a usage of about 245K/sec
-
Safari browser 5.0.6 not displaying all images on a specific site
I have a MAC running on PowerPC G5, with an OS X Version 10.5.8. I am using Safari browser version 5.0.6. I have been using the browser for years with out any problem until last week. All images show up on all sites except on one specific site. When
-
Hi table1 id cus_id val boi p gh hdc s vc 123 p xy 123 s xz 123 m xb 123 ll zx Note: 123 is default values o/p id cus_id val boi p gh boi s