Transcoding into a 3gp Video
These quick notes detail the steps I took to create 3gp videos from my recordings taken from MythTV. You will probably want to tune the various parameters.
Encode with commercials
Simply create a script with the following code in it:
#!/bin/sh # MythTV user job to transcode a video to 3gp suitable for a phone FILE=$1 TITLE=$2 OUTDIR="/tmp/" /usr/bin/ffmpeg -i $FILE -ar 16000 -ac 1 -acodec libamr_wb -ab 23.85k -b 240 -s qcif -f 3gp "$OUTDIR$TITLE.3gp" # Uncomment the following line for a LG VX9900 (enV) video #/usr/bin/ffmpeg -i $FILE -ar 16000 -ac 1 -acodec aac -ar 44100 -ab 128 -b 240 -s qcif -f 3gp "$OUTDIR$TITLE.3gp"
Make the script executabled:
chmod u+x /home/mythtv/3gp.sh
To use the script simply call it like:
/home/mythtv/3gp.sh /myth/1004_20070912180000.mpg "The Simpsons - Marge Be Not Proud"
Note: The title is in quotes, to ensure it is passed to the script as $2, without the quotes $2 would be "The", $3 "Simpsons" etc....
Encode without commercials
With this option we have a script that you can use from one of your User Jobs or fire it off from the command line... your choice. Either way encoding without commercials can save you a lot of precious space on your mobile device. I have chosen (via the below ffmpeg settings) to trade some of that space savings for better quality video, you decide what's best for your setup.
Just create the following file, make it executable and setup your user job of hit the command line.
Now, make that file executable:
#chmod a+x /usr/bin/myth_3gp
Running from a frontend
Do the following on the backend...
- Run “mythtvsetup”
- Select “General”
- Next until the “Job Queue (Host-Specific)” screen
- Place a check on “Allow User Job #1” (or whatever job number your using)
- Next until the “Job Queue (Job Commands)" screen and enter the following:
- User Job #1 Description: Convert for phone (mine is called Convert for enV)
- User Job #1 Command: /usr/bin/myth_3gp "%DIR%/%FILE%" "%TITLE%-%SUBTITLE%" "<the_directory_where_you_want_to_export_the_video>"
- Now, exit mythtvsetup
Lets test things out on the frontend...
- Go into Media Library -> Watch Recordings
- Select a recording, hit the right arrow, and select Job Options
- You should see a new job called “Begin Convert for phone” choose it
Running from command line
You can also fire the script from the command line, but it can be a PITA to find the file you want to encode... at any rate, you do it like this:
$/usr/bin/myth_3gp /myth/tv/1004_20070912180000.mpg "The Simpsons - Marge Be Not Proud" "/myth/shared/video/"
Now what's going to happen is the script will create a cutlist based on the commercial flagging or I think it will use an existing cutlist in case you want to create one yourself, but be warned that unless you comment out the line in the script above, it will automatically clear the cutlist when it's done. Then, it's going to generate a couple of files (a .tmp and a .key file) while it's building the .3gp file. Once the .tmp and .key file are removed and the job says "Completed" in the log it means the script it done and your file is ready for your mobile device.
To automate this process simply create a User Jobs to call the script, my UserJob1 is as follows:
/home/mythtv/3gp.sh "%DIR%/%FILE%" "%TITLE% - %SUBTITLE%"
There are many variables you may want to change within the script:
|Option||What it does||Possible Settings|
|-acodec||Audio Codec||libamr_wb, libamr_nb (depending on your version of ffmpeg you may need to drop the lib, ie amr_wb ro amr_nb.)|
|-ab||Audio Bit Rate||6.6k, 8.85k, 12.65k, 14.25k, 15.85k, 18.25k, 19.85k, 23.05k, or 23.85k (for libamr_wb)|
|-b||Video Bit Rate||any value you choose|