You are not logged in.
Pages: 1
Hi,
I am looking for a way to add right click mp4 convertion to nautilus at the moment I use
ffmpeg -y -i '<video_name>' -f mp4 -vcodec h264 -pass 1 -me full -refs 3 -subq 5 -b 700000 -maxrate 768000 -bufsize 244000 -s 320x240 -r 23.976023976 -ac 1 -bf 0 -level 13 -acodec aac -ar 48000 -ab 160000 -ac 2 '<video_name>.mp4'
Only I have to edit video_name each time I run from terminal ;-( would be better in a little bash script
replace video_name with a variable [or use it!]
The above command works ok on flv [although converted video is a little blocky!]
MrG
Mr Green
Offline
I am looking for a way to add right click mp4 convertion to nautilus
Save the following script to a file (named 'XCodeMP4', for example) in your '~/.gnome2/nautilus-scripts' directory and make the file executable. The script then should appear in your nautilus right-click menu under 'Scripts'.
To transcode files with the script, just right click on a file or group of files, and from the menu, select 'Scripts' > 'XCodeMP4'.
Pay attention to the variables that may need modifying for your situation:
mimes - If you want to add another mime type to the list in this variable, you can obtain the mime from a particular sample file by running:
file -i <filename> | awk '{print $NF;}'
vidfile_ext - You can change the target file extension here; for example, if you modify your encoding options, this might be desirable.
logfile - The variable is set to save a log file to your Desktop. Change the path if you wish to save the file elsewhere (see sample output below ... it represents the logfile contents). You may also wish to only keep the log for a particular transcoding run, and therefore you need to change the append-to-log code ('>>') to overwrite-log code ('>').
NOTE: I take no responsibility for the ffmpeg options supplied by Mr. Green. Actually, I take no responsibility for any of the code. If you run it, it's yours.
Scipt:
#!/bin/bash
# Date: 2007 12/02
# REQUIRES: awk, basename, file, ffmpeg, grep
# SCRIPT NAME: XCodeMP4
# DESCRIPTION: transcode selected video files
#
#=============
# === Variables
mimes="Microsoft ASF; video/mpeg; application/octet-stream"
vidfile_ext=".mp4"
tstamp=$(date '+%F / %r %Z')
logseparator="-------------------------------------------"
logfile="$HOME/Desktop/transcode.log"
# === Main
echo "$logseparator" >> "$logfile"
echo "Transcode Session: $tstamp" >> "$logfile"
for file in "$@"; do
if [ -f "$file" ]; then
filemime=$(file -i "$file" | awk '{print $NF;}')
vidfile=$(echo "$mimes" | grep -E "\b${filemime}\b")
vidfile_base=$( basename "$file" )
vidfile_base_noext="${vidfile_base%.*}"
if [ -n "$vidfile" ]; then
echo "$logseparator" >> "$logfile"
echo " >>> Transcoding: $file" >> "$logfile"
ffmpeg -y -i "$file" \
-f mp4 \
-vcodec h264 \
-pass 1 \
-me full \
-refs 3 \
-subq 5 \
-b 700000 \
-maxrate 768000 \
-bufsize 244000 \
-s 320x240 \
-r 23.976023976 \
-ac 1 \
-bf 0 \
-level 13 \
-acodec aac \
-ar 48000 \
-ab 160000 \
-ac 2 \
"${vidfile_base_noext}${vidfile_ext}" \
>> "$logfile" 2>&1
else
echo "$logseparator" >> "$logfile"
echo " >>> Transcoding skipped ... Mime (${filemime}) of '$file' does not match mimes list." \
>> "$logfile"
fi
else
echo "$logseparator" >> "$logfile"
echo " >>> Transcoding skipped ... '$file' is a directory." \
>> "$logfile"
fi
done
exit
Sample output:
-------------------------------------------
Transcode Session: 2007-12-02 / 09:34:31 AM EST
-------------------------------------------
>>> Transcoding: test2.mpeg
FFmpeg version SVN-rUNKNOWN, Copyright (c) 2000-2007 Fabrice Bellard, et al.
<snip transcoding output>
-------------------------------------------
>>> Transcoding: test3.wmv
FFmpeg version SVN-rUNKNOWN, Copyright (c) 2000-2007 Fabrice Bellard, et al.
<snip transcoding output>
-------------------------------------------
>>> Transcoding: test1flv
FFmpeg version SVN-rUNKNOWN, Copyright (c) 2000-2007 Fabrice Bellard, et al.
<snip transcoding output>
-------------------------------------------
>>> Transcoding skipped ... Mime (charset=us-ascii) of 'symfind.py' does not match mimes list.
-------------------------------------------
>>> Transcoding skipped ... 'untitled folder X' is a directory.
Last edited by MrWeatherbee (2007-12-02 15:15:18)
Offline
woah! thanks dude...
Mr Green
Offline
Mr. Green,
Word of warning here: Codec 'h264' is a raw stream. Use x264 through FFmpeg if you want high quality h264 with reasonable file sizes.
Offline
ok will give it a go... thanks
Mr Green
Offline
woah! thanks dude...
You're welcome.
By the way, Skottish is the man when it comes to encoding.
Offline
By the way, Skottish is the man when it comes to encoding.
I wish. I've spent hundreds of hours reading websites, forums, tutorials, and documentation, and I'd rank myself as a decent amateur. Some of the people over at http://forum.doom9.org are simply incredible. Those people have true understanding.
Last edited by skottish (2007-12-02 20:10:34)
Offline
I did used to use a script call mp4ize but for some reason the converted file would not work on my ipod...
When I get a minute I will add script to wiki ;-)
MrG
Mr Green
Offline
I did used to use a script call mp4ize but for some reason the converted file would not work on my ipod...
When I get a minute I will add script to wiki ;-)
MrG
I'd double check anything Skottish said regarding the encoding options. Turns out he's just a decent amateur.
Offline
I did used to use a script call mp4ize but for some reason the converted file would not work on my ipod...
Decent Amateur to the rescue!!!
If you have a mp4 file that won't work on Apple stuff, run it through MP4Box from GPAC. If it is in fact a compliant mpeg4 file codec wise, MP4Box will fix it up in a matter of seconds.
Last edited by skottish (2007-12-02 20:55:49)
Offline
Read that vlc will convert stuff but never had much luck doing it ....
Will check out MP4Box
Now if only I could encode my old albums lol
Mr Green
Offline
Pages: 1