diff options
| author | Tim Redfern <tim@eclectronics.org> | 2014-02-17 13:36:38 +0000 |
|---|---|---|
| committer | Tim Redfern <tim@eclectronics.org> | 2014-02-17 13:36:38 +0000 |
| commit | 22e28216336da876e1fd17f380ce42eaf1446769 (patch) | |
| tree | 444dad3dc7e2656992d29f34f7bce31970c122a5 /rotord | |
| parent | ae5e8541f6e06e64c28719467cdf366ac57aff31 (diff) | |
chasing indexing error
Diffstat (limited to 'rotord')
| -rwxr-xr-x | rotord/make_proxies | 4 | ||||
| -rwxr-xr-x | rotord/make_test_ffms2 | 1 | ||||
| -rw-r--r-- | rotord/src/libavwrapper.cpp | 4 | ||||
| -rw-r--r-- | rotord/src/rotor.h | 8 | ||||
| -rw-r--r-- | rotord/test_ffms2.c | 117 |
5 files changed, 126 insertions, 8 deletions
diff --git a/rotord/make_proxies b/rotord/make_proxies index 9bf433d..50b3e20 100755 --- a/rotord/make_proxies +++ b/rotord/make_proxies @@ -17,6 +17,6 @@ do #echo "suffix: $suffix" #echo "stub: $stub" ffmpeg -i "$source" -s 1280x720 "$path/$stub.proxies/720$suffix" - ffmpeg -i "$path/$stub.proxies/720$suffix" -s 640x360 "$path/$stub.proxies/360$suffix"; - ffmpeg -i "$path/$stub.proxies/360$suffix" -s 320x180 "$path/$stub.proxies/180$suffix"; + ffmpeg -i "$path/$stub.proxies/720$suffix" -s 640x360 "$path/$stub.proxies/360$suffix" + ffmpeg -i "$path/$stub.proxies/360$suffix" -s 320x180 "$path/$stub.proxies/180$suffix" done
\ No newline at end of file diff --git a/rotord/make_test_ffms2 b/rotord/make_test_ffms2 new file mode 100755 index 0000000..ad9e0f2 --- /dev/null +++ b/rotord/make_test_ffms2 @@ -0,0 +1 @@ +gcc test_ffms2.c -lffms2 -o test diff --git a/rotord/src/libavwrapper.cpp b/rotord/src/libavwrapper.cpp index 4a8315f..6c17537 100644 --- a/rotord/src/libavwrapper.cpp +++ b/rotord/src/libavwrapper.cpp @@ -70,11 +70,11 @@ bool libav::video_decoder::open(const std::string& filename){ FFMS_WriteIndex(idxfile.c_str(),index,&err); cerr<<"FFMS2: created index "<<idxfile<<endl; } - cerr<<"FFMS2: "<<filename<<" cannot be indexed "<<endl; + else cerr<<"FFMS2: "<<filename<<" cannot be indexed "<<endl; } if (index == NULL) { std::cerr<<"ffmpegsource: "<<err.Buffer<<std::endl; - return false; + return false; //temp removal 170214 causes core dump } int trackno = FFMS_GetFirstTrackOfType(index, FFMS_TYPE_VIDEO, &err); if (trackno < 0) { diff --git a/rotord/src/rotor.h b/rotord/src/rotor.h index 0053146..08d8734 100644 --- a/rotord/src/rotor.h +++ b/rotord/src/rotor.h @@ -796,7 +796,7 @@ namespace Rotor { if (h>0&&h<721){ Poco::Path path(filename); std::string stub(path.getBaseName()+".proxies/"); - std::string suffix="mp4"; //(path.getExtension()); + std::string suffix="mp4"; //(path.getExtension()); -always have to use mp4 incase of file with no suffix std::string pathto="/"; for (int i=0;i<path.depth();i++){ pathto=pathto+path[i]+"/"; @@ -854,8 +854,8 @@ namespace Rotor { Poco::Logger& logger = Poco::Logger::get(Log_name); logger.error("Video_loader failed to seek frame "+toString(wanted)+" of "+attributes["filename"]->value); - if (image.w>0) return ℑ //just return the previous frame if possible - else return nullptr; + if (image.w>0) return true; //just return the previous frame if possible + else return false; } image.setup_fromRGB(frame.w,frame.h,player.frame->Data[0],player.frame->Linesize[0]-(frame.w*3)); } @@ -930,7 +930,7 @@ namespace Rotor { if (!isLoaded&&isLoadable){ isLoaded=load(media_path+attributes["filename"]->value,frame.h); } - Base_video::output(frame); + return Base_video::output(frame); } //void init_attribute(const string &attr){ // if (attr=="filename") { diff --git a/rotord/test_ffms2.c b/rotord/test_ffms2.c new file mode 100644 index 0000000..1b30b04 --- /dev/null +++ b/rotord/test_ffms2.c @@ -0,0 +1,117 @@ +#include <ffms.h> +#include <stdio.h> +#ifdef _WIN32 +#include <objbase.h> +#endif + + + +int main (int argc, char *argv[]) { + + if(argc<2){ + printf("Error: USAGE - test filename\n"); + return 0; + } + /* If you are on Windows you should first initialize COM, or all MPEG-TS/PS and OGM + files may return an error when you try to open them (if the library was built + with HAALISOURCE defined). All other formats will work normally. */ +#ifdef _WIN32 + bool com_inited = false; + HRESULT res = CoInitializeEx(NULL, COINIT_MULTITHREADED); + if (SUCCEEDED(res)) + com_inited = true; + else if (res != RPC_E_CHANGED_MODE) { + /* com initialization failed, handle error */ + } +#endif + + /* Initialize the library itself. + The cpu caps are autodetected almost all places nowadays. Passing 0 should have close to no performance + impact with a recent FFmpeg. If you want you can pass something like + FFMS_CPU_CAPS_MMX | FFMS_CPU_CAPS_MMX2. */ + FFMS_Init(0, 0); + + /* Index the source file. Note that this example does not index any audio tracks. */ + char errmsg[1024]; + FFMS_ErrorInfo errinfo; + errinfo.Buffer = errmsg; + errinfo.BufferSize = sizeof(errmsg); + errinfo.ErrorType = FFMS_ERROR_SUCCESS; + errinfo.SubType = FFMS_ERROR_SUCCESS; + const char *sourcefile = argv[1]; + FFMS_Index *index = FFMS_MakeIndex(sourcefile, 0, 0, NULL, NULL, FFMS_IEH_STOP_TRACK, NULL, NULL, &errinfo); + if (index == NULL) { + /* handle error (print errinfo.Buffer somewhere) */ + printf("Error: cannot index %s\n",sourcefile); + return 0; + } + + /* Retrieve the track number of the first video track */ + int trackno = FFMS_GetFirstTrackOfType(index, FFMS_TYPE_VIDEO, &errinfo); + if (trackno < 0) { + /* no video tracks found in the file, this is bad and you should handle it */ + /* (print the errmsg somewhere) */ + } + + /* We now have enough information to create the video source object */ + FFMS_VideoSource *videosource = FFMS_CreateVideoSource(sourcefile, trackno, index, 1, FFMS_SEEK_NORMAL, &errinfo); + if (videosource == NULL) { + /* handle error (you should know what to do by now) */ + } + + /* Since the index is copied into the video source object upon its creation, + we can and should now destroy the index object. */ + FFMS_DestroyIndex(index); + + /* Retrieve video properties so we know what we're getting. + As the lack of the errmsg parameter indicates, this function cannot fail. */ + const FFMS_VideoProperties *videoprops = FFMS_GetVideoProperties(videosource); + + /* Now you may want to do something with the info, like check how many frames the video has */ + int num_frames = videoprops->NumFrames; + + /* Get the first frame for examination so we know what we're getting. This is required + because resolution and colorspace is a per frame property and NOT global for the video. */ + const FFMS_Frame *propframe = FFMS_GetFrame(videosource, 0, &errinfo); + + /* Now you may want to do something with the info; particularly interesting values are: + propframe->EncodedWidth; (frame width in pixels) + propframe->EncodedHeight; (frame height in pixels) + propframe->EncodedPixelFormat; (actual frame colorspace) + */ + + /* If you want to change the output colorspace or resize the output frame size, + now is the time to do it. IMPORTANT: This step is also required to prevent + resolution and colorspace changes midstream. You can you can always tell a frame's + original properties by examining the Encoded* properties in FFMS_Frame. */ + /* See libavutil/pixfmt.h for the list of pixel formats/colorspaces. + To get the name of a given pixel format, strip the leading PIX_FMT_ + and convert to lowercase. For example, PIX_FMT_YUV420P becomes "yuv420p". */ + + /* A -1 terminated list of the acceptable output formats. */ + int pixfmts[2]; + pixfmts[0] = FFMS_GetPixFmt("bgra"); + pixfmts[1] = -1; + + if (FFMS_SetOutputFormatV2(videosource, pixfmts, propframe->EncodedWidth, propframe->EncodedHeight, FFMS_RESIZER_BICUBIC, &errinfo)) { + /* handle error */ + } + + /* now we're ready to actually retrieve the video frames */ + int framenumber = 0; /* valid until next call to FFMS_GetFrame* on the same video object */ + const FFMS_Frame *curframe = FFMS_GetFrame(videosource, framenumber, &errinfo); + if (curframe == NULL) { + /* handle error */ + } + /* do something with curframe */ + /* continue doing this until you're bored, or something */ + + /* now it's time to clean up */ + FFMS_DestroyVideoSource(videosource); +#ifdef _WIN32 + if (com_inited) + CoUninitialize(); +#endif + + return 0; +}
\ No newline at end of file |
