Archive for ‘CLI’ Category
Browse:
CLI »
Subcategories:

Stream your Windows desktop using ffmpeg

datePosted on 10:26, November 3rd, 2011 by Many Ayromlou

I’ve already covered how to do this with vlc a while back in parts 1 followed by part 2. I just found out that something very similar in results can be done with ffmpeg. ffmpeg has recently added support for directshow filters which now allows one to capture the screen and stream and/or save it. Here is how you can do this:

1.) Grab a copy of the Screen Capture DirectShow source filter from Unreal Streaming Technologies. It’s about half way down that page. They have both the UScreenCapture X86 Edition and the X64 Edition (depending on your OS installation). I used the 64 bit filter on a Windows 7 64 bit installation.

2.) Install the filter and make sure you make the following changes to your windows registry using regedit. The default frame rate for UScreenCapture filter is 10 f/s and we need to boost this to 30 frames/sec. You need to find the key HKLM\SOFTWARE\UNREAL\Live\UScreenCapture and insert a DWORD value of 30 for FrameRate (You have to create FrameRate, it does not exist by default). Once you’ve done the registry tweak, reboot.

3.) Install the latest greatest version of ffmpeg for your windows version from Zeranoe. I grabbed the 64 bit Static build since I didn’t want to deal with libraries and such. Extract it and stick it somewhere on your hard drive. Remember the path to this folder since we will need it later.

4.) Open a command line window and cd to the directory where you extracted ffmpeg into, find the bin directory and cd into it. This is were the ffmpeg executable resides. In my case (I extracted the ffmpeg files into “Program Files” directory) it is C:\Program Files\ffmpeg-git-059707e-win64-static\bin.

5.) If you’ve made it this far, hand in there, we’re almost home. Now you need to issue the command that gets the screen streaming going. But first we need to find out the name of the Screen filter device. So issue the following command:

ffmpeg -list_devices true -f dshow -i dummy

In the output look for a device called “UScreenCapture“. Hopefully if everything is working with the directshow filter you have a entry in the list. That’s the name of our device that we need to pass onto ffmpeg. While you’re there also look for your audio device entry as well. Mine was the truncated word “Stereo Mix (Realtek High Defini” (Yes mine was missing the end of that line). Jot that down somewhere as well. I will show you how to get audio going as well.

6.) So first step is to get video going. Assuming you have a “UScreenCapture” device (You could use another directshow filter if you like, this will work with most of them. I just used the Unreal filter for the heck of it), here is the command to start encoding and sending video:

ffmpeg -f dshow  -i video="UScreenCapture"  -r 30 -vcodec mpeg4 -q 12 -f mpegts udp://aaa.bbb.ccc.ddd:6666?pkt_size=188?buffer_size=65535
  • -f dshow specifies that you’re going to be using a directshow device as your input.
  • -i video=”UScreenCapture” is the name of the input directshow device which we picked up in step 5.
  • -r 30 is the frame rate.
  • -vcodec mpeg4 is our video codec of choice.
  • -q 12 is a quality measure for the encoding process (1 is the best and 30 the worst). We’re doing VBR encoding so this measures the compression ratio vs. picture quality.
  • -f mpegts is our output filetype. In this case mpeg-2 transport stream. Yes, we’re encapsulating mpeg4 video inside a mpeg-2 transport stream…..why?….google it.
  • udp://aaa.bbb.ccc.ddd:6666?pkt_size=188?buffer_size=65535 this last bit specifies the address and port number of the recipient machine (aaa.bbb.ccc.ddd is the ip address of that machine and 6666 is my arbitrary port number). We’re also instructing ffmpeg to create smaller 188 byte size udp packets (which is the size of the transport stream packets) to decrease latency and our buffer size is 64kb.

7.) On the receiving machine you should be able to use vlc, ffmpeg or mplayer to catch the stream. In vlc simply open the Network stream rtp://@:6666 , in ffmpeg you can use the command ffplay -i udp://:6666 or using mplayer you can issue the command mplayer -framedrop -double udp://:6666 .

8.) Now to optionally add sound to the whole thing we can use this command on the encoding machine (instead of step 6). You need to know the device name for your sound card and you probably want to turn the volume down (at least initially) on the decoding machine.

ffmpeg -f dshow  -i video="UScreenCapture" -f dshow -i audio="Stereo Mix (Realtek High Defini" -r 30 -vcodec mpeg4 -q 20 -acodec libmp3lame -ab 128k -f mpegts udp://141.117.224.74:6666?pkt_size=188?buffer_size=65535
  • -f dshow specifies that you’re going to be using a directshow device as your input (VIDEO).
  • -i video=”UScreenCapture” is the name of the input directshow video device which we picked up in step 5.
  • -f dshow specifies that you’re going to be using a directshow device as your input (AUDIO).
  • -i audio=”Stereo Mix (Realtek High Defini” is the name of the input directshow audio device which we picked up in step 5.
  • -r 30 is the frame rate.
  • -vcodec mpeg4 is our video codec of choice.
  • -q 20 is a quality measure for the encoding process (1 is the best and 30 the worst). We’re doing VBR encoding so this measures the compression ratio vs. picture quality. I went with 20 instead of 12 from step 6 since the audio encoding slows the machine down a bit.
  • -acodec libmp3lame is our video codec of choice
  • -f mpegts is our output filetype. In this case mpeg-2 transport stream. Yes, we’re encapsulating mpeg4 video inside a mpeg-2 transport stream…..why?….google it.
  • udp://aaa.bbb.ccc.ddd:6666?pkt_size=188?buffer_size=65535 this last bit specifies the address and port number of the recipient machine (aaa.bbb.ccc.ddd is the ip address of that machine and 6666 is my arbitrary port number). We’re also instructing ffmpeg to create smaller 188 byte size udp packets (which is the size of the transport stream packets) to decrease latency and our buffer size is 64kb.
Share

Terminal Tip: Finding information about a mp3 audio file…

datePosted on 13:24, October 19th, 2010 by Many Ayromlou

Here is a quick tip for you OSX command line fans. If you want to find metadata information about a mp3 file use the “afinfo” command. Very quick and scripting friendly. Here is a example:

$ afinfo 08_\ Lily\ Allen\ -\ Fk\ You.mp3
File:           08_ Lily Allen - Fk You.mp3
File type ID:   MPG3
Data format:     2 ch,  44100 Hz, '.mp3' (0x00000000) 0 bits/channel, 0 bytes/packet, 1152 frames/packet, 0 bytes/frame
                no channel layout.
estimated duration: 215.249 sec
audio bytes: 5167920
audio packets: 8240
audio 9490176 valid frames + 576 priming + 1728 remainder = 9492480
bit rate: 192000 bits per second
packet size upper bound: 1052
maximum packet size: 731
audio data file offset: 32353
optimized
----
Share

Duplicating service settings under OSX Server…

datePosted on 14:17, August 25th, 2010 by Many Ayromlou

This mainly applies to how you deal with a backup DHCP server and it’s configuration, but might also be useful for backing up other service settings. One of the things that kinda bugs me about how some services are configured in OSX Server is the fact that the configurations are stored in the directory. For example, if you have a DHCP server servicing a subnet with a ton of reservations hardcoded in it, there is no way of editing and/or moving the information from the command line (ie: there is no single config file that contains the current configuration) to another server. That’s where the “serveradmin” commandline program comes to rescue. If you have two identical servers (ie: both running the same OSX server version), you can use serveradmin to export the settings from a specific service and then move the file to the new server and import it there. All using the CLI.

  • To Export the settings (in this case the DHCP service):
  • sudo serveradmin settings dhcp > dhcp-config.txt
  • To Import the settings on the other server:
  • sudo serveradmin settings < dhcp-config.txt
Share

MySQL: Transfering users and priviledges to a new server….

datePosted on 15:32, August 19th, 2010 by Many Ayromlou

So this was a great big mystery this morning. How the heck do you transfer the users and their privileges out of a old mysql server and “import” them into a new server. We recently upgraded from OSX 10.4.11 to a couple of spanking new Snow Leopard servers and during the mysql export/import cycle this issue came up. Well the simple answer is…..DON’T USE mysqldump on your mysql DB (you know the default DB that stores all your users and privileges. It’s a bad idea and will probably do more harm than good. Instead use the following procedure:

1) On your old server (the one that has your data/users/tables on it) issue the following command (replace YOUR dbadmin/root username and  password in the 2 appropriate places:

mysql -B -N --user=admin --password=yourpassword -e "SELECT DISTINCT CONCAT('SHOW GRANTS FOR ''', user, '''@''', host, ''';') AS query FROM mysql.user" |mysql --user=admin --password=yourpassword | sed 's/\(GRANT .*\)/\1;/;s/^\(Grants for .*\)/## \1 ##/;/##/{x;p;x;}'

The output of this command is something like this:

## Grants for admin@127.0.0.1 ##
GRANT ALL PRIVILEGES ON *.* TO 'admin'@'127.0.0.1' WITH GRANT OPTION;
## Grants for fabrik@localhost ##
GRANT USAGE ON *.* TO 'fabrik'@'localhost' IDENTIFIED BY PASSWORD 'HASHEDPASSWORD';
GRANT ALL PRIVILEGES ON `fabrikdb`.* TO 'fabrik'@'localhost' WITH GRANT OPTION;
## Grants for nerdlogger@localhost ##
GRANT USAGE ON *.* TO 'nerdlogger'@'localhost' IDENTIFIED BY PASSWORD 'HASHEDPASSWORD';
GRANT ALL PRIVILEGES ON `nerdlogger`.* TO 'nerdlogger'@'localhost' WITH GRANT OPTION;
## Grants for research@localhost ##
GRANT USAGE ON *.* TO 'research'@'localhost' IDENTIFIED BY PASSWORD 'HASHEDPASSWORD';
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `research`.* TO 'research'@'localhost';
## Grants for admin@localhost ##
GRANT ALL PRIVILEGES ON *.* TO 'admin'@'localhost' IDENTIFIED BY PASSWORD 'HASHEDPASSWORD' WITH GRANT OPTION;
## Grants for root@server.domain ##
GRANT ALL PRIVILEGES ON *.* TO 'admin'@'server.domain' WITH GRANT OPTION;

2) Now you’re ready to selectively cut and paste the appropriate users and associated grant into a new mysql session (which you have to open) on the new server.

Goodluck….

Share

ASCII Art for all your N.E.R.D.ly needs :-)…..

datePosted on 22:33, November 10th, 2009 by Many Ayromlou

Yep, a whole archive of ASCII Art, brought to you by Christopher A. Johnson……Ahhh, just like heaven….

                        ..uu.
                       ?$""`?i           z'
                       `M  .@"          x"
                       'Z :#"  .   .    f 8M
                       '&H?`  :$f U8   <  MP   x#'
                       d#`    XM  $5.  $  M' xM"
                     .!">     @  'f`$L:M  R.@!`
                    +`  >     R  X  "NXF  R"*L
                        k    'f  M   "$$ :E  5.
                        %    `~  "    `  'K  'M
                            .uH          'E   `h
                         .x*`             X     `
                      .uf`                *
                    .@8     .
                   'E9F  uf"          ,     ,
                     9h+"   $M    eH. 8b. .8    .....
                    .8`     $'   M 'E  `R;'   d?"""`"#
                   ` E      @    b  d   9R    ?*     @
                     >      K.zM `%M'   9'    Xf   .f
                    ;       R'          9     M  .=`
                    t                   M     Mx~
                    @                  lR    z"
                    @                  `   ;"
                                          `
                                 .u!"`
                             .x*"`
                         ..+"NP
                      .z""   ?
                    M#`      9     ,     ,
                             9 M  d! ,8P'
                             R X.:x' R'  ,
                             F F' M  R.d'
                             d P  @  E`  ,
                            P  '  P  N.d'
                           ''        '
                ss
                 X               x             .
                 9     .f       !         .    $b
                 4;    $k      /         dH    $f
                 'X   ;$$     z  .       MR   :$
                  R   M$$,   :  d9b      M'   tM
                  M:  #'$L  ;' M `8      X    MR
                  `$;t' $F  # X ,oR      t    Q;
                   $$@  R$ H :RP' $b     X    @'
                   9$E  @Bd' $'   ?X     ;    W
                   `M'  `$M d$    `E    ;.o* :R   ..
                    `    '  "'     '    @'   '$o*"' 
Share

Fix Ctrl-Alt-Backspace problem with Ubuntu 9.10+

datePosted on 13:58, October 31st, 2009 by Many Ayromlou

Downloaded and installed 9.10 yesterday and what do you know, someone decided to take away Ctrl-Alt-Backspace — or what I call “Three Finger Salute for Linux”. Whhhaaattt!!!!

How the heck are you supposed to kill and restart X without that…..A coworker suggested Alt-PrintScreen-K, but that just restarts GDM, not really useful when X decides to go south. Damit!!
The reason given on Ubuntu wiki is that “This is due to the fact that DontZap is no longer an option in the X server and has become an option in XKB instead.”
Well, fear not, whoever disabled it also created a easy way to reenable it again. Here is what you do:
  • In Gnome (Ubuntu):
    * Get to the System->Preferences->Keyboard menu.* Select the "Layouts" tab and click on the "Layout Options" button.* Then select "Key sequence to kill the X server" and enable "Control + Alt + Backspace". 
  • In KDE (Kubuntu):
    * Launch "systemsettings"* Select "Regional & Language".* Select "Keyboard Layout".* Click on "Enable keyboard layouts" (in the Layout tab).* Select the "Advanced" tab. Then select "Key sequence to kill the X server" and enable "Control + Alt + Backspace". 
  • Using Command-Line:
    You can type the following command to enable Zapping immediately.

    setxkbmap -option terminate:ctrl_alt_bksp

    If you're happy with the new behaviour you can add that command to your ~/.xinitrc in order to make the change permanent.
  • Using HAL:
    You can add the following line in /usr/share/hal/fdi/policy/10osvendor/10-x11-input.fdi (inside the <match key="info.capabilities" contains="input.keys"> section):

    <merge key="input.xkb.options" type="string">terminate:ctrl_alt_bksp</merge>

Share

ASCII Art at it’s finest…..

datePosted on 12:14, October 19th, 2009 by Many Ayromlou

Not sure if this has already been mentioned somewhere…..It’s pretty old, but I happen to come across it today. It’s a great rendition of everyone’s favorite space opera done by Simon Jansen in ASCII. Telenetification (is that even a word?) by Snore, with improvements by Mike Edwards. Anyways, use the following command, sit back and enjoy…..Star Wars in all its ASCII glory :-)
telnet towel.blinkenlights.nl

If you don’t know how to telnet, click here to see it in your browser.

Share

gksudo: Or how this old dog learned new tricks :-)

datePosted on 12:19, September 28th, 2009 by Many Ayromlou

Okay if you know about gksudo, fine. I just found out about it a little while back when I was trying to run ethereal. You see under Ubuntu (and a lot of other Linux distros) the concept of root user has been removed. There is no root (well there is, but you can’t access it), unless you specifically modify your system to activate it. That’s fine (most of the time), since you can use sudo to accomplish almost anything as the administrator. One thing that doesn’t work properly are the graphical applications that need root access. So here is where gksudo comes to rescue. In the case of ethereal I would issue the following command to get it to prompt me for sudo and run as root user:
gksudo ethereal
So next time you get tempted to open up that root account on your Ubuntu install, don’t, use gksudo and get those gui apps running as root.

Share

How to change the default command line text editor in Ubuntu….

datePosted on 12:10, September 28th, 2009 by Many Ayromlou

I love Ubuntu, but there is one thing that really bugs the hell out of me. The default configured editor in Ubuntu is nano, a Pico clone. I hate Pico, therefor I hate nano :-) . So how would you go about fixing this and changing the default editor to vi (or vim):

  1. Issue the following command: sudo update-alternatives --config editor
  2. Enter the superuser password when prompted.
  3. At the following screen choose the number beside the editor you want as default or alternatively just press Enter to keep the default the same.
    There are 3 alternatives which provide `editor'.
    
      Selection    Alternative-----------------------------------------------          1    /usr/bin/vim.tiny          2    /bin/ed*+        3    /bin/nano
    
    Press enter to keep the default[*], or type selection number: 1Using '/usr/bin/vim.tiny' to provide 'editor'.

That’s it…..Have fun.

Share

OSX 10.5: How to create a public share folder…..

datePosted on 12:39, June 11th, 2009 by Many Ayromlou

This problem has been around (I think) ever since the introduction of POSIX permissions. In pre-10.5 versions you could sorta do something like this by changing the default umask on the system, but that was system wide and applied to all folders/files a user created on the entire filesystem…..not nice. The real question is how do you create a directory that is totally public without mucking around with system/user wide settings. A folder that anyone on the system in question can read/write/modify/delete anything anyone else has put in there. A true shared directory with share permission inheritence. We call it “pub” directory at my place of work.

The old trick in OSX (in case someone is interested) was to write a small script that you ran via cron every 5-10 minutes that would “chmod” all the entries in a folder to be open to a specific POSIX group….something like the script below:

find /path/to/shared/directory ! -type l ! -perm -g=w -print0 | while IFS
= read -rd $'\0' filename
do
echo "*+*+*Permission changing program caught something"
if [ -d "$filename" ]
then
chmod g+rwx "$filename"
# echo Directory changed
stat -l "$filename"
fi
if [ -f "$filename" ]
then
chmod g+rw "$filename"
# echo File changed
stat -l "$filename"
fi
done

Well those were the old days and now with the help of ACL’s we can do this a lot nicer/cleaner. The procedure below is for OSX 10.5+ (it should also work on 10.4, although I haven’t tried it).

  1. Enable ACL’s on your computer. Type the following command in a Terminal window: sudo /usr/sbin/fsaclctl -p / -e and verify that ACL’s are now enabled by typing: sudo fsaclctl -p /
  2. Create a new group. The easiest way to do this is through the Accounts pane in System Preferences. Just click on the Plus sign to add a new account and then select Group from the New Account drop-down menu. Call this group anything you want; I called mine public. Add all the users who you want to participate in the file sharing to your newly-created group.
  3. Do the following steps in Terminal, in Applications -> Utilities:
  4. Change directory to /Users/Shared: cd /Users/Shared
  5. Create a new folder where the users will be able to share their files. I created a folder named Pub by typing mkdir Pub
  6. Change the group of the new folder to your newly-created group: sudo chown admin:public Pub
  7. Change the default permissions, if you wish: sudo chmod 770 Pub (this is optional if you’re happy with the default permissions).
  8. Create the ACL entry for the new folder:sudo chmod +a "group:public allow file_inherit,directory_inherit,readattr,readextattr,readsecurity,read,execute,list,search,writeattr,writeextattr,delete,append,write,delete_child,add_file,add_subdirectory" Pub

You now have a true public folder where all members of the group public can read, write and delete files, as well as read, write to and create new sub folders. The ACL rule takes precedence over standard UNIX file permissions and is automatically inherited. It’s this automatic inheritance that is really important.

IMPORTANT: You must copy (hold down Option in Finder prior to dragging), and not merely move, items. This is particularly important with bundles, such as the Aperture library bundle for example. Moving items doesn’t inherit/change the permissions/ACL’s. Copying ensures that the files are actually created in the shared folder, thereby forcing the ACL rules to be inherited. If you have moved files into this directory and the permissions are a bit messed up you can quickly fix that by issuing the following recursive command which will set the ACL’s and POSIX permissions to the “right” ones so that everyone can do anything in that directory:
sudo chmod -R +a "group:public allow file_inherit,directory_inherit,readattr,readextattr,readsecurity,read,execute,list,search,writeattr,writeextattr,delete,append,write,delete_child,add_file,add_subdirectory" /Users/Shared/Pub

Share

This used to be a pain in the butt. Lots of manual apt-get lines and config edits to get it to work. Weŕe talking about installing the LAMP stack onto a preexisting Ubuntu Desktop Edition installation. I used to do this backwards in the old days by installing the Server edition first (with LAMP) and then getting the graphical desktop goodies installed on top of that. That method still works, but I found out that LAMP stack install on a Desktop edition is a simple one command affair. As of the 7.04 release, the Ubuntu base system includes Tasksel. You can install LAMP using tasksel.
sudo tasksel install lamp-server

Share

Just came across tms , what a great tool. It a command line tool for OSX 10.5+ that allows basic CVS style operations on your Time Machine volumes and It does its thing in read-only mode, so nothing gets changed/deleted…..woohooo. Here is the stuff you can do with it:

  • help      - instructions on usage
  • version   – print the current version of this tool
  • disk      - print the current disk
  • disks     – print list of all Time Machine disks
  • volumes   – print list of all volumes
  • machine   – print the current machine
  • machines  - print the list of all machines backed up on the current disk
  • status    - print the current configuration
  • snapshots – print the list of snapshots for the current machine on the current disk
  • snaplog {} – print the log for the given (or latest) snapshot
  • log +     – print revision information for the given files
  • diff [-u] {} {} – print file diff with the given (or latest) snapshot, or between two snapshots
  • delta [-size] {

Go grab your copy NOW.

Share

Duplicate your Ubuntu Installation….

datePosted on 13:55, February 18th, 2009 by Many Ayromlou

As good as Ubuntu (and linux) are in general, once in a while you just get to a point where you need a reinstall. That’s when the realization kicks in that you’ve got far too many packages installed since the initial Ubuntu install. It’s okay, there is a way out. Make sure you have a USB key.

On Ubuntu Workstation (with graphical interface):

Run Synaptic package manager. Once inside Synaptic, go to File/Save Markings As menu option and choose a filename and location (USB stick). MAKE SURE YOU ALSO CHECK THE BOX “SAVE FULL STATE, NOT ONLY CHANGES”. This will save a text file that contains every single package installed on your system (through apt system and all it’s variants….manual compile/installs are something else). Now you can go ahead and reinstall the machine and configure your repositories. Once the machine is up and running again, load up Synaptic and go to File/Read Markings and point it at the file you saved on the USB stick and press Apply.

This will start a download process that will set the machine up (as far as installed packages are concerned) just like it used to be. Configurations need to be done manually, but atleast you get all your packages back.

This is also super handy if you’re duping identical systems. Remember that you can not do this to upgrade from one version to another. This is strictly for “Restoring” installed software packages from the same version of Ubuntu.

On Ubuntu Server (command line):

First we need to create a list of all the installed APT packages and configurations and save them:
sudo dpkg --get-selections > /tmp/dpkglist.txt
sudo debconf-get-selections > /tmp/debconfsel.txt

Copy the files from /tmp to your USB stick or save them somewhere else.

Now reinstall the OS, copy your backed up debconfsel.txt and dpkglist.txt file to your fresh system’s /tmp directory and execute the following:
sudo dselect update
sudo debconf-set-selections < /tmp/debconfsel.txt
sudo dpkg --set-selections < /tmp/dpkglist.txt
sudo apt-get -y update
sudo apt-get dselect-upgrade

Don’t worry! This method only adds and upgrades packages, it will not remove packages that do not exist in the list.

We also covered aptoncd program which basically does the same thing (it’s a extra install). Last but not least to make a costum Ubuntu install CD/DVD you want to check out our entry on Reconstructor.

Share

FFmpeg commands for ipod video encoding…

datePosted on 12:04, September 25th, 2008 by Many Ayromlou

So I found out the hard way that the new ipod’s (with video out) can actually play 640×480 video and also figured out how to get iTunes to accept the encoded files (so that I could sync them with the device)…….here is the run down:

  • “TV-Out” mode - 1.5Mbit/s 640×480 H.264 videos
    • BIT_RATE <= 1500 kbps
    • 640×480
    • Up to 30 fps
    • “Low-Complexity” H.264 Baseline Profile
    • 1 reference frame
    • Up to H.264 level 3
    • 640 pixels maximum frame width
    • Sample Aspect Ratio (SAR) must be 1:1
    • UUID atom must exist containing the following hex data: 6B 68 40 F2 5F 24 4F C5 BA 39 A5 1B CF 03 23 F3….This allows you to add the video into iTunes. You need AtomicParsley for this which can be checked out from their subversion repository . See below for usage.
  1. For 1-pass encoding use:
  2. ffmpeg -i INPUT -acodec libfaac -ab 128k -s WIDTHxHEIGHT -vcodec libx264 -b BIT_RATE -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -me umh -subq 5 -trellis 1 -refs 1 -coder 0 -me_range 16 -g 300 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -bt BIT_RATE -maxrate 10M -bufsize 10M -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -level 30 -aspect WIDTH:HEIGHT OUTPUT.mp4AtomicParsley OUTPUT.mp4 --DeepScan --iPod-uuid 1200 --overWrite

  3. For 2-pass encoding use:
  4. ffmpeg -i INPUT -an -pass 1 -s WIDTHxHEIGHT -vcodec libx264 -b BIT_RATE -flags +loop -cmp +chroma -partitions 0 -me epzs -subq 1 -trellis 0 -refs 1 -coder 0 -me_range 16 -g 300 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -bt BIT_RATE -maxrate 10M -bufsize 10M -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -level 30 -aspect WIDTH:HEIGHT OUTPUT.mp4 ffmpeg -i INPUT -acodec libfaac -ab 128k -pass 2 -s WIDTHxHEIGHT -vcodec libx264 -b BIT_RATE -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -me umh -subq 5 -trellis 1 -refs 1 -coder 0 -me_range 16 -g 300 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -bt BIT_RATE -maxrate 10M -bufsize 10M -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -level 30 -aspect WIDTH:HEIGHT OUTPUT.mp4AtomicParsley OUTPUT.mp4 --DeepScan --iPod-uuid 1200 --overWrite

  • “Standard” mode - 768kbit/s 320×240 H.264 videos
    • BIT_RATE <= 768 kbps
    • 320×240
    • Up to 30 fps
    • H.264 Baseline Profile up to level 1.3
  1. For 1-pass encoding use:
  2. ffmpeg -i INPUT -acodec libfaac -ab 128k -s WIDTHxHEIGHT -vcodec libx264 -b BIT_RATE -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -flags2 +mixed_refs -me umh -subq 5 -trellis 1 -refs 5 -coder 0 -me_range 16 -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -bt BIT_RATE -maxrate 768k -bufsize 2M -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -level 13 -title SOME_TITLE OUTPUT.mp4

  3. For 2-pass encoding use:
  4. ffmpeg -i INPUT -an -pass 1 -s WIDTHxHEIGHT -vcodec libx264 -b BIT_RATE -flags +loop -cmp +chroma -partitions 0 -me epzs -subq 1 -trellis 0 -refs 1 -coder 0 -me_range 16 -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -bt BIT_RATE -maxrate 768k -bufsize 2M -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -level 13 -title SOME_TITLE OUTPUT.mp4 ffmpeg -i INPUT -acodec libfaac -ab 128k -pass 2 -s WIDTHxHEIGHT -vcodec libx264 -b BIT_RATE -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -flags2 +mixed_refs -me umh -subq 5 -trellis 1 -refs 5 -coder 0 -me_range 16 -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -bt BIT_RATE -maxrate 768k -bufsize 2M -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -level 13 -title SOME_TITLE OUTPUT.mp4

      Share

      ffmpeg command line quickies…..

      datePosted on 11:05, September 25th, 2008 by Many Ayromlou

      Here are a bunch of ffmpeg command lines that will do just about everything you need.

      1. Getting info from a video file
      2. ffmpeg -i video.avi

      3. Turn a sequence of images into video
      4. ffmpeg -f image2 -i image%d.jpg video.mpg

      5. Turn a video into a sequence of images
      6. ffmpeg -i video.mpg image%d.jpg

      7. Encode video for Ipod/IPhone
      8. ffmpeg -i source_video_file.avi -acodec aac -ab 128kb -vcodec mpeg4 -b 1200kb -mbd 2 -flags +4mv -trell 1 -aic 2 -cmp 2 -subcmp 2 -s 320x180 -title X output_file.mp4

      9. Encode video for PSP
      10. ffmpeg -i source_video_file.avi -b 300 -s 320x240 -vcodec xvid -ab 32 -ar 24000 -acodec aac output_file.mp4ORffmpeg -i "OriginalFile.avi" -f psp -r 29.97 -b 768k -ar 24000 -ab 64k -s 320x240 "OutputFile.mp4"

      11. Extract audio from a video file and save it as mp3 format
      12. ffmpeg -i source_video_file.avi -vn -ar 44100 -ac 2 -ab 192 -f mp3 output_file.mp3

      13. Convert a wave file to mp3
      14. ffmpeg -i original_audio_file.avi -vn -ar 44100 -ac 2 -ab 192 -f mp3 output_file.mp3

      15. Convert a avi video to mpeg
      16. ffmpeg -i original_movie.avi output_file.mpg

      17. Convert a mpeg video to avi
      18. ffmpeg -i original_movie.mpg output_file.avi

      19. Convert a avi video to uncompressed animated gif
      20. ffmpeg -i original_movie.avi output_file.gif

      21. Add audio to an existing video-only file (mix audio and video)
      22. ffmpeg -i son.wav -i original_movie.avi output_file.mpg

      23. Convert a avi video to flv (flash video)
      24. ffmpeg -i original_movie.avi -ab 56 -ar 44100 -b 200 -r 15 -s 320x240 -f flv output_file.flv

      25. Convert a flv video to mpeg
      26. ffmpeg -i myFile.flv -ab 56 -ar 22050 -b 500 -s 320x240 myFile.mpg

      27. Convert a avi video to dv
      28. ffmpeg -i original_movie.avi -s ntsc -r ntsc -aspect 4:3 -ar 48000 -ac 2 output_file.dvORffmpeg -i original_movie.avi -target ntsc-dv output_file.dv

      29. Convert a avi video to mpeg specifically for DVD creation
      30. ffmpeg -i source_video.avi -target ntsc-dvd -ps 2000000000 -aspect 16:9 finale_video.mpeg

      31. Compress a avi video to Divx
      32. ffmpeg -i original_movie.avi -s 320x240 -vcodec msmpeg4v2 output_file.avi

      33. Convert a Ogg Theora video to mpeg specifically for DVD creation
      34. ffmpeg -i original_movie.ogm -s 720x576 -vcodec mpeg2video -acodec mp3 output_file.mpg

      35. Convert a avi video to mpeg2 for SVCD creation
      36. ffmpeg -i original_movie.avi -target ntsc-svcd output_file.mpg

      37. Convert a avi video to mpeg2 for VCD creation
      38. ffmpeg -i original_movie.avi -target ntsc-vcd output_file.mpg

      Share

      Speed up Mac OS X Mail application…..

      datePosted on 17:07, September 22nd, 2008 by Many Ayromlou

      Does your OSX Mail app crawl when you start it. Well here is a quick tip to speed things up again. Just issue this command from a terminal window (make sure you’re not running Mail app first).

      sqlite3 ~/Library/Mail/Envelope\ Index vacuum;
      You should notice a bit of a performance improvement the next time you start the Mail application. This only works for the OSX mail.app, not other mail applications.

      Share

      How to make a ISO out of a DMG file under OSX

      datePosted on 17:01, September 22nd, 2008 by Many Ayromlou

      Here is a quick command line for all you OSX ppl. If you’re ever in need of turning/converting a .dmg file into a .iso use the following command line:

      hdiutil makehybrid -iso -o newfile.iso yourfilename.dmg

      Where newfile is the name of the iso you want, and yourfilename.dmg is the dmg. Have Fun……
      Share

      How to mount CD/DVD images from command line under Linux

      datePosted on 16:45, September 22nd, 2008 by Many Ayromlou

      Here are some quick CLI commands to get those CD/DVD images mounted under Linux (without having to burn them first).

      # ISO
      mount -t iso9660 -o loop,user file.iso /path/mount_directory

      # MDF
      mount imagen.mdf /path/mount_directory -o loop=/dev/loop0

      # NRG
      mount -o loop,offset=307200 imagen.nrg /path/mount_directory

      Share

      Basic APT commands

      datePosted on 16:37, September 22nd, 2008 by Many Ayromlou

      Okay, now for a bit of CLI goodness. Here is a quick list of basic apt commands.  Debian and most derivatives (Ubuntu) use these for package maintenance.
      #search
      apt-cache search packagename

      #package info
      apt-cache show packagename

      #clean
      sudo apt-get clean
      sudo apt-get autoclean #old packages

      #check
      apt-get check

      #get source code
      apt-get source packagename

      #get dep
      apt-get build-dep packagename

      #update/install/remove/upgrade
      sudo apt-get update
      sudo apt-get install packagename
      sudo apt-get remove packagename
      sudo apt-get upgrade
      sudo apt-get dist-upgrade

      Share

      Activate expanded Save and Print menu’s in OSX

      datePosted on 15:42, August 25th, 2008 by Many Ayromlou

      Here are two commands to activate the expanded Print and Save menu’s under OSX by default. You need to type these in a terminal window.

      1) For expanded Print menu
      defaults write -g PMPrintingExpandedStateForPrint -bool TRUE
      Logoff and back in again to activate. Reissue the command replacing TRUE with FALSE to turn expanded functionality off.

      2) For expanded Save menu
      defaults write -g NSNavPanelExpandedStateForSaveMode -bool TRUE
      Logoff and back in again to activate. Reissue the command replacing TRUE with FALSE to turn expanded functionality off.

      Enjoy and Have fun

      Share
      123Next