Pre- and post-processing
Table of Contents
- 1 Renaming, resizing, and changing format
- 2 grayscale all images in a folder
- 3 Mplayer command to transcode mpeg to png
- 4 transcode command to transcode mpeg to ppm
- 5 Script to deinterlace in imagemagick
- 6 Imagemagick command to create a gif animation out of jpeg/png files
- 7 Create an mpeg4 from jpegs using mencoder or png2yuv
- 8 Create mpeg video from pngs using png2yuv and mpeg2enc
- 9 Create a gstreamer pipe with jpg images, adds effecttv effect
- 10 Transcode commands for images to video
- 11 Playing jpgs with mplayer
- 12 Script to convert seconds to minutes
- 13 erase every nth file in a folder
- 14 creating better mpeg4 with ffmpeg for archive.org
1 Renaming, resizing, and changing format
1.1 Rename files
1.2 Rename, convert and with optional resize or crop command
The folder where the files are has to be named on the commandline and with the –resize option you can say what size the files should have with the –crop option you can crop around the middle of an image. with the –both option, you can resize and crop to create a square. jpg, jpeg and png are automatically recognized. Use –help to see all options. bugs: if another type of file is present, the renaming script skips a file.
1.3 Command to rename JPG to jpg on commandline
for i in *.JPG; do mv "$i" "`basename $i .JPG`.jpg"; done
2 grayscale all images in a folder
for i in berg/*.png; do convert $i -type grayscale $i; done
3 Mplayer command to transcode mpeg to png
mplayer -nosound -edl test -vo png:z=1 path/to/movie.mov
4 transcode command to transcode mpeg to ppm
transcode videos/video.mpg -x mpeg2,null -y ppm,null -o /tmp/ppm
5 Script to deinterlace in imagemagick
6 Imagemagick command to create a gif animation out of jpeg/png files
convert -delay 20 -loop 0 *.jpg animate.gif
convert -quiet -resize 360x288! -delay 5 *.png -ordered-dither o8x8,8,8,4 \ -layers OptimizeTransparency +map animate_opt.gif
7 Create an mpeg4 from jpegs using mencoder or png2yuv
mencoder "mf://*.jpg" -mf fps=25 -o output.avi -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=5000
8 Create mpeg video from pngs using png2yuv and mpeg2enc
png2yuv -j file%08d.png -I p -f 25 -b 1 | \
mpeg2enc -f 3 -q 3 -b 5000 -o out.m2v
9 Create a gstreamer pipe with jpg images, adds effecttv effect
gst-launch -v multifilesrc location="%03d.jpg" caps="image/jpeg,framerate=\(fraction\)6/1" \ ! decodebin ! ffmpegcolorspace ! warptv ! ximagesinko
10 Transcode commands for images to video
10.1 Export jpeg files to hdv mpeg
find *jpg -type f | sort > list transcode -H0 -i list -x mplayer,null -y mpeg2enc,null -o test -g 1920x1080 -f 25 \ -export_asr 3 --import_asr 3 -w 25000 -F3,"--no-constraints --nonvideo-bitrate 384 \ --force-b-b-p --video-buffer 448 --keep-hf --min-gop-size 6 --max-gop-size 6"
10.2 Export png files to raw avi changing fps
find *png -type f | sort > list transcode -x imlist,null --use_rgb -y raw,null -f 10 -i list -g 720x576 \ -o video.avi -H 0 -z -k --export_fps 25 --export_asr 2 -J fps=10:25
10.3 Export png to mpeg4 - strange black borders
-
Make file list
find *png -type f | sort > list
-
Transcode
transcode -x imlist,null --use_rgb -y ffmpeg,null -F mpeg4 -w 1000 -f 14 -i list \ -g 175x140 -Z 360x288 -o video.avi -H 0 -z -k --import_asr 2 --export_fps 25 \ --export_asr 2 -J fps=14:25 --export_par 1
10.4 s.a.b with audio dub
-
Make file list
find *png -type f | sort > list
-
Transcode
transcode -x imlist,raw --use_rgb -y ffmpeg -F mpeg4 -w 1000 -f 15 -i list \ -g 175x140 -Z 360x288 -o video.avi -H 0 -z -k --import_asr 2 --export_fps 25 \ --export_asr 2 -J fps=15:25 --export_par 1 -p ~/exhibit/test/Aurora.wav -e 44100 -n 0x1
10.5 Export png to mpeg2
-
Make file list
find *png -type f | sort > list
-
Transcode video, 1st pass
transcode -x imlist,null --use_rgb -y ffmpeg,null -F mpeg2video -f 15 -i list -g 720x576 \ -o video2 -z -k -H0 --import_asr 2 --export_fps 25 --export_asr 2 -J fps=15:25 --export_par 1 \ --encode_fields p -w 8500 -R 1,ffmpeg.log
-
Transcode video, 2nd pass
transcode -x imlist,null --use_rgb -y ffmpeg,null -F mpeg2video -f 15 -i list -g 720x576 -o \ video2 -z -k -H0 --import_asr 2 --export_fps 25 --export_asr 2 -J fps=15:25 --export_par 1 \ --encode_fields p -w 8500 -R 2,ffmpeg.log
-
Transcode audio to mp2
transcode -x null,raw -y null,mp2enc -J resample -e 44100 -n 0x1 -p ~/exhibit/test/Aurora.wav \ -E 48000 -m sound.mp2 -N 0x50 -b 192
-
Multiplex audio and video
mplex -f 3 -o video.mpeg video2.m2v sound.mp2
create ffmpeg.cfg file with the following content:
[mpeg2video] nr = 20 gray = 0 mbd = 2 mv0 = 1 trell = 1 cbp = 1 cmp = 3 subcmp = 3 vqcomp = 0.7 vqblur = 0.3 vrcminrate=0 vrcmaxrate=9800 vrcbufsize=1792
11 Playing jpgs with mplayer
mplayer mf://*.jpg -mf fps=18:type=jpg
12 Script to convert seconds to minutes
Required to pass arguments to mplayer sometimes, as it counts time in seconds
13 erase every nth file in a folder
14 creating better mpeg4 with ffmpeg for archive.org
explanation with examples mp4creator -optimize outfile2.mp4
Date: 2009-10-18 14:37:38 CEST
HTML generated by org-mode 6.24b in emacs 22