mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
foamCreateVideo: enabled to use avconv and output WebM format
Resolves feature request http://www.openfoam.org/mantisbt/view.php?id=1722
This commit is contained in:
@ -26,8 +26,8 @@
|
|||||||
# foamCreateVideo
|
# foamCreateVideo
|
||||||
#
|
#
|
||||||
# Description
|
# Description
|
||||||
# Creates an MPEG-4 compressed (.mp4) video file from PNG images
|
# Creates a video file from PNG images
|
||||||
# - requires mencoder
|
# - requires avconv or mencoder
|
||||||
#
|
#
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -43,14 +43,15 @@ options:
|
|||||||
-h | -help help
|
-h | -help help
|
||||||
-i | -image <name> name of image sequence (default = image)
|
-i | -image <name> name of image sequence (default = image)
|
||||||
-o | -out <name> name of output video file (default = video)
|
-o | -out <name> name of output video file (default = video)
|
||||||
|
-w | -webm WebM output video file format
|
||||||
|
|
||||||
Creates an MPEG-4 compressed (.mp4) video file from a sequence of PNG images
|
Creates a video file from a sequence of PNG images
|
||||||
- A sequence named "image" will expect files image.0000.png, image.0001.png, etc
|
- A sequence named "image" will expect files image.0000.png, image.0001.png, etc
|
||||||
- An output video named "video" will produce a file video.mp4
|
- The default output video compression format is MPEG-4, with WebM as an option
|
||||||
- By default the video codec is high resolution (x264) but there is an option to
|
- The default file name, using MPEG-4 compression, is video.mp4
|
||||||
select a medium resolution codec (lavc)
|
- By default the video codec is high resolution
|
||||||
|
|
||||||
Requires mencoder
|
Requires avconv or mencoder for MPEG-4 output, avconv for WebM output
|
||||||
|
|
||||||
USAGE
|
USAGE
|
||||||
exit 1
|
exit 1
|
||||||
@ -62,8 +63,7 @@ DIR='.'
|
|||||||
IMAGE='image'
|
IMAGE='image'
|
||||||
VIDEO='video'
|
VIDEO='video'
|
||||||
FPS=10
|
FPS=10
|
||||||
VCODEC=x264
|
FMT='mp4'
|
||||||
|
|
||||||
|
|
||||||
while [ "$#" -gt 0 ]
|
while [ "$#" -gt 0 ]
|
||||||
do
|
do
|
||||||
@ -91,6 +91,11 @@ do
|
|||||||
VIDEO=$2
|
VIDEO=$2
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
|
-w | -webm)
|
||||||
|
FMT=webm
|
||||||
|
echo "Selected $FMT format, requires avconv..."
|
||||||
|
shift
|
||||||
|
;;
|
||||||
-*)
|
-*)
|
||||||
usage "invalid option '$1'"
|
usage "invalid option '$1'"
|
||||||
;;
|
;;
|
||||||
@ -106,12 +111,35 @@ done
|
|||||||
|
|
||||||
[ -f "$(ls -1 $DIR/$IMAGE.*.png | head -1)" ] || usage "Cannot find first file in image sequence"
|
[ -f "$(ls -1 $DIR/$IMAGE.*.png | head -1)" ] || usage "Cannot find first file in image sequence"
|
||||||
|
|
||||||
if command -v mencoder >/dev/null 2>&1; then
|
if [ "$FMT" = "webm" ] ; then
|
||||||
mencoder \
|
if command -v avconv >/dev/null 2>&1 ; then
|
||||||
"mf://$DIR/$IMAGE.*.png" \
|
echo "Creating image with avconv..."
|
||||||
-mf fps=$FPS \
|
avconv \
|
||||||
-o $VIDEO.mp4 \
|
-r 1 \
|
||||||
-ovc $VCODEC
|
-i ${DIR}/${IMAGE}.%04d.png \
|
||||||
|
-r $FPS \
|
||||||
|
-c:v libvpx -crf 15 -b:v 1M \
|
||||||
|
$VIDEO.$FMT
|
||||||
|
else
|
||||||
|
usage "Please install avconv"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
usage "Please install mencoder"
|
if command -v avconv >/dev/null 2>&1 ; then
|
||||||
|
echo "Creating image with avconv..."
|
||||||
|
avconv \
|
||||||
|
-r 1 \
|
||||||
|
-i ${DIR}/${IMAGE}.%04d.png \
|
||||||
|
-r $FPS \
|
||||||
|
-c:v libx264 -pix_fmt yuv420p \
|
||||||
|
$VIDEO.$FMT
|
||||||
|
elif command -v mencoder >/dev/null 2>&1 ; then
|
||||||
|
echo "Creating image with mencoder..."
|
||||||
|
mencoder \
|
||||||
|
"mf://$DIR/$IMAGE.*.png" \
|
||||||
|
-mf fps=$FPS \
|
||||||
|
-o $VIDEO.$FMT \
|
||||||
|
-ovc x264
|
||||||
|
else
|
||||||
|
usage "Please install avconv or mencoder"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user