ffmpeg add hardcoded subtitles to video

This command converts video to video

  • with hardcoded subtitles
  • with forced font size 30
  • with color yellow

ffmpeg -i video.mp4 -vf "subtitles=subtitle.srt:force_style='Fontsize=30,PrimaryColour=&H00ffff&'" "output.mp4"

And this command converts only sample from 120s to 300s

ffmpeg -ss 120 -t 300 -i video.mp4 -vf "subtitles=subtitle.srt:force_style='Fontsize=32,PrimaryColour=&H00ffff&'" output.mp4

And this is the default command just to add subtitles

ffmpeg -i video.mp4 -vf "subtitles=subtitle.srt" "output.mp4"


Continue Reading

Raw service with bindings

public class Request2Service extends Service {

    public static final int MSG_REGISTER_WATCHER = -1;
    public static final int MSG_UNREGISTER_WATCHER = -2;

    private ArrayList<Messenger> clients = new ArrayList<>();

    private Messenger clientMessenger = new Messenger(new Handler() {

        public void handleMessage(Message msg) {
            switch (msg.what) {
                case MSG_REGISTER_WATCHER:
                    if (!clients.contains(msg.replyTo)) {

                case MSG_UNREGISTER_WATCHER:
                    if (clients.contains(msg.replyTo)) {

                // TODO: 2017-07-12 case: ... 

    private ExecutorService executor = Executors.newCachedThreadPool();

    private static void sendToClients(ArrayList<Messenger> clients, Message msg) {

        for (int i = clients.size() - 1; i >= 0; i--) {
            try {
                Message msg2 = Message.obtain();
                msg2.what = msg.what;
                msg2.arg1 = msg.arg1;
                msg2.arg2 = msg.arg2;
                msg2.replyTo = msg.replyTo;
            } catch (RemoteException e) {

    public int onStartCommand(final Intent intent, int flags, final int startId) {
        if (intent != null && intent.getAction() != null) {
            executor.execute(new Runnable() {
                public void run() {
        return START_STICKY;

    private void handleStartCommand(Intent intent) {
        // TODO: 2017-07-12  

    public IBinder onBind(Intent intent) {
        return clientMessenger.getBinder();

    public void onCreate() {

    public void onDestroy() {


Continue Reading

Drawable bottom line

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:top="-6dp" android:left="-6dp" android:right="-6dp">
            <solid android:color="#2b7996"/>
            <stroke android:color="#33b5e5" android:width="6dp"/>

Continue Reading

Passing bitmap to bundle

I found this somewhere in Internet and I thought it would be useful someday

To pass bitmap to bundle, first we ought to convert it to byte array. Then the rest goes straight.

public static byte[] toByteArray(Bitmap bmp) {
    ByteArrayOutputStream stream = new ByteArrayOutputStream();
    bmp.compress(Bitmap.CompressFormat.PNG, 100, stream);
    return stream.toByteArray();

public static Bitmap fromByteArray(byte[] byteArray) {
    return BitmapFactory.decodeByteArray(byteArray, 0, byteArray.length);


Continue Reading

Helper to compare i.e two months in different years

This method will help in comparing two dates by trimming date format to our specific format. So we avoid unnecessary data.


We compare two months in different years. First date is:

2017-10-10 10:00

First we convert it to milliseconds using `SimpleDateFormat`.

We want know only time for


So after we get millisecond, we can convert it to another one `yyyy-MM-dd` using code below:

public long getTimeInMillis(long milliSeconds, String dateFormat) {
    SimpleDateFormat formatter = new SimpleDateFormat(dateFormat, Locale.forLanguageTag("pl"));
    Calendar calendar = Calendar.getInstance();
    String format = formatter.format(calendar.getTime());

    long milli = milliSeconds;

    SimpleDateFormat sdf = new SimpleDateFormat(dateFormat, Locale.forLanguageTag("pl"));
    try {
        Date parse = sdf.parse(format);
        Calendar c = Calendar.getInstance();
        milli = c.getTimeInMillis();
    } catch (ParseException e) {

    return milli;
Continue Reading
1 2 3 9