すみません、簡単な質問:
ビデオストリームのこのルーチンがあり、パケットを受信し、それらを byte[] に変換し、次にビットマップに変換してから、画面に表示します。
dsocket.receive(packetReceived); // receive packet
byte[] buff = packetReceived.getData(); // convert packet to byte[]
final Bitmap ReceivedImage = BitmapFactory.decodeByteArray(buff, 0, buff.length); // convert byte[] to bitmap image
runOnUiThread(new Runnable()
{
@Override
public void run()
{
// this is executed on the main (UI) thread
imageView.setImageBitmap(ReceivedImage);
}
});
さて、録音機能を実装したいと思います。FFmpeg を使用する必要があるとの提案がありますが (方法はわかりません)、まず、注文した画像のディレクトリを準備して、それをビデオ ファイルに変換する必要があります。すべての画像を内部的に保存します。この回答を使用して各画像を保存しています。
if(RecordVideo && !PauseRecording) {
saveToInternalStorage(ReceivedImage, ImageNumber);
ImageNumber++;
}
else
{
if(!RecordVideo)
ImageNumber = 0;
}
// ...
private void saveToInternalStorage(Bitmap bitmapImage, int counter){
ContextWrapper cw = new ContextWrapper(getApplicationContext());
// path to /data/data/yourapp/app_data/imageDir
File MyDirectory = cw.getDir("imageDir", Context.MODE_PRIVATE);
// Create imageDir
File MyPath = new File(MyDirectory,"Image" + counter + ".jpg");
FileOutputStream fos = null;
try {
fos = new FileOutputStream(MyPath);
// Use the compress method on the BitMap object to write image to the OutputStream
bitmapImage.compress(Bitmap.CompressFormat.PNG, 100, fos);
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
fos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
//return MyDirectory.getAbsolutePath();
}
しかし、デバイスでディレクトリが見つからないようです (ディレクトリの作成に成功したかどうかを実際に確認するため)// path to /data/data/yourapp/app_data/imageDir
正確にはどこにありますか?