Results 1 to 10 of 45

Thread: Script to create android (480x320) compatible mp4 video using ffmpeg

Threaded View

  1. #1
    Join Date
    Feb 2008
    Location
    52°38'41.6"N/1°19'43.6"E
    Beans
    Hidden!

    Script to create android (480x320) compatible mp4 video using ffmpeg

    If you're interested I created a python script to create compatible mp4 video for android G1/Dream/Hero from any video file using ffmpeg. It will figure out the padding top and bottom to fit the screen and keep the original video aspect ratio, see attached. To install and use:

    To install:
    1. save attached file to /tmp/
    2. put the file into a folder in your PATH, in this case /usr/bin: "sudo cp /tmp/android-video.py /usr/bin"
    3. give the file exec rights: "sudo chmod +x /usr/bin/android-video.py"
    4. install ffmpeg with mp4 etc support, try using the following (works for Jaunty and Intrepid):
      Code:
      sudo apt-get install ffmpeg ubuntu-restricted-extras
      A full set of methods can be found in this thread: HOWTO: Easily enable MP3, MPEG4, AAC, and other restricted encoding in FFmpeg


    To use:
    1. go to the terminal and cd to the directory where video exists
    2. run "android-video.py videofile1 videofile2..."
    3. new gnome-terminals will be spawned for each video conversion required
    4. New files with the same name as originals will be created but with a .mp4 extension added


    Note: you'll need ffmpeg installed...

    If you want to change the video conversion settings they are all set at the top of the script as follows:

    Code:
    TEMP_INFO_PATH = "/tmp/android-video.info"
    TARGET_VIDEO_WIDTH = 480
    TARGET_VIDEO_HEIGHT = 320
    TARGET_AUDIO_CHANNELS = 2
    TARGET_AUDIO_SAMPLING_RATE = 16000
    TARGET_AUDIO_BIT_RATE = 64000
    TARGET_FRAME_RATE = 23.976
    TARGET_VIDEO_BIT_RATE = 500000
    NO_PADDING = False
    In theory it could be used for future devices with other screen sizes and requirements...

    Hope you find it useful..I do

    Edit: I've updated the script to handle input video aspect ratio's lower than what the android offers, this will result in left and right padding of the output video rather than the usual top and bottom padding as seen with modern day films.
    Attached Files Attached Files
    Last edited by kaivalagi; November 6th, 2009 at 01:10 PM. Reason: updated script to fix "odd"ities

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •