0

そのため、ビデオ ファイルの作成に使用する Java パッケージに関するいくつかの推奨事項を受け取った後、JMF にサンプルとして付属する JPEGImagesToMovie ファイルを変更してみることにしました。すべてをコンパイルすることができたので、実行する必要があるようです。新しいクラスは BufferedImages の Vector を受け取る必要があり、以前のようにファイルから読み取ってバイト配列に変換する代わりに、BufferedImage からバイト配列に直接変換します。問題は、プロセッサが構成されないという事実にあります (ロックアップなど)。これを引き起こしている明らかな欠陥を誰かが見ることができますか?

また、より優れた、より簡単な、よりシンプルなフレームワークを使用するための提案に対して、私はまだ完全にオープンです。

編集:これは私が実際に何かをしたコードです。読みやすくするために、ここで少しクリーンアップしました。

class ImageDataSource extends PullBufferDataSource {

ImageSourceStream streams[];

ImageDataSource(int width, int height, int frameRate, Vector images) {
    streams = new ImageSourceStream[1];
    streams[0] = new ImageSourceStream(width, height, frameRate, images);
}

/**
 * The source stream to go along with ImageDataSource.
 */
class ImageSourceStream implements PullBufferStream {

Vector images;
int width, height;
VideoFormat format;

int nextImage = 0;  // index of the next image to be read.
boolean ended = false;

public ImageSourceStream(int width, int height, int frameRate, Vector images) {
    this.width = width;
    this.height = height;
    this.images = images;

    format = new VideoFormat(null,
            new Dimension(width, height),
            Format.NOT_SPECIFIED,
            Format.byteArray,
            (float)frameRate);
}

/**
 * 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 >= images.size()) {
    // We are done.  Set EndOfMedia.
    System.err.println("Done reading all images.");
    buf.setEOM(true);
    buf.setOffset(0);
    buf.setLength(0);
    ended = true;
    return;
    }

    BufferedImage imageFile = (BufferedImage)images.elementAt(nextImage);
    nextImage++;


    byte data[] = ImageToByteArray.convertToBytes(imageFile);
    // 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.

    buf.setData(data);

    buf.setOffset(0);
    buf.setLength((int)data.length);
    buf.setFormat(format);
    buf.setFlags(buf.getFlags() | buf.FLAG_KEY_FRAME);
}

私が確信が持てなかったのは、VideoFormat のエンコーディングとして何を使用するかということです。

4

1 に答える 1

0

真剣に、Xugglerでこれを行うことを検討する必要があります。

于 2010-02-08T16:41:19.030 に答える