Howto automate JPEG to MP4 with Mencoder in Windows
Posted: Sat Jan 08, 2011 7:30 pm
Howto automate JPEG to MP4 with Mencoder in Windows
With this process, you can convert motions detected jpg in a viewable MP4 video. Since it is called from a command line , you can easily automate the process. If CPU usage is an issue, you can also convert to mjpeg( motion jpeg) which is basically a stack of jpeg in a mpeg file, It will use less cpu power , but will build a file as big as your original JPEG. MJPEG might be more compatible to more video reader.
Performances on a 2.4ghz Core2 quad , 4gb ram, Windows XP to :
Convert 4800 95kb 720x480 jpg (total450mb) to MP4 :
Output file size: 24mb
3-10 minutes
Use a 10-20mb of ram while in the process
Use 25% of cpu
Edit:
(Doesn't seem to bee possible to use more that a core)
(Windows split the task on many cores thus: )
(Will usee 100% on a single core)
(Will usee 50% on a dual core)
(Will usee 25% on a quad core)
Convert 4800 95kb 720x480 jpg (total450mb) to MJPEG :
Output file size: 415mb
2 minutes
Use a 3-5mb of ram while in the process
Use 2% of cpu
Step 1 :
Download and unzip (you might need 7zip) Mplayer with MEncoder
http://www.mplayerhq.hu/design7/dload.html
Actualy you only need Mencoder, the Player is useless for this process
It wasn’t really well sorted out on there web page when I’ve searched for it, here is a direct download link, Pick the one with your CPU
http://sourceforge.net/projects/mplayer ... z/download
Step 2:
You only need the mencoder.exe file, put it in your JPEG folder, havent found a better working way to do it
Step3:
Build yourself a .bat file in the same folder , here is mine:
______________
:begining
REM ------MJPEG-------
mencoder mf://*.jpg -mf w=720:h=480:fps=20:type=jpg -ovc copy -oac copy -o cam1.avi
REM ------MP4---------
REM mencoder mf://*.jpg -mf w=720:h=480:fps=20:type=jpg -ovc lavc -lavcopts vcodec=mpeg4:mbd=2:trell -oac copy -o cam1.avi
xcopy cam1.avi .. /Y
del cam1.avi
ping 127.0.0.2 -w 5000
ping 127.0.0.2 -w 5000
goto :beginning
________________
It basically compress all jpeg in the same folder to a video file
(Remove the REM comment) before the compression type you need.
It moves the video file in the preceding Folder
It wait 10 seconds while doing fake ping commands, and do it all again.
Step 4
Use VLC to read the file
Sources :
http://www.mplayerhq.hu/DOCS/HTML/en/me ... mages.html
Command line result:
C:\camera\cam1\move>REM ------MJPEG-------
C:\camera\cam1\move>REM mencoder mf://*.jpg -mf w=720:h=480:fps=20:type=jpg –ovc copy -oac copy -o cam1.avi
C:\camera\cam1\move>REM ------MP4---------
C:\camera\cam1\move>mencoder mf://*.jpg -mf w=720:h=480:fps=20:type=jpg -ovc lav
c -lavcopts vcodec=mpeg4:mbd=2:trell -oac copy -o cam1.avi
MEncoder SVN-r32735-4.2.5 (C) 2000-2010 MPlayer Team
success: format: 16 data: 0x0 - 0x0
MF file format detected.
[mf] search expr: *.jpg
[mf] number of files: 5311 (21244)
VIDEO: [IJPG] 720x480 24bpp 20.000 fps 0.0 kbps ( 0.0 kbyte/s)
[V] filefmt:16 fourcc:0x47504A49 size:720x480 fps:20.000 ftime:=0.0500
Opening video filter: [expand osd=1]
Expand: -1 x -1, -1 ; -1, osd: 1, aspect: 0.000000, round: 1
==========================================================================
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
Selected video codec: [ffmjpeg] vfm: ffmpeg (FFmpeg MJPEG)
==========================================================================
Movie-Aspect is 1.50:1 - prescaling to correct movie aspect.
videocodec: libavcodec (720x480 fourcc=34504d46 [FMP4])
[VE_LAVC] High quality encoding selected (non-realtime)!
Fontconfig error: Cannot load default config file
Fontconfig failed to select a font. Trying without fontconfig...
New_Face failed. Maybe the font path is wrong.
Please supply the text font file (~/.mplayer/subfont.ttf).
subtitle font: load_sub_face failed.
Fontconfig failed to select a font. Trying without fontconfig...
New_Face failed. Maybe the font path is wrong.
Please supply the text font file (~/.mplayer/subfont.ttf).
subtitle font: load_sub_face failed.
Writing header...
ODML: Aspect information not (yet?) available or unspecified, not writing vprp h
eader.
Writing header...
ODML: Aspect information not (yet?) available or unspecified, not writing vprp h
eader.
Pos: 98.8s 1975f (37%) 17.46fps Trem: 3min 25mb A-V:0.000 [804:0]]
With this process, you can convert motions detected jpg in a viewable MP4 video. Since it is called from a command line , you can easily automate the process. If CPU usage is an issue, you can also convert to mjpeg( motion jpeg) which is basically a stack of jpeg in a mpeg file, It will use less cpu power , but will build a file as big as your original JPEG. MJPEG might be more compatible to more video reader.
Performances on a 2.4ghz Core2 quad , 4gb ram, Windows XP to :
Convert 4800 95kb 720x480 jpg (total450mb) to MP4 :
Output file size: 24mb
3-10 minutes
Use a 10-20mb of ram while in the process
Use 25% of cpu
Edit:
(Doesn't seem to bee possible to use more that a core)
(Windows split the task on many cores thus: )
(Will usee 100% on a single core)
(Will usee 50% on a dual core)
(Will usee 25% on a quad core)
Convert 4800 95kb 720x480 jpg (total450mb) to MJPEG :
Output file size: 415mb
2 minutes
Use a 3-5mb of ram while in the process
Use 2% of cpu
Step 1 :
Download and unzip (you might need 7zip) Mplayer with MEncoder
http://www.mplayerhq.hu/design7/dload.html
Actualy you only need Mencoder, the Player is useless for this process
It wasn’t really well sorted out on there web page when I’ve searched for it, here is a direct download link, Pick the one with your CPU
http://sourceforge.net/projects/mplayer ... z/download
Step 2:
You only need the mencoder.exe file, put it in your JPEG folder, havent found a better working way to do it
Step3:
Build yourself a .bat file in the same folder , here is mine:
______________
:begining
REM ------MJPEG-------
mencoder mf://*.jpg -mf w=720:h=480:fps=20:type=jpg -ovc copy -oac copy -o cam1.avi
REM ------MP4---------
REM mencoder mf://*.jpg -mf w=720:h=480:fps=20:type=jpg -ovc lavc -lavcopts vcodec=mpeg4:mbd=2:trell -oac copy -o cam1.avi
xcopy cam1.avi .. /Y
del cam1.avi
ping 127.0.0.2 -w 5000
ping 127.0.0.2 -w 5000
goto :beginning
________________
It basically compress all jpeg in the same folder to a video file
(Remove the REM comment) before the compression type you need.
It moves the video file in the preceding Folder
It wait 10 seconds while doing fake ping commands, and do it all again.
Step 4
Use VLC to read the file
Sources :
http://www.mplayerhq.hu/DOCS/HTML/en/me ... mages.html
Command line result:
C:\camera\cam1\move>REM ------MJPEG-------
C:\camera\cam1\move>REM mencoder mf://*.jpg -mf w=720:h=480:fps=20:type=jpg –ovc copy -oac copy -o cam1.avi
C:\camera\cam1\move>REM ------MP4---------
C:\camera\cam1\move>mencoder mf://*.jpg -mf w=720:h=480:fps=20:type=jpg -ovc lav
c -lavcopts vcodec=mpeg4:mbd=2:trell -oac copy -o cam1.avi
MEncoder SVN-r32735-4.2.5 (C) 2000-2010 MPlayer Team
success: format: 16 data: 0x0 - 0x0
MF file format detected.
[mf] search expr: *.jpg
[mf] number of files: 5311 (21244)
VIDEO: [IJPG] 720x480 24bpp 20.000 fps 0.0 kbps ( 0.0 kbyte/s)
[V] filefmt:16 fourcc:0x47504A49 size:720x480 fps:20.000 ftime:=0.0500
Opening video filter: [expand osd=1]
Expand: -1 x -1, -1 ; -1, osd: 1, aspect: 0.000000, round: 1
==========================================================================
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
Selected video codec: [ffmjpeg] vfm: ffmpeg (FFmpeg MJPEG)
==========================================================================
Movie-Aspect is 1.50:1 - prescaling to correct movie aspect.
videocodec: libavcodec (720x480 fourcc=34504d46 [FMP4])
[VE_LAVC] High quality encoding selected (non-realtime)!
Fontconfig error: Cannot load default config file
Fontconfig failed to select a font. Trying without fontconfig...
New_Face failed. Maybe the font path is wrong.
Please supply the text font file (~/.mplayer/subfont.ttf).
subtitle font: load_sub_face failed.
Fontconfig failed to select a font. Trying without fontconfig...
New_Face failed. Maybe the font path is wrong.
Please supply the text font file (~/.mplayer/subfont.ttf).
subtitle font: load_sub_face failed.
Writing header...
ODML: Aspect information not (yet?) available or unspecified, not writing vprp h
eader.
Writing header...
ODML: Aspect information not (yet?) available or unspecified, not writing vprp h
eader.
Pos: 98.8s 1975f (37%) 17.46fps Trem: 3min 25mb A-V:0.000 [804:0]]