On Fri, 12 Sep 2003, Kevin Atkinson wrote: > Here is what I got: > avs2yuv4mpeg.cpp - the main program > avisynth_c.h - header for DLL I need to link with > avisynth_c.lib - lib " " " > > And I want to compile this into an executable avs2yuv4mpeg
OK I figured out how to get it to compile. I manually created libavisynth_c.def, it is attached. I know that wasn't the best thing to do but it worked. Why is this necessary? Can't it use the .lib file? Failing that is there a script to create the .def from the .lib? However, I didn't seam to gain anything from making it a winelib application. It still runs like a windows application and uses wine. Furthermore it is still using windows I/O. How can I use the native glibc I/O libraries? In particular I want to be able for stdout and stderr to be handles like they would in a linux application so I can send my output to stdout (with out any line conversion) and messages to stderr. Right now when I redirect stdout stderr gets redirected also. Is it possible to run a winelib application as a native executable, or is wine needed for the loading of windows dlls? avs2yuv4mpeg.cpp is also attached. --- http://kevin.atkinson.dhs.org
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <windef.h> #include "avisynth_c.h" typedef unsigned char byte; int main(int argc, const char * argv[]) { if (argc != 2) {puts("Need Source Video"); return 2;} AVS_ScriptEnvironment * env = avs_create_script_environment(AVISYNTH_INTERFACE_VERSION); AVS_Value arg0 = avs_new_value_string(argv[1]); AVS_Value args = avs_new_value_array(&arg0, 1); AVS_Value res = avs_invoke(env, "avisource", args, 0); if (avs_is_error(res)) { fputs(avs_as_string(res),stderr); fputc('\n', stderr); return 1;} arg0 = res; res = avs_invoke(env, "ConvertToYV12", args, 0); AVS_Clip * clip = avs_take_clip(res, env); avs_release_value(res); const AVS_VideoInfo * inf = avs_get_video_info(clip); FILE * out = fopen("y:\\res.yuv", "wb"); int out_fn = fileno(out); fputs("YUV4MPEG2 ", out); fprintf(out, "W%d ", inf->width); fprintf(out, "H%d ", inf->height); fprintf(out, "F%d:%d ", inf->fps_numerator, inf->fps_denominator); fputs("\n", out); fflush(out); for (int i = 0; i != inf->num_frames; ++i) { fprintf(stderr, "FRAME %d\n", i); fflush(stderr); AVS_VideoFrame * f = avs_get_frame(clip, i); write(out_fn, "FRAME \n", 7); const byte * d = avs_get_read_ptr(f); int pitch = avs_get_pitch(f); for (int y = 0; y != inf->height; ++y, d += pitch) write(out_fn, d, inf->width); d = avs_get_read_ptr_p(f, AVS_PLANAR_U); pitch = avs_get_pitch_p(f, AVS_PLANAR_U); for (int y = 0; y != inf->height/2; ++y, d += pitch) write(out_fn, d, inf->width/2); d = avs_get_read_ptr_p(f, AVS_PLANAR_V); pitch = avs_get_pitch_p(f, AVS_PLANAR_V); for (int y = 0; y != inf->height/2; ++y, d += pitch) write(out_fn, d, inf->width/2); avs_release_frame(f); } fclose(out); return 0; }
LIBRARY avisynth_c.dll EXPORTS avs_invoke @0 avs_take_clip @0 avs_release_value @0 avs_get_video_info @0 avs_get_frame @0 avs_create_script_environment @0 avs_release_video_frame @0