/** \fn runOne \brief Run one job */ void jobsWindow::RunOne(bool b) { int sel = ui.tableWidget->currentRow(); printf("Selected %d\n", sel); if(sel >= 0 && sel < _nbJobs) { if(desc[sel].status == STATUS_SUCCEED) GUI_Info_HIG(ADM_LOG_INFO,QT_TR_NOOP("Already done"),QT_TR_NOOP("This script has already been successfully executed.")); else { desc[sel].status=STATUS_RUNNING; updateRows(); GUI_Quiet(); TLK_getDate(&(desc[sel].startDate)); if(parseECMAScript(_jobsName[sel])) desc[sel].status=STATUS_SUCCEED; else desc[sel].status=STATUS_FAILED; TLK_getDate(&(desc[sel].endDate)); updateRows(); GUI_Verbose(); } } }
/* Unpack all frames without displaying them to check for error */ void A_videoCheck( void) { #if 0 uint32_t nb=0; //uint32_t buf[720*576*2]; uint32_t error=0; ADMImage *aImage; DIA_workingBase *work; nb = avifileinfo->nb_frames; work=createWorking(QT_TRANSLATE_NOOP("adm","Checking video")); aImage=new ADMImage(avifileinfo->width,avifileinfo->height); for(uint32_t i=0;i<nb;i++) { work->update(i, nb); if(!work->isAlive()) break; if(!GUI_getFrameContent (aImage,i)) { error ++; printf("Frame %u has error\n",i); } }; delete work; delete aImage; if(error==0) GUI_Info_HIG(ADM_LOG_IMPORTANT,QT_TRANSLATE_NOOP("adm","No error found"), NULL); else { char str[400]; sprintf(str,QT_TRANSLATE_NOOP("adm","Errors found in %u frames"),error); GUI_Info_HIG(ADM_LOG_IMPORTANT,str, NULL); } GUI_GoToFrame(0); #endif }
/** \fn A_openAvi \brief Open (replace mode) a video */ int A_openAvi (const char *name) { uint8_t res; char *longname; uint32_t magic[4]; uint32_t id = 0; if (playing) return 0; /// check if name exists FILE *fd; fd = ADM_fopen(name, "rb"); if (!fd) { if (errno == EACCES) { GUI_Error_HIG(QT_TRANSLATE_NOOP("adm", "Permission error"), QT_TRANSLATE_NOOP("adm", "Cannot open \"%s\"."), name); } if (errno == ENOENT) { GUI_Error_HIG(QT_TRANSLATE_NOOP("adm", "File error"), QT_TRANSLATE_NOOP("adm", "\"%s\" does not exist."), name); } return 0; } if (4 == fread(magic, 4, 4, fd)) id = R32(magic[0]); fclose(fd); GUI_close(); // Cleanup // DIA_StartBusy (); /* ** we may get a relative path by cmdline */ longname = ADM_PathCanonize(name); // check if avisynth input is given if (fourCC::check(id, (uint8_t *) "ADAP")) res = video_body->addFile(AVS_PROXY_DUMMY_FILE); else res = video_body->addFile(longname); // DIA_StopBusy (); // forget last project file video_body->setProjectName(""); if (res != ADM_OK) // an error occured { delete[] longname; if (ADM_IGN == res) { return 0; } if (fourCC::check(id, (uint8_t *) "//AD")) { GUI_Error_HIG(QT_TRANSLATE_NOOP("adm", "Cannot open project using the video loader."), QT_TRANSLATE_NOOP("adm", "Try 'File' -> 'Load/Run Project...'")); } else { GUI_Error_HIG(QT_TRANSLATE_NOOP("adm", "Could not open the file"), NULL); } return 0; } { int i; FILE *fd = NULL; char magic[4]; /* check myself it is a project file (transparent detected and read ** by video_body->addFile (name); */ //#warning FIXME #if 0 if ((fd = ADM_fopen(longname, "rb"))) { if (fread(magic, 4, 1, fd) == 4) { /* remember a workbench file */ if (!strncmp(magic, "ADMW", 4)) { actual_workbench_file = ADM_strdup(longname); } } fclose(fd); } #endif /* remember any video or workbench file to "recent" */ prefs->set_lastfile(longname); UI_updateRecentMenu(); updateLoaded(); if (currentaudiostream) { uint32_t nbAudio; audioInfo *infos = NULL; if (video_body->getAudioStreamsInfo(admPreview::getCurrentPts() + 1, &nbAudio, &infos)) { if (nbAudio > 1) { // Multiple track warn user GUI_Info_HIG(ADM_LOG_INFO, QT_TRANSLATE_NOOP("adm", "Multiple Audio Tracks"), QT_TRANSLATE_NOOP("adm", "The file you just loaded contains several audio tracks.\n" "Go to Audio->MainTrack to select the active one.")); } } if (infos) delete [] infos; // Revert mixer to copy //setCurrentMixerFromString("NONE"); EditableAudioTrack *ed = video_body->getDefaultEditableAudioTrack(); if (ed) ed->audioEncodingConfig.audioFilterSetMixer(CHANNEL_INVALID); } for (i = strlen(longname); i >= 0; i--) { #ifdef _WIN32 if (longname[i] == '\\' || longname[i] == '/') #else if (longname[i] == '/') #endif { i++; break; } } UI_setTitle(longname + i); } delete[] longname; return 1; }
uint8_t flvHeader::open(char *name) { uint32_t prevLen, type, size, pts,pos=0; _isvideopresent=0; _isaudiopresent=0; audioTrack=NULL; videoTrack=NULL; _filename=ADM_strdup(name); _fd=fopen(name,"rb"); if(!_fd) { printf("[FLV] Cannot open %s\n",name); return 0; } // Get size uint32_t fileSize=0; fseeko(_fd,0,SEEK_END); fileSize=ftello(_fd); fseeko(_fd,0,SEEK_SET); printf("[FLV] file size :%u bytes\n",fileSize); // It must begin by F L V 01 uint8_t four[4]; read(4,four); if(four[0]!='F' || four[1]!='L' || four[2]!='V') { printf("[FLV] Not a flv file %s\n",name); return 0; } // Next one is flags uint32_t flags=read8(); if(flags & 1) // VIDEO { _isvideopresent=1; printf("[FLV] Video flag\n"); }else { GUI_Info_HIG(ADM_LOG_INFO,"Warning","This FLV file says it has no video.\nI will assume it has and try to continue"); _isvideopresent=1; } if(flags & 4) // Audio { _isaudiopresent=1; printf("[FLV] Audio flag\n"); } // Skip header uint32_t skip=read32(); fseeko(_fd,skip,SEEK_SET); printf("[FLV] Skipping %u header bytes\n",skip); pos=ftello(_fd);; printf("pos:%u/%u\n",pos,fileSize); // Create our video index videoTrack=new flvTrak(50); if(_isaudiopresent) audioTrack=new flvTrak(50); else audioTrack=NULL; // Loop while(pos<fileSize-14) { pos=ftello(_fd); prevLen=read32(); type=read8(); size=read24(); pts=read24(); read32(); // ??? uint32_t remaining=size; //printf("[FLV] At %08x found type %x size %u pts%u\n",pos,type,size,pts); switch(type) { case FLV_TAG_TYPE_AUDIO: { if(!_isaudiopresent) { audioTrack=new flvTrak(50); _isaudiopresent=1; /* Damn lying headers...*/ }; uint8_t flags=read8(); int of=1+4+3+3+1+4; remaining--; int format=flags>>4; int fq=(flags>>2)&3; int bps=(flags>>1) & 1; int channel=(flags) & 1; if(!audioTrack->_nbIndex) // first frame.. { setAudioHeader(format,fq,bps,channel); } insertAudio(pos+of,remaining,pts); } break; case FLV_TAG_TYPE_VIDEO: { int of=1+4+3+3+1+4; uint8_t flags=read8(); remaining--; int frameType=flags>>4; int codec=(flags)&0xf; if(codec==FLV_CODECID_VP6) { read8(); // 1 byte of extraData remaining--; of++; } int first=0; if(!videoTrack->_nbIndex) first=1; insertVideo(pos+of,remaining,frameType,pts); if(first) // first frame.. { if(!setVideoHeader(codec,&remaining)) return 0; } } break; default: printf("[FLV]At 0x%x, unhandled type %u\n",pos,type); } Skip(remaining); } // while // Udpate frame count etc.. printf("[FLV] Found %u frames\n",videoTrack->_nbIndex); _videostream.dwLength= _mainaviheader.dwTotalFrames=videoTrack->_nbIndex; // Compute average fps float f=_videostream.dwLength; uint32_t duration=videoTrack->_index[videoTrack->_nbIndex-1].timeCode; if(duration) f=1000.*1000.*f/duration; else f=25000; _videostream.dwRate=(uint32_t)floor(f); _videostream.dwScale=1000; _mainaviheader.dwMicroSecPerFrame=ADM_UsecFromFps1000(_videostream.dwRate); printf("[FLV] Duration %u ms\n",videoTrack->_index[videoTrack->_nbIndex-1].timeCode); // _videostream.fccType=fourCC::get((uint8_t *)"vids"); _video_bih.biBitCount=24; _videostream.dwInitialFrames= 0; _videostream.dwStart= 0; videoTrack->_index[0].flags=AVI_KEY_FRAME; // audio track _audioStream=new flvAudio(name,audioTrack,&wavHeader); printf("[FLV]FLV successfully read\n"); return 1; }