How to ’embed’ subtitles into mp4 video

If you ever want to embed or burn subtitles into an mp4 video file, just use ffmpeg. See below:

ffmpeg -i infile.mp4 -f srt -i infile.srt -c:v copy -c:a copy -c:s mov_text outfile.mp4
Advertisements

Convert MKV video to MP4 via Terminal

Converting MKV video is super fast via terminal. This can be done on Linux or Mac.

Install ffmpeg

sudo apt-get install ffmpeg
OR
sudo brew install ffmpeg

Example:

To convert video.mkv to video.mp4 use the command below:

ffmpeg -i video.mkv -vcodec copy -acodec copy video.mp4

This 183MB file took less than 20 seconds to convert.screen-shot-2016-09-22-at-22-13-42

This 183MB file took less than 20 seconds to convert.

Tip: To convert all the mkv files in current directory, run a simple loop in terminal:

for i in *mkv; do ffmpeg -i $i -vcodec copy -acodec copy $i.mp4; done

Make a bootable Ubuntu USB drive on a Mac in under 20 minutes.

This article details how to easily create a bootable Ubuntu USB drive that be completed in less than 20 mins (May be 10 if you’ve a fast usb drive). Having a faster USB drive would help in the long run too!

osx_versus_ubuntu_linux_thumb800

Note: this procedure requires that you create an .img file from the .iso file you download. It will also change the filesystem that is on the USB stick to make it bootable, so backup all data before continuing.

Tip: Drag and drop a file from Finder to Terminal to ‘paste’ the full path without risking typing errors.

  1. Download Ubuntu Desktop
  2. Open the Terminal (in /Applications/Utilities/ or query Terminal in Spotlight)
  3. Convert the .iso file to .img using the convert option of hdiutil. Example:
    hdiutil convert -format UDRW ~/path/to/target.iso -o ~/path/to/ubuntu.img
    

    Note: OS X tends to put the .dmg ending on the output file automatically.

  4. Run diskutil list to get the current list of devices
  5. Insert your flash media
  6. Run diskutil list again and determine the device node assigned to your flash media
    (e.g. /dev/disk2)
  7. Run
    diskutil unmountDisk /dev/diskN
    

    (replace N with the disk number from the last command; in the previous example, N would be 2) If if fails to unmount with errors, use the ‘force’ command:

    sudo diskutil unmountDisk force /dev/diskN
  8. Execute the following command while replacing /path/to/downloaded.img with the path where the image file is located; for example, ./ubuntu.img or ./ubuntu.dmg).
    sudo dd if=/path/to/downloaded.img of=/dev/rdiskN bs=1m
    
    • Using /dev/rdisk instead of /dev/disk may be faster.
    • If you see the error dd: Invalid number '1m', you are using GNU dd. Use the same command but replace bs=1m with bs=1M.
    • If you see the error dd:/devdiskN: Resource busy, make sure the disk is not in use. Start the Disk Utility.app and unmount (don’t eject) the drive.
  9. Run diskutil eject /dev/diskN and remove your flash media when the command completes
  10. Restart your Mac and press Alt while the Mac is restarting to choose the USB-Stick (This should also work on a PC)

Run a HTTP server in any folder (Mac)

Use this one-liner to serve any directory on Mac on the local network. Navigate to the directory in the terminal first.

python -m SimpleHTTPServer 8000

You can also leave the port out so that it uses the default port 80.

Now, in a browser, type in the below to access the directory files.

http://localhost:8000

Use CTRL+C to end.

If other devices on the local network want to access, replace localhost with your local ip e.g. below:

http://192.168.0.14:8000

Screen Shot 2016-07-16 at 23.15.23

Most frequent Linux tools  – Quick start guide

This quick one minute video demonstrates how to use some of the most frequently used tools in Linux or Mac. The processes are elaborated below as this video does not contain any audio. This quick video is from my Mac. Leave comments or questions at the bottom.

Tools demoed:
 vi
 less
 cat
 grep
 awk
The above video demonstrates the following:
  • How to create a directory called tutorial in Linux – the mkdir command
    mkdir tutorial
  • Navigate into the directory
    cd tutorial/
  • How to get a list of contents in directory
    ls
  • How to create file named file.txt using vi or vim and save it
    vi file.txt

    to open editor, then press ‘i’ to start inserting text and ESC to come out of writing mode; and to save and quit, use ‘:wq’ and ENTER!

  • How to quickly view the file without it hogging the screen permanently using less –
    less file.txt

    and then ‘q’ to exit viewing

  • How to view the file in a manner that it stays on the terminal screen using cat
    cat file.txt
  • How to find the string ‘make’ in the file or every occurrence of this string using grep
    grep make file.txt
  • How to use awk to print only certain strings from a line in the file – basically, we want to print certain strings from a line, so its clever to choose a string that is only in that line and grep it first so that we have the line alone; then pipe (|) it to awk to filter the strings using – In this case, awk prints the 4th, 8th, 9th and 10th string from the grep result as output.
    grep ‘abracadabra’ file.txt | awk ‘{print $4,$8,$9,$10}’
 Screen Shot 2016-06-12 at 13.19.14.png
 
In addition to these tools, there are various other tools used (e.g. sed, tail etc) that come in handy with these tools. Please leave any comments or questions. Thanks for visiting.

Gemstones

These gemstones are available. Contact me on +447710874066

IMG_9811
Pink Sapphire (Untreated) lot 3.22 Carats £275