播放swf文件
安装swf解码器
sudo apt-get install swfmill
如何保存串流视频(mms/rtsp)
mplayer -dumpfile dump.rm -dumpstream rstp://....
批量将rmvb转为avi
#ipod touch可用for i in *.rmvb; do mencoder -vf harddup -oac mp3lame -lameopts vbr=3 -ovc xvid -xvidencopts fixed_quant=4 -of avi $i -o `echo $i | sed -e 's/rmvb$/avi/'`; done
批量将DVD转为avi
for i in *.VOB; do mencoder -oac mp3lame -lameopts aq=7:vbr=2:q=6 -srate 44100 -ovc xvid -xvidencopts fixed_quant=4 -of avi $i -o `echo $i | sed -e 's/VOB$/avi/'`; done
批量将任何格式的电影转为ogv
#sudo apt-get install ffmpeg2theora #firefox3.5或chrome直接支持播放,无需安装任何解码器,注意不支持rmvb,rmvb会出现a/v不同步问题for i in *; do ffmpeg2theora --optimize --deinterlace $i; done
批量将rmvb格式的电影转为ogv
#!/bin/bashfor i in *; domkfifo "/tmp/$i"mencoder -quiet -vf harddup -ovc raw -oac pcm -o "/tmp/$i" "$i" &ffmpeg2theora --optimize --deinterlace "/tmp/$i" -o "`echo $i | sed 's/\(.*\)\..*$/\1/'`.ogv"rm "/tmp/$i"done
利用gst来转换任意电影为ogv
#!/bin/bashfor i in *; dogst-launch-0.10 filesrc location="$i"! decodebin name=demux \{ oggmux name=mux! filesink location="`echo $i | sed 's/\(.*\)\..*$/\1/'`.ogv" } \{ demux.! queue! audioconvert! vorbisenc! queue! mux. } \{ demux.! queue! ffmpegcolorspace! videorate! theoraenc! mux. } done
批量转换任意文件为ipod touch使用的mp4
#!/bin/bash#ubuntu10.04自带的mencoder由于版权问题,不支持h264编码,需要重新编译;也可以直接参考下面的压缩方法。#sudo apt-get install mencoder mplayerfind . -name '*.avi' -o -name '*.rm' -o -name '*.rmvb' -o -name '*.wmv' -o \-name '*.vob' -o -name '*.asf' -o -name '*.mpg' -o -name '*.ts' -o \-name '*.flv' -o -name '*.mpeg' -o -name '*.ogv' -o -name '*.mov' -o \-name '*.mkv' -o -name '*.dat' | while read i; dobasename=`echo $i | sed 's/\(.*\)\..*$/\1/'`font="WenQuanYi Zen Hei"if [ -f "${basename}.srt" ]; thencp "${basename}.srt" $$.srtm0="-vf scale=480:-10,harddup -sub $$.srt -unicode -subcp GB18030 -subfont-text-scale 3"; elsem0="-vf scale=480:-10,harddup"; fix0="-lavfopts format=mp4 -faacopts mpeg=4:object=2:raw:br=160 -oac faac -ovc x264 -sws 9 -x264encopts nocabac:level_idc=30:bframes=0:global_header:threads=auto:subq=5:frameref=6:partitions=all:trellis=1:chroma_me:me=umh:bitrate=500 -of lavf -ofps 24000/1001";mencoder $m0 -fontconfig -font "${font}" $x0 -o "$$.mp4" "$i"mv "$$.mp4" "${basename}.mp4"if [ -f "${basename}.mp4" ]; thenrm "$i"fidone
转换任意格式的视频到H264
#!/bin/bash#sudo apt-get install faac x264 gpac mplayer mencoderbasename=`echo $1 | sed 's/\(.*\)\..*$/\1/'`#获得视频的长宽和帧数mplayer -vo null -ao null -identify -frames 0 "$1" 2>/dev/null > video.infoFPS=`cat video.info | grep ID_VIDEO_FPS | cut -d = -f 2`#FPS=23.976W=`cat video.info | grep ID_VIDEO_WIDTH | cut -d = -f 2`H=`cat video.info | grep ID_VIDEO_HEIGHT | cut -d = -f 2`WIDTH=480HEIGHT=`expr $WIDTH \* $H \/ $W`echo $1 FPS=$FPS WIDTH=$WIDTH HEIGHT=$HEIGHTmkfifo audio.wav video.yuvfaac -o audio.aac audio.wav &mplayer -ao pcm:file=audio.wav:fast -vc null -vo null "$1" x264 --profile baseline --fps $FPS -o video.264 video.yuv ${WIDTH}x${HEIGHT} &mencoder -vf scale=$WIDTH:$HEIGHT,harddup,pp=fd,format=i420 -nosound -ovc raw -of rawvideo -ofps $FPS -o video.yuv "$1"MP4Box -new -add video.264 -add audio.aac -fps $FPS "$basename.mp4"rm video.info audio.aac video.264 audio.wav video.yuv#使用方法将上面的脚本保存为 x264.sh , x264.sh xxx.avi 来进行转化。
压制DVD到H264,支持ipod
#sudo apt-get install faac x264 gpac mplayerFPS=29.970mkfifo audio.wavcat VTS_01_1.VOB VTS_02_1.VOB VTS_02_2.VOB VTS_03_1.VOB VTS_04_1.VOB | mplayer -nocorrect-pts -vo null -vc null -ao pcm:file=audio.wav:fast - &faac audio.wav -o audio.aacmkfifo video.y4mcat VTS_01_1.VOB VTS_02_1.VOB VTS_02_2.VOB VTS_03_1.VOB VTS_04_1.VOB | mplayer -vo yuv4mpeg:file=video.y4m -vf scale=480:-3,harddup,pp=fd -nosound - &x264 --profile baseline --muxer mp4 --demuxer y4m video.y4m -o video.mp4MP4Box -add video.mp4 -add audio.aac -fps $FPS video.mp4
图形界面为ipod touch转mp4的方法
先确保有zenity和memcoder
wget /~lily/toIpod -O ~/.gnome2/nautilus-scripts/toIpod && chmod +x ~/.gnome2/nautilus-scripts/toIpod
在nautilus里对视频文件点右键,选择"脚本"-"toIpod".
详情请查看出处。
转换flv到MP4
#sudo apt-get install ffmpegffmpeg -i 矜持.flv -ar 22050 矜持.mp4
mencoder/mplayer 反拉丝参数
-vf lavcdeint
合并多个 rm 文件为一个 avi 文件
mencoder -ovc lavc 1.rm -oac mp3lame -o 1.avimencoder -ovc lavc 2.rm -oac mp3lame -o 2.avimencoder -idx 1.avi -ovc copy -oac copy -o o1.avimencoder -idx 2.avi -ovc copy -oac copy -o o2.avicat o1.avi o2.avi | mencoder -noidx -ovc copy -oac copy -o output.avi -
合并视频到一个文件
mencoder -ovc copy -oac copy -idx -o 目标文件名 文件名1 文件名2
CD 抓轨为 mp3 (有损)
#sudo apt-get install abcdeabcde -o mp3 -b
CD 抓轨为 Flac (无损)
#sudo apt-get install abcdeabcde -o flac -b
ape 转换为 flac
#sudo apt-get install flac shntool iconv mac#iconv -f GB2312 -t UTF-8 example.cue -o example_UTF-8.cue#shntool split -t "%n.%p-%t" -f example_UTF-8.cue -o flac example.ape -d flacOutputDir#sudo apt-get install libav-toolsffmpeg -i example.ape example.flac
ape/flac 转换为 mp3
#sudo apt-get install shntool iconv libav-toolsffmpeg -i CDImage.ape CDImage.flaciconv -f gbk -t utf-8 CDImage.cue | shntool split -t "%n.%p-%t" -o 'cust ext=mp3 lame --quiet -%f' CDImage.flac
批量将 ape 转为 mp3
for f in *.ape; do gst-launch-0.10 filesrc location="$f"! decodebin! audioconvert! lame vbr=0 bitrate=320! id3mux! filesink location="${f%.ape}.mp3"; done#需要安装 shntoolfor i in *.ape; do shnconv -i ape -o "cust ext=mp3 lame -b 320 -%f" "$i" -d mp3OutputDir; done
批量将 ape 转为 m4a
for f in *.ape; do ffmpeg -i "$f" -acodec alac "${f%.ape}.m4a"; done
批量将 ape 转为 aac
for f in *.ape; do ffmpeg -i "$f" -acodec aac -strict experimental -ab 256k "${f%.ape}.aac"; done
批量将 flac 转为 mp3
for i in *.flac; do shnconv -i flac -o "cust ext=mp3 lame -b 320 -%f" "$i" -d mp3OutputDir; done
批量将svg转为png
for i in *.svg; do inkscape $i --export-png=`echo $i | sed -e 's/svg$/png/'`; done
批量转换格式到mp3
#sudo apt-get install lame mplayerfor i in *; do base=${i%.*}; mplayer -quiet -vo null -vc dummy -af volume=0,resample=44100:0:1 -ao pcm:waveheader:file="$i.wav" "$i"; lame -V0 -h -b 192 -vbr-new "$i.wav" "$base.mp3"; rm -f "$i.wav"; done
批量缩小图片到30%
for i in *.jpg; do convert -resize 30%x30% "$i" "sm-$i"; done
批量转换jpg到png
for i in *.jpg; do convert $i `echo $i | sed -e 's/jpg$/png/'`; done
将文字转为图片
convert -size 200x30 xc:transparent -font /usr/share/fonts/truetype/wqy/wqy-microhei.ttc -fill red -pointsize 16 -draw "text 5,15 '测试中文转为图片'" test.png
如何压缩png图片
#sudo apt-get install optipngoptipng -o7 old.png new.png#或 sudo apt-get install pngcrush#pngcrush -brute old.png new.png
将多张图片合并到一个PDF文件
convert *.jpg out.pdf
批量把pdf转换为txt并格式化
sudo apt-get install poppler-utils poppler-datafind ./ -name '*.txt' | while read i; do cat $i | awk '{if ($0 ~ "^space:”) {printf “\n”$0} else {printf $0}}’ | sed ‘/^space:*digit:*$/d’ | sed ’s/^space:\+/ /’ | sed ’s/"/”/g’ > “../txt/$i”; done
转换 pdf 到 png
#sudo apt-get install imagemagickconvert -density 196 FILENAME.pdf FILENAME.png
获取jpg的扩展信息(Exif)
identify -verbose xxx.jpg
获取视频文件 xxx.avi 的信息
mplayer -vo null -ao null -frames 0 -identify "xxx.avi" 2>/dev/null | sed -ne '/^ID_/ { s/[]()|&;<>`'"'"'\\!$" []/\\&/g;p }'
查看MKV视频文件 xxx.mkv 的信息
#sudo apt-get install mkvtoolnixmkvinfo -v xxx.mkv