IN PROGRESS: IDLffVideoWrite: Example Linux instructions to replace IDL 8.2 FFmpeg library with user obtained library from FFmpeg web site
Anonym
==============================================================
Exelis Visual Information Solutions Technical Support:
example instructions to replace FFmpeg libs in 64-bit IDL 8.2
for Linux with user copy obtained from FFmpeg web site.
==============================================================
1.) DOWNLOAD FFMPEG VERSION NEEDED TO MODIFY IDL 8.2
Get the "FFmpeg 0.8.12 "Love"" release ("ffmpeg-0.8.12.tar.gz") from:
http://www.ffmpeg.org/download.html
[ Test download distribution files for Tech Support can be found
on tech support rhel 6.2 test machine under the directory:
~/Downloads/ffmpeg
]
2.) LIBRARY DEPENDENCIES
[ To get the resulting "ffmpeg" executable to run on an Exelis VIS
Tech Support RHEL 6.2 machine required additional installation
of "yasm" package. Had to download rpm file from http://rpmfind.net
and then installed the downloaded rpm package with a command
like:
sudo rpm -install /path/to/yasm-1.2.0-1.el6.x86_64.rpm
Not sure if this lib is needed to use the user-installed libs with
IDL 8.2.
]
3.) UNPACK DISTRIBUTION
gzip -d ./ffmpeg-0.8.12.tar.gz
tar xvf ./ffmpeg-0.8.12.tar
4.) INSTRUCTIONS TO ENABLE x264/H.264 ENCODING
See instructions provided by link on FFmpeg doc page:
http://www.ffmpeg.org/general.html#x264
[ At this time, this step has not been tested and we leave the
details of implementation to the end-user. ]
5.) BUILD/INSTALL INSTRUCTIONS
For general FFmpeg lib build/installation steps read INSTALL file
from unpacked distribution.
6.) CREATE BUILD/INSTALL DIRECTORY
Example commands below assume that destination directory will be
"/sw/util/ffmpeg-0.8.12" with a generic symbolic link directory
name of "ffmpeg".
sudo mkdir /sw
sudo mkdir /sw/util
sudo mkdir /sw/util/ffmpeg-0.8.12
sudo ln -s /sw/util/ffmpeg-0.8.12 /sw/util/ffmpeg
7.) BUILD AND INSTALL FFMPEG BINARIES
(Destination directory: /sw/utils/ffmpeg)
[ Run "./config --help" from FFmpeg source dir for config options. ]
[ To enable use of x264 module (I assume) you'll also need to
use the following "configure" switches:
--enable-libx264 --enable-gpl
See also step #4 above for installing x264/H.264 support.
]
cd /path/to/ffmpeg-0.8.12/sourcefiles
sudo ./configure --prefix=/sw/util/ffmpeg --enable-shared \
--enable-libx264 --enable-gpl
sudo make
sudo make install
[ Note: Building of binaries resulted in lots of warnings but no errors. ]
[ If needed, before configuring/building libraries again, be sure to
issue "make clean" command. ]
8.) REPLACE ORIGINAL IDL LIBS WITH NEW FFMPEG LIBS
cd /usr/local/exelis/idl82/bin/bin.linux.x86_64
sudo mv libavcodec.so.53 libavcodec.so.53.orig
sudo mv libavformat.so.53 libavformat.so.53.orig
sudo mv libavutil.so.51 libavutil.so.51.orig
cd /sw/util/ffmpeg-0.8.12
sudo cp ./libavcodec/libavcodec.so.53* /usr/local/exelis/idl82/bin/bin.linux.x86_64/
sudo cp ./libavformat/libavformat.so.53* /usr/local/exelis/idl82/bin/bin.linux.x86_64/
sudo cp ./libavutil/libavutil.so.51* /usr/local/exelis/idl82/bin/bin.linux.x86_64/
9.) EXAMPLE TEST CODE USING REPLACEMENT FFMPEG LIBS WITH IDL 8.2:
;+
; :Description:
; Exelis VIS Technical Support example IDL program to test the
; use of user-provided FFmpeg libraries with IDL 8.2.
;-
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PRO test_replace_ffmpeg_libs
; Get the current routine file directory (doesn't work with main level programs)
scope = SCOPE_TRACEBACK(/STRUCT)
thisfilename = (scope[-1]).FILENAME
thisdir = FILE_DIRNAME(thisfilename, /MARK_DIRECTORY)
READ_JPEG, FILE_WHICH('rose.jpg'), img, /TRUE
HELP, img
; Make frame dimensions even
img = CONGRID(img, 3, 228, 150)
PRINT, 'Make frame dimensions even:'
HELP, img
; Parameters for video
width = 228
height = 150
frames = 100
fps = 30
; Codec "wmv2" is not supported by default by
; IDL 8.2 IDLffVideoWrite
fileext = 'avi'
codec = 'wmv2'
; ; Codec "mpeg4" *is* supported by default by
; ; IDL 8.2 IDLffVideoWrite
; fileext = 'mp4'
; codec = 'mpeg4'
file = thisdir + 'myvid.' + fileext
ov = IDLffVideoWrite(file)
codecs = ov.GetCodecs(/VIDEO)
; Check for codec support
found = codecs[WHERE(STREGEX(codecs, codec, /BOOLEAN), /NULL)]
IF N_ELEMENTS(found) NE 0 THEN $
PRINT, '% '+codec+' supported? > ', found $
ELSE BEGIN
PRINT, 'Codec "', codec, '" not found. Returning...'
RETURN
ENDELSE
; Add codec video stream. specified codec won't be
; used if not supported by currently installed ffmpeg libs.
vidstream = ov.AddVideoStream(width, height, fps, CODEC=codec)
; Add video frames
FOR I=0, 99 DO $
time = ov.Put(vidstream, SHIFT(img, 0, 10*i, 10*i))
ov.Cleanup
OBJ_DESTROY, ov
PRINT, 'Video file created: ' + file
END
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;