2017-09-30 11 views
0

Java Gstreamerバインディング1を使用して、ディスクからオーディオファイルを読み込み、このファイルのセグメントをディスクに書き戻したいとします。このため、 "filesrc"要素を使用することはできませんが、代わりにGnonlinプラグインの "gnlurisource"要素を使用できることがわかりました。2Java Gstreamer Gnonlinソースセグメンテーション

私はGstreamer Javaバインディングを使用しました。ローカルにコンパイルして、プロジェクトに追加したjarファイルを取得しました。私はまた、次のコマンドを使用してUbuntuでのGStreamerをインストール:

sudo apt-get install libgstreamer1.0-dev 
sudo apt-get install gstreamer1.0-gnonlin 

プログラムがエラーなしでコンパイルが、それは残ったままと何もしません。私は私のプログラムコードを添付して下記

import java.util.concurrent.TimeUnit; 
import org.freedesktop.gstreamer.Element; 
import org.freedesktop.gstreamer.ElementFactory; 
import org.freedesktop.gstreamer.Gst; 
import org.freedesktop.gstreamer.Pipeline; 
import org.freedesktop.gstreamer.State; 


public class AudioSegmentation { 

public static void main(String[] args) { 

    Pipeline pipe; 
    Element asr; 
    Element composition; 
    Element gnlsource; 
    Element convert; 
    Element filesink; 

    Gst.init(); 

    pipe = new Pipeline("SimplePipeline"); 
    composition = ElementFactory.make("gnlcomposition", "comp"); 
    gnlsource = ElementFactory.make("gnlurisource", "gnlsource"); 

    convert = ElementFactory.make("audioconvert", "compconvert"); 
    filesink = ElementFactory.make("filesink", "filesink"); 

    gnlsource.set("uri", "file:///home/user/Desktop/file-source.wav"); 
    gnlsource.set("start", TimeUnit.SECONDS.toNanos(5)); 
    gnlsource.set("duration", TimeUnit.SECONDS.toNanos(2)); 

    filesink.set("location", "/home/user/Desktop/file-destination.wav"); 

    composition.link(gnlsource); 
    pipe.addMany(composition, convert, filesink); 
    Element.linkMany(composition, convert, filesink); 

    pipe.setState(State.PLAYING); 
    Gst.main(); 
    Gst.quit(); 

} 

}

私はGStreamerを持つので、多くの経験を持っていないが、あなたは私が悪いのかについてのヒントを与えることができますか?

ありがとうございました!

答えて

0

更新:コマンドラインからgstreamerを使用して、オーディオファイルからセグメントを選択することができました。 "gnlurisource"要素には、セグメントの開始時間を設定するための "inpoint"パラメータと、セグメントの持続時間を指定する "duration"があります。私はまだJavaでこのパイプラインを実装しようとしている

gst-launch-1.0 gnlurisource uri=file:///home/user/Desktop/file-source.wav inpoint=2000000000 duration=1500000000 ! audioconvert ! wavenc ! filesink location=/home/user/Desktop/file-destination.wav 

: はここでコマンドです。私はそのようなものを試しましたが、うまくいかない:

import java.util.concurrent.TimeUnit; 
import org.freedesktop.gstreamer.Element; 
import org.freedesktop.gstreamer.ElementFactory; 
import org.freedesktop.gstreamer.Gst; 
import org.freedesktop.gstreamer.Pipeline; 
import org.freedesktop.gstreamer.State; 


public class AudioSegmentation { 

public static void main(String[] args) { 

    Pipeline pipe; 
    Element gnlsource; 
    Element audioconvert; 
    Element wavenc; 
    Element filesink; 

    Gst.init(); 

    pipe = new Pipeline("SimplePipeline"); 
    gnlurisource = ElementFactory.make("gnlurisource", "gnlurisource"); 
    audioconvert = ElementFactory.make("audioconvert", "audioconvert"); 
    wavenc = ElementFactory.make("wavenc", "wavenc"); 
    filesink = ElementFactory.make("filesink", "filesink"); 

    gnlurisource.set("uri", "file:///home/user/Desktop/file-source.wav"); 
    gnlurisource.set("inpoint", TimeUnit.SECONDS.toNanos(2)); 
    gnlurisource.set("duration", TimeUnit.SECONDS.toNanos(3)); 

    filesink.set("location", "/home/user/Desktop/file-destination.wav"); 

    pipe.addMany(gnlurisource, audioconvert, wavenc, filesink); 
    Element.linkMany(gnlurisource, audioconvert, wavenc, filesink); 

    pipe.setState(State.PLAYING); 
    Gst.main(); 
    Gst.quit(); 

}