-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47 from danieljprice/mp4
mp4 device, v1.4.0
- Loading branch information
Showing
13 changed files
with
350 additions
and
368 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
Changes in v1.3.2 | ||
Changes in v1.4.0 | ||
------------------ | ||
- bug fix with spaces at end of string causing failure on open_device in Fortran interface (#35) | ||
- added mp4 driver, can simply give "file.mp4" as the device to generate mp4 file | ||
- can amend flags to ffmpeg using GIZA_FFMPEG_FLAGS environment variable | ||
- automated cleanup of temporary .png files used to make the movie |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#! /bin/sh | ||
# Guess values for system-dependent variables and create Makefiles. | ||
# Generated by GNU Autoconf 2.71 for giza 1.3.2. | ||
# Generated by GNU Autoconf 2.71 for giza 1.4.0. | ||
# | ||
# Report bugs to <[email protected]>. | ||
# | ||
|
@@ -621,8 +621,8 @@ MAKEFLAGS= | |
# Identity of this package. | ||
PACKAGE_NAME='giza' | ||
PACKAGE_TARNAME='giza' | ||
PACKAGE_VERSION='1.3.2' | ||
PACKAGE_STRING='giza 1.3.2' | ||
PACKAGE_VERSION='1.4.0' | ||
PACKAGE_STRING='giza 1.4.0' | ||
PACKAGE_BUGREPORT='[email protected]' | ||
PACKAGE_URL='http://danieljprice.github.io/giza' | ||
|
||
|
@@ -1386,7 +1386,7 @@ if test "$ac_init_help" = "long"; then | |
# Omit some internal or obsolete options to make the list less imposing. | ||
# This message is too long to be a string in the A/UX 3.1 sh. | ||
cat <<_ACEOF | ||
\`configure' configures giza 1.3.2 to adapt to many kinds of systems. | ||
\`configure' configures giza 1.4.0 to adapt to many kinds of systems. | ||
|
||
Usage: $0 [OPTION]... [VAR=VALUE]... | ||
|
||
|
@@ -1457,7 +1457,7 @@ fi | |
|
||
if test -n "$ac_init_help"; then | ||
case $ac_init_help in | ||
short | recursive ) echo "Configuration of giza 1.3.2:";; | ||
short | recursive ) echo "Configuration of giza 1.4.0:";; | ||
esac | ||
cat <<\_ACEOF | ||
|
||
|
@@ -1587,7 +1587,7 @@ fi | |
test -n "$ac_init_help" && exit $ac_status | ||
if $ac_init_version; then | ||
cat <<\_ACEOF | ||
giza configure 1.3.2 | ||
giza configure 1.4.0 | ||
generated by GNU Autoconf 2.71 | ||
|
||
Copyright (C) 2021 Free Software Foundation, Inc. | ||
|
@@ -1891,7 +1891,7 @@ cat >config.log <<_ACEOF | |
This file contains any messages produced by compilers while | ||
running configure, to aid debugging if configure makes a mistake. | ||
|
||
It was created by giza $as_me 1.3.2, which was | ||
It was created by giza $as_me 1.4.0, which was | ||
generated by GNU Autoconf 2.71. Invocation command line was | ||
|
||
$ $0$ac_configure_args_raw | ||
|
@@ -3161,7 +3161,7 @@ fi | |
|
||
# Define the identity of the package. | ||
PACKAGE='giza' | ||
VERSION='1.3.2' | ||
VERSION='1.4.0' | ||
|
||
|
||
printf "%s\n" "#define PACKAGE \"$PACKAGE\"" >>confdefs.h | ||
|
@@ -4810,9 +4810,9 @@ ac_config_headers="$ac_config_headers config.h" | |
|
||
GIZA_VERSION_MAJOR=1 | ||
|
||
GIZA_VERSION_MINOR=3 | ||
GIZA_VERSION_MINOR=4 | ||
|
||
GIZA_VERSION_MICRO=2 | ||
GIZA_VERSION_MICRO=0 | ||
|
||
# | ||
# The following specify the interface version numbers for giza. | ||
|
@@ -4828,7 +4828,7 @@ GIZA_VERSION_MICRO=2 | |
# | ||
LT_CURRENT=1 | ||
|
||
LT_REVISION=2 | ||
LT_REVISION=0 | ||
|
||
LT_AGE=1 | ||
|
||
|
@@ -16970,7 +16970,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 | |
# report actual input values of CONFIG_FILES etc. instead of their | ||
# values after options handling. | ||
ac_log=" | ||
This file was extended by giza $as_me 1.3.2, which was | ||
This file was extended by giza $as_me 1.4.0, which was | ||
generated by GNU Autoconf 2.71. Invocation command line was | ||
|
||
CONFIG_FILES = $CONFIG_FILES | ||
|
@@ -17039,7 +17039,7 @@ ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\ | |
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 | ||
ac_cs_config='$ac_cs_config_escaped' | ||
ac_cs_version="\\ | ||
giza config.status 1.3.2 | ||
giza config.status 1.4.0 | ||
configured by $0, generated by GNU Autoconf 2.71, | ||
with options \\"\$ac_cs_config\\" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
AC_PREREQ(2.61) | ||
m4_define(giza_version_major,1) | ||
m4_define(giza_version_minor,3) | ||
m4_define(giza_version_micro,2) | ||
m4_define(giza_version_minor,4) | ||
m4_define(giza_version_micro,0) | ||
AC_INIT([giza], | ||
[giza_version_major.giza_version_minor.giza_version_micro], | ||
[[email protected]],[], | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* giza - a scientific plotting library built on cairo | ||
* | ||
* Copyright (c) 2010 James Wetter and Daniel Price | ||
* Copyright (c) 2010-2023 Daniel Price | ||
* | ||
* This library is free software; and you are welcome to redistribute | ||
* it under the terms of the GNU General Public License | ||
* (GPL, see LICENSE file for details) and the provision that | ||
* this notice remains intact. If you modify this file, please | ||
* note section 2a) of the GPLv2 states that: | ||
* | ||
* a) You must cause the modified files to carry prominent notices | ||
* stating that you changed the files and the date of any change. | ||
* | ||
* This software is distributed "AS IS", with ABSOLUTELY NO WARRANTY. | ||
* See the GPL for specific language governing rights and limitations. | ||
* | ||
* The Original code is the giza plotting library. | ||
* | ||
* Contributor(s): | ||
* James Wetter <[email protected]> | ||
* Daniel Price <[email protected]> (main contact) | ||
*/ | ||
|
||
void _giza_close_device_mp4 (int last); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/* giza - a scientific plotting library built on cairo | ||
* | ||
* Copyright (c) 2010 James Wetter and Daniel Price | ||
* Copyright (c) 2010-2023 Daniel Price | ||
* | ||
* This library is free software; and you are welcome to redistribute | ||
* it under the terms of the GNU General Public License | ||
* (GPL, see LICENSE file for details) and the provision that | ||
* this notice remains intact. If you modify this file, please | ||
* note section 2a) of the GPLv2 states that: | ||
* | ||
* a) You must cause the modified files to carry prominent notices | ||
* stating that you changed the files and the date of any change. | ||
* | ||
* This software is distributed "AS IS", with ABSOLUTELY NO WARRANTY. | ||
* See the GPL for specific language governing rights and limitations. | ||
* | ||
* The Original code is the giza plotting library. | ||
* | ||
* Contributor(s): | ||
* James Wetter <[email protected]> | ||
* Daniel Price <[email protected]> (main contact) | ||
*/ | ||
|
||
#include "giza-private.h" | ||
#include "giza-drivers-private.h" | ||
#include "giza-io-private.h" | ||
#include "giza-driver-png-private.h" | ||
#include "giza-driver-mp4-private.h" | ||
#include <giza.h> | ||
#include <stdio.h> | ||
#include <string.h> | ||
#include <stdlib.h> | ||
#include <unistd.h> | ||
|
||
#define GIZA_DEVICE_EXTENSION ".mp4" | ||
#define GIZA_FFMPEG_FLAGS_DEFAULT "-r 10 -vb 50M -bt 100M -pix_fmt yuv420p -vf setpts=4.*PTS" | ||
|
||
/** | ||
* Closes an open mp4 device. This closes the sequence of png images | ||
* and compiles them into a movie | ||
*/ | ||
void | ||
_giza_close_device_mp4 (int last) | ||
{ | ||
_giza_close_device_png(last); | ||
if (Dev[id].drawn && last==1) { | ||
/* construct filename for mp4 file */ | ||
int lenext = strlen(GIZA_DEVICE_EXTENSION); | ||
int length = strlen(Dev[id].prefix) + lenext + 5; | ||
char fileName[length + 1]; | ||
_giza_get_filename_for_device(fileName, Dev[id].prefix, 0, GIZA_DEVICE_EXTENSION, 1); | ||
|
||
/* delete the existing mp4 file if it exists */ | ||
if (access(fileName, F_OK) != -1) | ||
{ | ||
remove(fileName); | ||
} | ||
|
||
/* allow the user to change the ffmpeg flags with an environment variable */ | ||
char *userFlags = getenv("GIZA_FFMPEG_FLAGS"); | ||
char *flagsToUse = userFlags ? userFlags : GIZA_FFMPEG_FLAGS_DEFAULT; | ||
|
||
/* construct ffmpeg command and repeat it to the user */ | ||
char command[512]; /* Adjust size as needed */ | ||
sprintf(command, "ffmpeg -i %s_%%04d.png %s %s", Dev[id].prefix,flagsToUse,fileName); | ||
_giza_message(command); | ||
|
||
/* issue command and check that it succeeded */ | ||
int success = system(command); | ||
if (success != 0) { | ||
_giza_message("Error: ffmpeg command failed: please install ffmpeg using your package manager"); | ||
} else { | ||
char tmp[length + 10]; | ||
sprintf(tmp, "%s created", fileName); | ||
_giza_message(tmp); | ||
|
||
/* if the mp4 file exists, clean up the temporary .png files */ | ||
if (access(fileName, F_OK) != -1) | ||
{ | ||
for (int i = 0; i <= Dev[id].pgNum; i++) | ||
{ | ||
_giza_get_filename_for_device(fileName, Dev[id].prefix, i, ".png", 0); | ||
|
||
if (access(fileName, F_OK) != -1) | ||
{ | ||
if (remove(fileName) != 0) | ||
{ | ||
printf("Unable to delete %s \n",fileName); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.