2

i am doing video recording and save recording in my folder inside sdcard..now when i play video from sdcard i want to add date and time in video view , i am done with image means able to add time stamp in Image view using frame layout and Z-index but how would it to be done with video recording ..is it possible or not? if yes please suggest any way.. my code for adding time stamp in Image are given below with refrence URl..:

http://www.ilovefreesoftware.com/29/android-2/how-to-auto-capture-date-and-time-on-photos-taken-from-android.html

now how to do this same for video?

any help would be greatly apprciated here...

 Bitmap src = BitmapFactory.decodeResource(getResources(), R.drawable.splashmodified); // the original file is cuty.jpg i added in resources
  Bitmap dest = Bitmap.createBitmap(src.getWidth(), src.getHeight(), Bitmap.Config.ARGB_8888);

  SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  String dateTime = sdf.format(Calendar.getInstance().getTime()); // reading local time in the system

  Canvas cs = new Canvas(dest);
  Paint tPaint = new Paint();
  tPaint.setTextSize(35);
  tPaint.setColor(Color.BLUE);
  tPaint.setStyle(Style.FILL);
  cs.drawBitmap(src, 0f, 0f, null);
  float height = tPaint.measureText("yY");
  cs.drawText(dateTime, 20f, height+15f, tPaint);
  try {
      dest.compress(Bitmap.CompressFormat.JPEG, 100, new FileOutputStream(new File("/sdcard/timeStampedImage.jpg")));
  } catch (FileNotFoundException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
  }

}
SRam
  • 2,832
  • 4
  • 45
  • 72
  • You might be interested in an approach using MediaRecorder and mobile-ffmpeg [here](https://stackoverflow.com/a/65505434/361413). – bk138 Dec 30 '20 at 10:27

1 Answers1

0

If you're asking how to simply display something on top of your video, the answer is sure... just use a relative layout and put your TextView in the same coordinates as the SurfaceView you're using for your Camera preview... as long as it is after the SurfaceView in the XML it will draw on top of it.

Or if you insist on drawing your text to Canvas, put your drawing surface view on top of the Camera preview. Either way, as long as it's added to the parent view after the Cam surface it will draw on top of it.

Yevgeny Simkin
  • 27,946
  • 39
  • 137
  • 236