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() {

        @Override
        public void handleMessage(Message msg) {
            switch (msg.what) {
                case MSG_REGISTER_WATCHER:
                    if (!clients.contains(msg.replyTo)) {
                        clients.add(msg.replyTo);
                    }
                    break;

                case MSG_UNREGISTER_WATCHER:
                    if (clients.contains(msg.replyTo)) {
                        clients.remove(msg.replyTo);
                    }
                    break;

                // 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.setData(msg.getData());
                msg2.replyTo = msg.replyTo;
                clients.get(i).send(msg2);
            } catch (RemoteException e) {
                clients.remove(i);
            }
        }
    }

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

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

    @Nullable
    @Override
    public IBinder onBind(Intent intent) {
        return clientMessenger.getBinder();
    }

    @Override
    public void onCreate() {
        super.onCreate();
    }

    @Override
    public void onDestroy() {
        super.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">
        <shape> 
            <solid android:color="#2b7996"/>
            <stroke android:color="#33b5e5" android:width="6dp"/>
        </shape>
    </item>
</layer-list>

Continue Reading
1 2 3 9