How to create a YUV Player with JMF

Hey again,
Just wondering anyone could give me some pointers on how to go about creating a player for raw YUV files. I want to create a player or plugin that will allow the system to play raw YUV files, if given the relevent parameters, frame rate, resolution, YUV subsampling etc,
Thanks,
Stef

Ok, it's a bit course and I am looking into making a much neater version but this is code allows you to play local rawyuv files from a URL. This code is directly based on the "Generate Live Audio/Video Data" Sample Code (thanks again to mok524 for pointing me in this direction)
The code needs to be compiled and then the package 'ie.ucd.delboy' needs to be added to the Protocol Prefix List using the JMF Registry Editor. Then run the JMStudio and go to File>Open URL..
Then type in a URL in the following format:
rawyuv://<<local file location>>:F<<frame>>S<<width>>x<<height>>
example:
rawyuv://C:/my_directory/my_file.yuv:F10S352x176
So Here's the code:
package ie.ucd.delboy.media.protocol.rawyuv;
import javax.media.Time;
import javax.media.MediaLocator;
import javax.media.protocol.*;
import java.io.IOException;
import java.io.*;
import java.util.*;
import java.awt.*;
public class DataSource extends PushBufferDataSource
    protected Object[] controls = new Object[0];
    protected boolean started = false;
    protected String contentType = "raw";
    protected boolean connected = false;
    protected Time duration = DURATION_UNKNOWN;
    protected LiveStream[] streams = null;
    protected LiveStream stream = null;
    public DataSource()
    public String getContentType()
     if(!connected)
         System.err.println("Error: DataSource not connected");
         return null;
     return contentType;
    public void connect() throws IOException
     if(connected)
         return;
     connected = true;
    public void disconnect()
     try
         if(started)
          stop();
     catch(IOException e)
     connected = false;
    public void start() throws IOException
     // we need to throw error if connect() has not been called
     if(!connected)
         throw new java.lang.Error(
          "DataSource must be connected before it can be started");
     if(started)
         return;
     started = true;
     stream.start(true);
    public void stop() throws IOException
     if((!connected) || (!started))
         return;
     started = false;
     stream.start(false);
    public Object[] getControls()
     return controls;
    public Object getControl(String controlType)
     try
         Class cls = Class.forName(controlType);
         Object cs[] = getControls();
         for(int i = 0; i < cs.length; i++)
          if(cls.isInstance(cs))
          return cs[i];
     return null;
     catch(Exception e)
     return null;
public Time getDuration()
     return duration;
private String getFile()
     String url = getLocator().toString();
     int index_of_colon = url.indexOf(':');
     int index_of_last_colon = url.lastIndexOf(':');
     if(index_of_colon==index_of_last_colon)
     index_of_last_colon = url.length();
     String file = url.substring(index_of_colon+3, index_of_last_colon);
     return file;
private float getFrameRate()
     float frame_rate = 15; //15 set as default framerate
     String url = getLocator().toString();
     int index_of_last_colon = url.lastIndexOf(':');
     String params = url.substring(index_of_last_colon+1).toLowerCase();
     if(params.indexOf('f')!=-1)
     int start = params.indexOf('f')+1;
     int end = params.length();
     if(params.indexOf('s') > start)
          end = params.indexOf('s');
     frame_rate = Float.parseFloat(params.substring(start, end));
     return frame_rate;
private Dimension getFrameSize()
     Dimension d = new Dimension(176, 144); //QCIF as default
     String url = getLocator().toString();
     int index_of_last_colon = url.lastIndexOf(':');
     String params = url.substring(index_of_last_colon+1).toLowerCase();
     if(params.indexOf('s')!=-1)
     int start = params.indexOf('s')+1;
     int end = params.length();
     if(params.indexOf('f') > start)
          end = params.indexOf('f');
     String size = params.substring(start, end);
     int x = Integer.parseInt(size.substring(0,size.indexOf('x')));
     int y = Integer.parseInt(size.substring(size.indexOf('x')+1,size.length()));
     d = new Dimension(x, y);
     return d;
public PushBufferStream[] getStreams()
     if(streams == null)
     streams = new LiveStream[1];
     stream = streams[0] = new LiveStream(getFile(), getFrameRate(), getFrameSize());
     return streams;
package ie.ucd.delboy.media.protocol.rawyuv;
import java.awt.Dimension;
import javax.media.*;
import javax.media.format.*;
import javax.media.protocol.*;
import javax.media.protocol.DataSource;
import java.io.IOException;
import java.io.*;
public class LiveStream implements PushBufferStream, Runnable
    protected ContentDescriptor cd = new ContentDescriptor(ContentDescriptor.
     RAW);
    protected int maxDataLength;
    protected byte[] data;
    protected Dimension size;
    protected YUVFormat yuvFormat;
    protected AudioFormat audioFormat;
    protected boolean started;
    protected Thread thread;
    protected float frameRate = 5f;
    protected BufferTransferHandler transferHandler;
    protected Control[] controls = new Control[0];
    private FileInputStream fis = null;
    private FileOutputStream fos = null;
    private boolean EOS = false;
    protected boolean videoData = true;
    public LiveStream(String location, float frame_rate, Dimension frame_size)
     frameRate = frame_rate;
     try
         fis = new FileInputStream(location);
         fos = new FileOutputStream("C:\\stef_temp\\log_data.txt");
     catch(Exception ex)
         System.exit(1);
     int x, y, pos, revpos;
     size = frame_size;
     maxDataLength = size.width * size.height * 3;
     yuvFormat = new YUVFormat(size,
                      maxDataLength,
                      Format.byteArray,
                      frameRate,
                      YUVFormat.YUV_420,
                      size.width,
                      size.width / 2,
                      0,
                      size.height * size.width,
                      size.height * size.width +
                      ((size.height / 2) * (size.width / 2)));
     thread = new Thread(this);
    public ContentDescriptor getContentDescriptor()
     return cd;
    public long getContentLength()
     return LENGTH_UNKNOWN;
    public boolean endOfStream()
     return EOS;
    int seqNo = 0;
    double freq = 2.0;
    public Format getFormat()
     return yuvFormat;
    public void read(Buffer buffer)
     synchronized(this)
         Object outdata = buffer.getData();
         if(outdata == null || !(outdata.getClass() == Format.byteArray) ||
            ((byte[]) outdata).length < maxDataLength)
          outdata = new byte[maxDataLength];
          buffer.setData(outdata);
         buffer.setFormat(yuvFormat);
         buffer.setTimeStamp((long) (seqNo * (1000 / frameRate) * 1000000));
         try
          fos.write(("Bytes left in file: "+fis.available()+"\n").getBytes());
          if(fis.available()==0)
              fos.write("Reached end of file!\n".getBytes());
              fis.close();
              fos.close();
              EOS = true;
          fis.read((byte[]) outdata);
         catch(IOException ex)
         buffer.setSequenceNumber(seqNo);
         buffer.setLength(maxDataLength);
         buffer.setFlags(0);
         buffer.setHeader(null);
         seqNo++;
    public void setTransferHandler(BufferTransferHandler transferHandler)
     synchronized(this)
         this.transferHandler = transferHandler;
         notifyAll();
    public void start(boolean started)
     synchronized(this)
         this.started = started;
         if(started && !thread.isAlive())
          thread = new Thread(this);
          thread.start();
         notifyAll();
    public void run()
     while(started)
         synchronized(this)
          while(transferHandler == null && started)
              try
               wait(1000);
              catch(InterruptedException ie)
         if(started && transferHandler != null)
          transferHandler.transferData(this);
          try
              Thread.currentThread().sleep(10);
          catch(InterruptedException ise)
    public Object[] getControls()
     return controls;
    public Object getControl(String controlType)
     try
         Class cls = Class.forName(controlType);
         Object cs[] = getControls();
         for(int i = 0; i < cs.length; i++)
          if(cls.isInstance(cs))
          return cs[i];
     return null;
     catch(Exception e)
     return null;

Similar Messages

  • How to create a Macromedia's Flash Java Player with JMF?

    How to create a Macromedia's Flash Java Player with JMF? Can you give me an example? My email:[email protected] [email protected]

    Yes, there is a way. Look up JTree in the API.-can you post some code.... i cant figure out on how to use JTree...
    i'm still confused on where will i get the entire directories of my drives...
    thanks

  • How to create an unsolved cube with awm???

    hi all,
    I readed the "Oracle Olap developer's guide to the Oalp api" and I found there's 2 type of Cube: Solved and Unsolved Cubes. And this document says: "... if all the data for a cube is specified by the DBA, then the cube is considered to be Solved. If some or all of the aggregate data must be calculated by Oracle OLap, then the cube is unsolved ..."
    I tried with awm 10.2.0.3.0A to create an unsolvedCube but I can't. All cubes I created are solvedCube. To know if a cube is solved or unsolved, I wrotte an program in Java to read informations of package mtm.
    Some one can tell me how to create an unsolved cube with AWM ou other soft please!

    SH is not a relational OLAP data model which is quite different from the GLOBAL schema which is based on an Analytic Workspace.
    If you change the aggregation method you will need to re-compute the whole cube which can be a very big job! You might be able to force the unsolved status be de-selecting all the levels on the Rules tab in AWM. However, I think by default analytic workspace OLAP models always provide a fully solved cube to the outside world. This is the nature of the multi-dimensional model.
    Relationally, as keys are located in separate columns a cube can be unsolved in that the key column only contains values for a single level from the corresponding dimension tables. If more than keys for different levels within the same dimension appear within the fact key column then the cube is deemed as being solved.
    Therefore, I am not sure you are going to get the information you require from the API. To changes the aggregation method you will have to switch off all pre-compute options and also disable the session cache to prevent previously calculated data being returned when you change the aggregation method.
    Hope this helps
    Keith Laker
    Oracle EMEA Consulting
    BI Blog: http://oraclebi.blogspot.com/
    DM Blog: http://oracledmt.blogspot.com/
    BI on Oracle: http://www.oracle.com/bi/
    BI on OTN: http://www.oracle.com/technology/products/bi/
    BI Samples: http://www.oracle.com/technology/products/bi/samples/

  • How to create an explain plan with rowsource statistics for a complex query that include multiple table joins ?

    1. How to create an explain plan with rowsource statistics for a complex query that include multiple table joins ?
    When multiple tables are involved , and the actual number of rows returned is more than what the explain plan tells. How can I find out what change is needed  in the stat plan  ?
    2. Does rowsource statistics gives some kind of  understanding of Extended stats ?

    You can get Row Source Statistics only *after* the SQL has been executed.  An Explain Plan midway cannot give you row source statistics.
    To get row source statistics either set STATISTICS_LEVEL='ALL'  in the session that executes theSQL OR use the Hint "gather_plan_statistics"  in the SQL being executed.
    Then use dbms_xplan.display_cursor
    Hemant K Chitale

  • How to create a Sales order with ref to Contract using Function Module

    How to create a Sales order with ref to Contract using Function Module BAPI_SALESDOCU_CREATEFROMDATA ?

    We have a unique situation where we like change the sold-to customer of the sales order
    once order has been created. These orders have been created using either by function module
    BAPI_SALESDOCUMENT_COPY or using BDC (VA01, Copy with reference).
    These two processes work abosolutely fine except someone might have change the sold-to
    customer of the ship-to customer of the original sales order. If this the case then the new
    sales order will be created with the old sold-to and with not the new sold-to.
    We tried using BAPI_SALESDOCUMENT_CHANGE and commit afterwards. We checked
    the returned parameteres of the BAPIs and they are all successful but sold-to remains the
    same old one.
    Any help would be much more appreciated.

  • How to create a pdf file with CS5

    Hello, I'm new to PhotoShop CS5 and haven't figured out yet (despite two hours of trying) how to create a pdf file with pictures and texts.  Can someone please help me with this ?  The "help" button in CS5 doesn't seem to cover this question.  Nor do the FAQs.
    Thank you very much.

    Save As... Photoshop PDF.

  • How to update adobe flash player with os10.6.8

    how to update adobe flash player with os10.6.8

    You can check here what version of Flash player you actually have installed:  http://kb2.adobe.com/cps/155/tn_15507.html
    You can check here:  http://www.adobe.com/products/flash/about/  to see which version you should install for your Mac and OS. You should first uninstall any previous version of Flash Player, using the uninstaller from here (make sure you use the correct one!):
    http://kb2.adobe.com/cps/909/cpsid_90906.html
    and also that you follow the instructions closely, such as closing ALL applications (including Safari) first before installing. You must also carry out a permission repair after installing anything from Adobe.
    After installing, reboot your Mac and relaunch Safari, then in Safari Preferences/Security enable ‘Allow Plugins’. If you are running 10.6.8 or later:
    When you have installed the latest version of Flash, relaunch Safari and test.
    If you're getting a "blocked plug-in" error, then in System Preferences… ▹ Flash Player ▹ Advanced
    click Check Now. Quit and relaunch your browser, but check this also:
    http://support.apple.com/kb/HT5655?viewlocale=en_US&locale=en_US  which also covers ‘blocked plug-in’.

  • How to create  a test plan with specific transactions (or program)

    Hello,
    I'm a new user in Sol Man !
    How to create  a test plan with specific transactions (or program).
    In my Business Blueprint (SOLAR01) I've created in 'transaction tab' the name of my specific transactions and linked it.
    In my test plan (STWB_2) those specific doesn't appear to be selected !
    Thanks in advance.
    Georges HUYNEN

    Hi 
    In solar01 you have defined but you have to assign the test case in solar02 for this test case in the test cases tab.
    When you do so expand the business sceanario node in test plan generation of STWB_2 transaction and now that will appear.
    Also visit my weblog
    /people/community.user/blog/2006/12/07/organize-and-perform-testing-using-solution-manager
    please reward points.

  • How to create a web template with company logo

    how to create a web template with company logo . can any one help me with the steps. or any notes. thnaks in advance .
    2. i have 25000 articles and client want to have a selection feild to see top article ex:50,10,20, 100, 1000 etc . same for bottom articles . plz let me know how to do it . thanks for replay . i am new bw so plz .
    thanks to you all

    Hi
    1) Please read
    http://help.sap.com/saphelp_nw04/helpdata/en/4a/c8353c51aab32be10000000a114084/frameset.htm
    2) Create a condition in the Query Designer: Use a formula variable
    See http://help.sap.com/saphelp_nw04/helpdata/en/73/702e39074dc93de10000000a114084/frameset.htm
    Heike

  • How to create a transport request with query and only with its structure.

    HI guru,
                how to create a transport request with query and only with its structure.transport request should not  include any other query items like ( variables, conditions...etc)
    thanks in advance.
    venkata

    Hi,
    Goto RSA1 and then Transport Connection -> In SAP Transports select Object Types-> Query Elements -> Then select Query->Give Technical name of the query and then select for transfer. In the right side you can choose the components which you wanted to transport.
    Regards,
    anil

  • How to create a csv file with NCS attributes?

    Hi
    i installed Cisco Prime NCS and trying to perform bulk update of device credentials with csv file.
    How to create a csv file with all required attributes?
    This is part of NCS online help talking about this topic:
    Bulk Update Devices—To update the device credentials in a bulk, select Bulk Update Devices from the Select a command drop-down list. The Bulk Update Devices page appears.You can choose a CSV file.
    Note        The CSV file contains a list of devices to be updated, one device per line. Each line is a comma separated list of device attributes. The first line describes the attributes included. The IP address attribute is mandatory.
    Bellow is test csv file i created but does not work:
    10.64.160.31,v2c,2,10,snmpcomm,ssh,zeus,password,password,enablepwd,enablepwd,60
    10.64.160.31,v2c,2,10,snmpcomm,ssh,zeus,password,password,enablepwd,enablepwd,60
    The error i am getting while importing this file:
    Missing mandatory field [ip_address] on header line:10.64.160.31,v2c,2,10,snmpcomm,ssh,zeus,password,password,enablepwd,enablepwd,60
    Assistance appreciated.

    It looks like the IP address field is incorrectly set.,
    It should be as follows
    {Device IP},{Device Subnet Mask}, etc etc
    so a practical example of the aboove could be (i dont know if this is completely correct after the IP address / Subnet Mask)
    10.64.160.31,255.255.255.0,v2c,2,10,snmpcomm,ssh,zeus,password,password,enablepwd,enablepwd,60
    below is a link to the documentation
    http://www.cisco.com/en/US/docs/wireless/ncs/1.0/configuration/guide/ctrlcfg.html#wp1840245
    HTH
    Darren

  • How to create a procedure function with a return value of ref cursor?

    Can anybody provide a sample about how to create a procedure function with a return value of REF CURSOR?
    I heard if I can create a function to return a ref cursor, I can use VB to read its recordset.
    Thanks a lot.

    http://osi.oracle.com/~tkyte/ResultSets/index.html

  • How can i make audio player with osmf??

    i want to know how can i make audio player with osmf and flex4.5 ?

    Thanks again...I suppose I'd just like it louder in case the radio is on when the directions are given. The difference between the iPhone & Nokia is like night & day!
    BTW, do you know if the Maps program is using data from my cell phone plan as we drive? Or are the corresponding maps downloaded into the phone once for the trip?
    Thanks again!!

  • How to create an install cd with the final cut pro x app if the app comes from App.Store?

    How to create an install cd with the final cut pro x app if the app comes from App.Store?

    Just copy the Application FCPX to your CD. When you want to install drag the FCPX to the Application folder and you are done.

  • How to create item wise invoice with reference to sales order.

    Hi ,
    Please let me know how to create item wise invoice with reference to sales order.
    Ex : Sales order has 2 line items .
              When creating invoice system should create two invoices for each line items.
    I have tried with copy control but I am not able to do it.
    Please advise.
    Regards

    Hi,
    Please let us know your exact requirement. Whether you want it to be fixed like only one line item to be billed every time ot it to be based on selection you do every time.
    As per my understanding it should not be fixed and in that case it should like as follows,
    In VF01 you will select Del. document/S.O. number and click on selection list and will take you to next screen as mention below,
    and select desire line item to be billed and click on copy and will take you to billing screen.
    Regards,
    Ajit K Singh

Maybe you are looking for

  • Automatic Creation of Quality Notification

    Dear All, In standard SAP whenever defects recording is done for an inspection lot and saved,automatically a quality notification is also created.In my business scenario they will record defects for almost all the inspection lots hence resulting in a

  • Saving a .pdf

    Why does a file saved in Acrobat as a .pdf have a Word logo?

  • SOAP sync to JMS async

    Hi Everyone, I'm trying to create the following scenario in SAP PI 7.31 but after a lot of thinking I do not see how I can create it in PI. I have JMS queues and topics where messages are stored. I need to make a soap call from a client app to PI to

  • Error when installing Quicktime 7.1.3

    I'm having trouble updating my iTunes/QuickTime to the newest version. The error I get is: Could not open key: HKEYLOCALMACHINE\Software\Classes\QuickTimePlayerLib.QuickTimePlayerApp\CLSID. Verify that you have sufficient access to that key, or conta

  • XI receiving scenario example

    Hi Friends, I had searched on sdn for different scenario in XI , most of them are for sendin message out of system, but I didnt got any scenario which shows receiving of message from external system... So can you please provide some link where I can