Results 1 to 4 of 4
I have a home media center and wanted to be able to sync all recorded tv, podcasts, and pictures to my Android G1. This could be used for other phones ...
- 02-14-2009 #1Just Joined!
- Join Date
- Feb 2009
- Posts
- 5
Scripts: Converting media to Android G1
I have a home media center and wanted to be able to sync all recorded tv, podcasts, and pictures to my Android G1. This could be used for other phones and media players too. They can be modified for better resolution and sound quality, but I suggest leaving them where they are...these settings are perfect for the G1. Change the folder directories to suit your system. Put these scripts in your crontab.
Converting recorded TV and podcasts:
Code:#!/bin/bash # Convert video files to mp4 for the Android G1 # # Warning: different folder hierarchy may cause problems # # Compile ffmpeg with these options: # ./configure --enable-gpl --enable-postproc --enable-nonfree --enable-postproc --enable-libfaad --enable-swscale --enable-avfilter --enable-pthreads --enable-libxvid --enable-libx264 --enable-libmp3lame --enable-libdc1394 --enable-libfaac --disable-ffserver --disable-ffplay --enable-libamr_nb --enable-libamr_wb --enable-libvorbis --enable-decoder=h263 --enable-encoder=h263 --enable-decoder=h264 --enable-encoder=h264 # PodcastIn="/mnt/nas/Media/Podcasts" PodcastOut="/mnt/nas/Media/G1/Podcasts" TVIn="/mnt/htpc/Recorded TV" TVOut="/mnt/nas/Media/G1/RecordedTV" TempDir="/tmp/ConvertMP4" trap "rm -rf $TempDir; exit 1" SIGINT SIGTERM if [ ! -d $TempDir ]; then mkdir $TempDir fi find "$PodcastIn" -type f | grep -v ehthumbs_vista.db | \ while read line; do Ext=$(echo "$line" | gawk -F . '{print $NF}') NoExt="$(echo "$line" | sed "s/\.$Ext//g")" BaseNoExt="$(basename "$NoExt")" if [ ! -f "$PodcastOut"/"$BaseNoExt".mp4 ]; then /usr/local/bin/ffmpeg -y -i "$line" -s 480x320 -vcodec mpeg4 -acodec libfaac -ac 2 -ar 16000 -r 23.976 -b 400000 -ab 96000 -aspect 3:2 "$TempDir"/"$BaseNoExt".mp4 </dev/null cp "$TempDir"/"$BaseNoExt".mp4 "$PodcastOut"/"$BaseNoExt".mp4 rm -f "$TempDir"/"$BaseNoExt".mp4 else echo ""$BaseNoExt".mp4 already exists, skipping..." fi done find "$PodcastOut" -type f -name "*.mp4" | grep -v SyncToy | \ while read line; do Ext=$(echo "$line" | gawk -F . '{print $NF}') NoExt="$(echo "$line" | sed "s/\.$Ext//g")" BaseNoExt="$(basename "$NoExt")" if [ ! -f "$PodcastIn"/*/"$BaseNoExt".* ]; then echo "Deleting $BaseNoExt from $PodcastOut" rm -f "$PodcastOut"/"$BaseNoExt".mp4 fi done find "$TVIn" -type f -name "*.dvr-ms*" | \ while read line; do Ext=$(echo "$line" | gawk -F . '{print $NF}') NoExt="$(echo "$line" | sed "s/\.$Ext//g")" BaseNoExt="$(basename "$NoExt")" if [ ! -f "$TVOut"/"$BaseNoExt".mp4 ]; then /usr/local/bin/ffmpeg -y -i "$line" -s 480x320 -vcodec mpeg4 -acodec libfaac -ac 2 -ar 16000 -r 23.976 -b 400000 -ab 96000 -aspect 3:2 -async 1 "$TempDir"/"$BaseNoExt".mp4 </dev/null cp "$TempDir"/"$BaseNoExt".mp4 "$TVOut"/"$BaseNoExt".mp4 rm -f "$TempDir"/"$BaseNoExt".mp4 else echo ""$BaseNoExt".mp4 already exists, skipping..." fi done find "$TVOut" -type f -name "*.mp4" | grep -v SyncToy | \ while read line; do Ext=$(echo "$line" | gawk -F . '{print $NF}') NoExt="$(echo "$line" | sed "s/\.$Ext//g")" BaseNoExt="$(basename "$NoExt")" if [ ! -f "$TVIn"/"$BaseNoExt".dvr-ms ]; then echo "Deleting $BaseNoExt from $TVOut" rm -f "$TVOut"/"$BaseNoExt".mp4 fi done rm -rf $TempDir
Converting pictures to better sizes and resolution:
Code:#!/bin/bash # Convert image files to resized jpeg's for the Android G1 # Warning: different folder hierarchy may cause problems. PicsIn="/mnt/nas/Media/Pictures" PicsOut="/mnt/nas/Media/G1/Pictures" trap "exit 1" SIGINT SIGTERM find "$PicsIn" -type f | grep -v ehthumbs_vista.db | grep -v Thumbs.db | \ while read line; do Ext=$(echo "$line" | gawk -F . '{print $NF}') NoExt="$(echo "$line" | sed "s/\.$Ext//g")" BaseNoExt="$(basename "$NoExt")" BaseDir="$(echo "$line" | gawk -F "/" '{print $(NF-1)}')" if [ ! -f "$PicsOut"/"$NoExt".jpg ]; then if [ ! -d "$PicsOut"/"$BaseDir" ]; then mkdir -p "$PicsOut"/"$BaseDir" fi if [ "$(basename "$(dirname "$line")")" = "$BaseDir" ]; then convert -sample 480x320 "$line" "$PicsOut"/"$BaseDir"/"$BaseNoExt".jpg else convert -sample 480x320 "$line" "$PicsOut"/"$BaseNoExt".jpg fi else echo ""$BaseNoExt".jpg already exists, skipping..." fi done
- 02-14-2009 #2
Nice. Thank you much. You can actually do the second one with imagemagick already
But the first one could be very useful, thanks again.
Ubuntu 10.10 the Maverick Meerkat
Dell Studio 17, Intel Graphics card, 4 gigs of RAM, KDE & GDM
"The beauty in life can only be found by moving past the materialism which defines human nature and into the higher realm of thought and knowledge"
- 02-14-2009 #3Just Joined!
- Join Date
- Feb 2009
- Posts
- 5
The convert command is part of imagemagick. You mean there's already a script that converts entire directories?
- 02-15-2009 #4
yeah I'll have to remember how I did it but I have before on a really large set of pictures that I had that were each over 2 megs and I wanted them way more compact
simple image converter [Archive] - Ubuntu ForumsUbuntu 10.10 the Maverick Meerkat
Dell Studio 17, Intel Graphics card, 4 gigs of RAM, KDE & GDM
"The beauty in life can only be found by moving past the materialism which defines human nature and into the higher realm of thought and knowledge"


Reply With Quote
