Skip to content

Some significant fixes for ffmpeg-php #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions config.w32
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// $Id$
// vim:ft=javascript

ARG_WITH("ffmpeg", "ffmpeg support", "no");

if(PHP_FFMPEG != "no")
{
if(
CHECK_LIB("avcodec.lib", "ffmpeg", PHP_FFMPEG + "\\lib")
&& CHECK_LIB("avformat.lib", "ffmpeg", PHP_FFMPEG + "\\lib")
&& CHECK_LIB("avutil.lib", "ffmpeg", PHP_FFMPEG + "\\lib")
&& CHECK_LIB("swscale.lib", "ffmpeg", PHP_FFMPEG + "\\lib")
&& CHECK_HEADER_ADD_INCLUDE("libavcodec\\avcodec.h", "CFLAGS_FFMPEG", PHP_FFMPEG + "\\include"))
{
// Will crash in Release mode if you don't have the following compile
// flag

ADD_FLAG("LDFLAGS_FFMPEG", "/OPT:NOREF");

AC_DEFINE("HAVE_LIBGD20", 1);
AC_DEFINE("HAVE_SWSCALER", 1);
AC_DEFINE("HAVE_FFMPEG_PHP", 1);
AC_DEFINE("COMPILE_DL_FFMPEG", 1);
EXTENSION("ffmpeg", "ffmpeg-php.c ffmpeg_movie.c ffmpeg_frame.c ffmpeg_errorhandler.c ffmpeg_tools.c", true);
//
// Use the following instead of above to build the extension into php
// instead of as ext DLL
//
// EXTENSION("ffmpeg", "ffmpeg-php.c ffmpeg_movie.c ffmpeg_frame.c ffmpeg_errorhandler.c ffmpeg_tools.c");
}
else
{
WARNING("ffmpeg not enabled; libraries and headers not found");
}
}

9 changes: 5 additions & 4 deletions ffmpeg-php.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,11 @@ PHP_MSHUTDOWN_FUNCTION(ffmpeg)
Add an entry for ffmpeg-php support in phpinfo() */
PHP_MINFO_FUNCTION(ffmpeg)
{
AVCodec *next_codec = NULL;
char *m_codec_list = NULL;
long m_codec_list_len = 0;
long m_codec_len = 0;

php_info_print_table_start();
// php_info_print_table_header(2, "ffmpeg-php", "enabled");
php_info_print_table_row(2, "ffmpeg-php version", FFMPEG_PHP_VERSION);
Expand All @@ -169,10 +174,6 @@ PHP_MINFO_FUNCTION(ffmpeg)
#endif

//phpinfo should show the codec list available to aid developers
AVCodec *next_codec = NULL;
char *m_codec_list = NULL;
long m_codec_list_len = 0;
long m_codec_len = 0;
while((next_codec = av_codec_next(next_codec))) {
//go through each codec and add to the list
m_codec_len = (strlen(next_codec->name) + 5);
Expand Down
Empty file modified ffmpeg-phpinfo.php
100755 → 100644
Empty file.
5 changes: 4 additions & 1 deletion ffmpeg_frame.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ int _php_convert_frame(ff_frame_context *ff_frame, int dst_fmt) {
AVFrame *dst_frame;
int result = 0;

TSRMLS_FETCH();

if (!ff_frame->av_frame) {
return -1;
}
Expand Down Expand Up @@ -430,7 +432,8 @@ FFMPEG_PHP_METHOD(ffmpeg_frame, getPresentationTimestamp)

GET_FRAME_RESOURCE(getThis(), ff_frame);

RETURN_DOUBLE((double)ff_frame->pts / AV_TIME_BASE);
//RETURN_DOUBLE((double)ff_frame->pts / AV_TIME_BASE);
RETURN_DOUBLE(ff_frame->pts);
}
/* }}} */

Expand Down
2 changes: 1 addition & 1 deletion ffmpeg_frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ typedef struct {
int height;
int pixel_format;
int keyframe;
int64_t pts;
double pts;
} ff_frame_context;

ff_frame_context* _php_create_ffmpeg_frame(INTERNAL_FUNCTION_PARAMETERS);
Expand Down
Loading