void UI_setTimeCount(uint32_t curFrame,uint32_t total, uint32_t fps)
{
  char text[80];   
 uint16_t mm,hh,ss,ms;
 
 	frame2time(curFrame,fps, &hh, &mm, &ss, &ms);
  	sprintf(text, "%02d:%02d:%02d.%03d", hh, mm, ss, ms);
     	//gtk_label_set_text((GtkLabel *) guiCurTime, text);
     	gtk_write_entry_string(guiCurTime,text);
     
 	frame2time(total,fps, &hh, &mm, &ss, &ms);
  	sprintf(text, "%02d:%02d:%02d.%03d", hh, mm, ss, ms);
     	gtk_label_set_text((GtkLabel *) guiTotalTime, text);     
     

}
Exemplo n.º 2
0
/**
 * 
 * @param p
 */
void show_info(char *p)
{
   UNUSED_ARG(p);
   uint32_t war,har;
   const char *s;

   if (avifileinfo)
    {

   printf("Video\n");
   printf("   Video Size: %u x %u\n", avifileinfo->width, avifileinfo->height);
   printf("   Frame Rate: %2.3f fps\n", (float)avifileinfo->fps1000/1000.F);
   printf("   Number of frames: %d frames\n", avifileinfo->nb_frames);
   printf("   Codec FourCC: %s\n", fourCC::tostring(avifileinfo->fcc));
   if(avifileinfo->nb_frames){
     uint32_t hh, mm, ss, ms;
      frame2time(avifileinfo->nb_frames, avifileinfo->fps1000,&hh, &mm, &ss, &ms);
      printf("   Duration: %02d:%02d:%02d.%03d\n", hh, mm, ss, ms);
   }else{
      printf("   Duration: 00:00:00.000\n");
   }
   war=video_body->getPARWidth();
   har=video_body->getPARHeight();
   getAspectRatioFromAR(war,har, &s);
   printf("   Aspect Ratio: %s (%u:%u)\n", s,war,har);

   printf("Audio\n");
   ADM_audioStream *s;
   WAVHeader *wavinfo=NULL;
   video_body->getDefaultAudioTrack(&s);
   if(s )
   {
        wavinfo=s->getInfo();
    }
   if( wavinfo )
    {
      printf("   Codec: %s\n",getStrFromAudioCodec(wavinfo->encoding));
      printf("   Mode: ");
      switch( wavinfo->channels ){
         case 1:  printf("MONO\n"); break;
         case 2:  printf("STEREO\n"); break;
         default: printf("????\n"); break;
      }
      printf("   BitRate: %u Bps / %u kbps\n", wavinfo->byterate, wavinfo->byterate*8/1000);
      printf("   Frequency: %u Hz\n", wavinfo->frequency);
   }else{
      printf("   Codec: NONE\n");
      printf("   Mode: NONE\n");
      printf("   BitRate: NONE\n");
      printf("   Frequency: NONE\n");
      printf("   Duration: NONE\n");
    }
   }
   else
   {
       printf("Nothing to get infos from\n");
   }
}
//******************************************
// Compute the value that will not change
// (duration)
// and init the entries for current bitrate
//******************************************
void prepare( void )
{

	float duration=0;
	aviInfo info;
	char string[200];
	 uint16_t mm,hh,ss,ms;
	 AVDMProcessAudioStream *stream;
	 
	 if(frameStart<frameEnd) numberOfVideoFrames=frameEnd-frameStart;
	 else			 numberOfVideoFrames=frameStart-frameEnd;
 
 	
	
	duration=(float)video_body->getTime (numberOfVideoFrames);
	duration=duration/1000.;
	
	if(duration<0) duration=-duration;
	
	video_body->getVideoInfo(&info);
	
	videoDuration=(uint32_t)ceil(duration);
	frame2time(numberOfVideoFrames,info.fps1000, &hh, &mm, &ss, &ms);
	// now we can set it
	sprintf(string,"%02d:%02d:%02d",hh,mm,ss);
	gtk_label_set_text(GTK_LABEL(WID(labelDuration)),string);
	
	printf("Video duration :%lu\n",videoDuration);

	// Now get audio info
	track1=0;
	if(audioProcessMode() && currentaudiostream)
	{
		stream=buildFakeAudioFilter(currentaudiostream,
				0, 0xffffffff);
	
		if(stream)
		{
			track1=(stream->getInfo()->byterate*8)/1000;
		}
		deleteAudioFilter();
	}else
	{
		if(currentaudiostream) track1=(currentaudiostream->getInfo()->byterate*8)/1000;
	}
	
	track2=0;
	gtk_write_entry(WID(entry3), track1);
	gtk_write_entry(WID(entry4), track2);
	
	printf("Track1 bitrate :%lu\n",track1);
	printf("Track2 bitrate :%lu\n",track2);

	
	
}
Exemplo n.º 4
0
//******************************************
// Compute the value that will not change
// (duration)
// and init the entries for current bitrate
//******************************************
void prepare( void )
{
#if 0
	float duration=0;
	aviInfo info;
	char string[200];
	 uint16_t mm,hh,ss,ms;
         AVDMGenericAudioStream *stream;

	 if(frameStart<frameEnd) numberOfVideoFrames=frameEnd-frameStart;
	 else			 numberOfVideoFrames=frameStart-frameEnd;



	duration=(float)video_body->getTime (numberOfVideoFrames);
	duration=duration/1000.;

	if(duration<0) duration=-duration;

	video_body->getVideoInfo(&info);

	videoDuration=(uint32_t)ceil(duration);
	frame2time(numberOfVideoFrames,info.fps1000, &hh, &mm, &ss, &ms);
	// now we can set it
	sprintf(string,"%02d:%02d:%02d",hh,mm,ss);
	gtk_label_set_text(GTK_LABEL(GW(labelDuration),string);

	printf("Video duration :%lu\n",videoDuration);

	// Now get audio info
	track1=0;
	if(audioProcessMode() && currentaudiostream)
	{
//		stream=buildAudioFilter(currentaudiostream,0);

		if(stream)
		{
			track1=(stream->getInfo()->byterate*8)/1000;
		}
//                deleteAudioFilter(stream);
	}else
	{
		if(currentaudiostream) track1=(currentaudiostream->getInfo()->byterate*8)/1000;
	}

	track2=0;
	gtk_spin_button_set_value(GTK_SPIN_BUTTON(GW(spinbuttonTrack1)), track1);
	gtk_spin_button_set_value(GTK_SPIN_BUTTON(GW(spinbuttonTrack2)), track2);

	printf("Track1 bitrate :%lu\n",track1);
	printf("Track2 bitrate :%lu\n",track2);

#endif

}
Exemplo n.º 5
0
void show_info(char *p){
   UNUSED_ARG(p);
   uint32_t war,har;
   const char *s;
   
   if (avifileinfo)
    {
		
   printf("Video\n");
   printf("   Video Size: %u x %u\n", avifileinfo->width, avifileinfo->height);
   printf("   Frame Rate: %2.3f fps\n", (float)avifileinfo->fps1000/1000.F);
   printf("   Number of frames: %d frames\n", avifileinfo->nb_frames);
   printf("   Codec FourCC: %s\n", fourCC::tostring(avifileinfo->fcc));
   if(avifileinfo->nb_frames){
     uint16_t hh, mm, ss, ms;
      frame2time(avifileinfo->nb_frames, avifileinfo->fps1000,&hh, &mm, &ss, &ms);
      printf("   Duration: %02d:%02d:%02d.%03d\n", hh, mm, ss, ms);
   }else{
      printf("   Duration: 00:00:00.000\n");
   }
   war=video_body->getPARWidth();
   har=video_body->getPARHeight();
   getAspectRatioFromAR(war,har, &s);
   printf("   Aspect Ratio: %s (%u:%u)\n", s,war,har);

   printf("Audio\n");
   if( wavinfo )
    {
      printf("   Codec: %s\n",getStrFromAudioCodec(wavinfo->encoding));     
      printf("   Mode: ");
      switch( wavinfo->channels ){
         case 1:  printf("MONO\n"); break;
         case 2:  printf("STEREO\n"); break;
         default: printf("????\n"); break;
      }
      printf("   BitRate: %u Bps / %u kbps\n", wavinfo->byterate, wavinfo->byterate*8/1000);
      printf("   Frequency: %u Hz\n", wavinfo->frequency);
      { double du = video_body->getAudioLength();
        uint16_t hh, mm, ss, ms;
         du*=1000;
         du/=wavinfo->byterate;
         ms2time((uint32_t)floor(du), &hh, &mm, &ss, &ms);
         printf("   Duration: %02d:%02d:%02d.%03d (%lu MBytes)\n", hh, mm, ss, ms, video_body->getAudioLength()>>20);
      }
   }else{
      printf("   Codec: NONE\n");
      printf("   Mode: NONE\n");
      printf("   BitRate: NONE\n");
      printf("   Frequency: NONE\n");
      printf("   Duration: NONE\n");
    }
   }
Exemplo n.º 6
0
calculatorDialog::calculatorDialog(QWidget* parent) : QDialog(parent)
{
    ui.setupUi(this);

    connect(ui.formatComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(comboBox_currentIndexChanged(int)));
    connect(ui.mediumComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(mediumComboBox_currentIndexChanged(int)));
    connect(ui.customSizeSpinBox, SIGNAL(valueChanged(int)), this, SLOT(spinBox_valueChanged(int)));
    connect(ui.audioTrack1SpinBox, SIGNAL(valueChanged(int)), this, SLOT(spinBox_valueChanged(int)));
    connect(ui.audioTrack2SpinBox, SIGNAL(valueChanged(int)), this, SLOT(spinBox_valueChanged(int)));

    float duration = 0;
    aviInfo info;
    uint16_t mm, hh, ss, ms;
    unsigned int track1 = 0;

    if (frameStart < frameEnd)
        _videoFrameCount = frameEnd - frameStart;
    else
        _videoFrameCount = frameStart - frameEnd;

    duration = ((float)video_body->getTime(_videoFrameCount) / 1000.);

    if (duration < 0)
        duration = -duration;

    _videoDuration = (uint32_t)ceil(duration);

    video_body->getVideoInfo(&info);
    frame2time(_videoFrameCount, info.fps1000, &hh, &mm, &ss, &ms);

    ui.durationLabel->setText(QString("%1:%2:%3").arg(hh, 2, 10, QLatin1Char('0')).arg(mm, 2, 10, QLatin1Char('0')).arg(ss, 2, 10, QLatin1Char('0')));

    if (audioProcessMode() && currentaudiostream)
    {
        AVDMGenericAudioStream *stream ; //= buildAudioFilter(currentaudiostream, 0);

        if (stream)
            track1 = (stream->getInfo()->byterate * 8) / 1000;

//		deleteAudioFilter(stream);
    }
    else if(currentaudiostream)
        track1 = (currentaudiostream->getInfo()->byterate * 8) / 1000;

    ui.audioTrack1SpinBox->setValue(track1);

    update();
}
uint8_t A_ListAllBlackFrames(char *name)
{
// Print a list of all black frames
//_____________________________________________________________
    uint32_t f;
    uint32_t flags;
    uint32_t startframe;
    uint16_t mm,hh,ss,ms;

    uint16_t reresh_count=0;

    char *outfile;
    FILE *fd;

    outfile=name;    

    if ( playing )
        return 0;
    if ( !avifileinfo )
        return 0;

   
    if ( !outfile )
        return 0;
    fd=fopen(outfile, "wb");
    if ( fd == NULL )
    {
        fprintf(stderr, "cannot create output file for list of black frames\n");
        return 0;
    }

    const int darkness=40;

    startframe=curframe;
    DIA_working *work=new DIA_working("Finding black frames");
    printf("\n** Listing all black frames **\n");

    for (f=0; f<avifileinfo->nb_frames; f++) {
       if( work->update( 100 * f / avifileinfo->nb_frames ) ) 
            break;
        if ( !video_body->getUncompressedFrame(f,rdr_decomp_buffer,&flags) ) {
            curframe=0;
            video_body->getUncompressedFrame(0,rdr_decomp_buffer);
            break;
        }

        curframe=f;
        if ( !fastIsNotBlack(darkness) ) {
            frame2time(curframe,avifileinfo->fps1000,&hh,&mm,&ss,&ms);
            printf("\tBlack frame: frame %d  time %02d:%02d:%02d.%03d\n", curframe, hh, mm, ss, ms);
            fprintf(fd, "\tBlack frame: frame %d  time %02d:%02d:%02d.%03d\n", curframe, hh, mm, ss, ms);
        }
        reresh_count++;
        if(reresh_count>100)
        {
                update_status_bar(rdr_decomp_buffer);
                reresh_count=0;
        }
    }

    printf("** done **\n\n");
    fclose(fd);
    delete work;
    curframe=startframe;
    if ( !video_body->getUncompressedFrame(curframe,rdr_decomp_buffer,&flags) ) {
        curframe=0;
        video_body->getUncompressedFrame(0,rdr_decomp_buffer);
    }
    renderUpdateImage(rdr_decomp_buffer->data);
    if ( mode_preview )
        editorUpdatePreview( curframe );
    update_status_bar(rdr_decomp_buffer);

    return 1;
}
/**
    \fn A_ListAllBlackFrames
    \brief Scan for all black frames and output that in a separate (text) file
*/
uint8_t A_ListAllBlackFrames(char *name)
{
    uint32_t f;
    uint32_t flags;
    uint32_t startframe;
    uint16_t mm,hh,ss,ms;

    uint16_t reresh_count=0;

    char *outfile;
    FILE *fd;

    outfile=name;    

    if ( playing )
        return 0;
    if ( !avifileinfo )
        return 0;
   ADMImage *buffer=admPreview::getBuffer();
    if(!buffer) return 0;
   
    if ( !outfile )
        return 0;
    fd=fopen(outfile, "wb");
    if ( fd == NULL )
    {
        fprintf(stderr, "cannot create output file for list of black frames\n");
        return 0;
    }

    const int darkness=40;

    startframe=curframe;
    DIA_working *work=new DIA_working(QT_TR_NOOP("Finding black frames"));
    printf("\n** Listing all black frames **\n");

    for (f=0; f<avifileinfo->nb_frames; f++) {
       if( work->update( 100 * f / avifileinfo->nb_frames ) ) 
            break;
        if ( !video_body->getUncompressedFrame(f,buffer,&flags) ) 
        {
            break;
        }

        curframe=f;
        if ( !fastIsNotBlack(darkness,buffer) ) 
        {
            frame2time(curframe,avifileinfo->fps1000,&hh,&mm,&ss,&ms);
            printf("\tBlack frame: frame %d  time %02d:%02d:%02d.%03d\n", curframe, hh, mm, ss, ms);
            fprintf(fd, "\tBlack frame: frame %d  time %02d:%02d:%02d.%03d\n", curframe, hh, mm, ss, ms);
        }
        reresh_count++;
        if(reresh_count>100)
        {
                update_status_bar();
                reresh_count=0;
        }
    }

    printf("** done **\n\n");
    fclose(fd);
    delete work;
    GUI_GoToFrame(startframe);
    return 1;
}
void DIA_properties( void )
{

 char text[80];
 uint16_t hh, mm, ss, ms;
 GtkWidget *dialog;

    if (playing)
	return;

    text[0] = 0;
    if (!avifileinfo)
	return;

	dialog = create_dialog();
	gtk_transient(dialog);
#define FILL_ENTRY(x) gtk_label_set_text((GtkLabel *) lookup_widget(dialog,#x),text);
	sprintf(text, "%lu x %lu  ", avifileinfo->width,		avifileinfo->height);

	FILL_ENTRY(label_size);

	sprintf(text, "%2.3f fps", (float) avifileinfo->fps1000 / 1000.F);
	FILL_ENTRY(label_fps);
		
	sprintf(text, "%ld frames", avifileinfo->nb_frames);
	FILL_ENTRY(label_number);
		
      	sprintf(text, "%s ",      fourCC::tostring(avifileinfo->fcc));
	FILL_ENTRY(label_videofourcc);

	if (avifileinfo->nb_frames)
	  {
	      	frame2time(avifileinfo->nb_frames, avifileinfo->fps1000,
			 &hh, &mm, &ss, &ms);
	      	sprintf(text, "%02d:%02d:%02d.%03d", hh, mm, ss, ms);
	   	FILL_ENTRY(label_duration);	

	  }
	// Now audio
	if (wavinfo)
	  {
	      switch (wavinfo->channels)
		{
		case 1:
		    sprintf(text, "MONO");
		    break;
		case 2:
		    sprintf(text, "STEREO");
		    break;
		default:
		    sprintf(text, "????");
		    break;
		}
	     	FILL_ENTRY(label1_audiomode);
	     
	      	sprintf(text, "%lu Hz", wavinfo->frequency);
	     	FILL_ENTRY(label_fq);
	     
	      
	      sprintf(text, "%lu Bps / %lu kbps", wavinfo->byterate,      wavinfo->byterate * 8 / 1000);
	      FILL_ENTRY(label_bitrate);
	      
	      switch (wavinfo->encoding)
		{
		case (WAV_MP2):
		    sprintf(text, "MP2 ");
		    break;
		case (WAV_MP3):
		    sprintf(text, "MP3 ");
		    break;
		case (WAV_WMA):
		    sprintf(text, "WMA ");
		    break;
		 case (WAV_LPCM):
		    sprintf(text, "LPCM ");
		    break;
		case (WAV_PCM):
		    sprintf(text, "PCM ");
		    break;
		case (WAV_AC3):
		    sprintf(text, "AC3 ");
		    break;
       		case (WAV_OGG):
       		    sprintf(text,"OGG/VORBIS");
        	    break;
		default:
		    sprintf(text, "?? (0x%2x) ", wavinfo->encoding);
		    break;
		}
	     	FILL_ENTRY(label1_audiofourcc);
		sprintf(text,"%lu MBytes",video_body->getAudioLength()>>20);
		FILL_ENTRY(label_audioduration);
	} else
	  {
void DIA_properties( void )
{

 char text[80];
 uint16_t hh, mm, ss, ms;
 GtkWidget *dialog;
 uint8_t gmc, qpel,vop;
 uint32_t info=0;
 const char *yesno[2]={QT_TR_NOOP("No"),QT_TR_NOOP("Yes")};
 uint32_t war,har;

    if (playing)
        return;
  
    text[0] = 0;
    if (!avifileinfo)
        return;
  
        // Fetch info
        info=video_body->getSpecificMpeg4Info();
        vop=!!(info & ADM_VOP_ON);
        qpel=!!(info & ADM_QPEL_ON);
        gmc=!!(info & ADM_GMC_ON);
        
        dialog = create_dialog1();

        gtk_register_dialog(dialog);

        sprintf(text, QT_TR_NOOP("%lu x %lu"), avifileinfo->width,avifileinfo->height);
        FILL_ENTRY(label_size);

        sprintf(text, QT_TR_NOOP("%2.3f fps"), (float) avifileinfo->fps1000 / 1000.F);
        FILL_ENTRY(label_fps);

        sprintf(text, QT_TR_NOOP("%ld frames"), avifileinfo->nb_frames);
        FILL_ENTRY(label_number);

        sprintf(text, "%s", fourCC::tostring(avifileinfo->fcc));
        FILL_ENTRY(label_videofourcc);

        if (avifileinfo->nb_frames)
          {
                frame2time(avifileinfo->nb_frames, avifileinfo->fps1000,
                          &hh, &mm, &ss, &ms);
                sprintf(text, QT_TR_NOOP("%02d:%02d:%02d.%03d"), hh, mm, ss, ms);
                FILL_ENTRY(label_duration);	
  
          }
        // Fill in vop, gmc & qpel
        SET_YES(labelPacked,vop);
        SET_YES(labelGMC,gmc);
        SET_YES(labelQP,qpel);
        // Aspect ratio 
        const char *s;
        war=video_body->getPARWidth();
        har=video_body->getPARHeight();
        getAspectRatioFromAR(war,har, &s);
        sprintf(text, QT_TR_NOOP("%s (%u:%u)"), s,war,har);
        FILL_ENTRY(labelAspectRatio);	
        // Now audio
        WAVHeader *wavinfo=NULL;
        if (currentaudiostream) wavinfo=currentaudiostream->getInfo();
          if(wavinfo)
          {
              
              switch (wavinfo->channels)
                {
                case 1:
                    sprintf(text, QT_TR_NOOP("Mono"));
                    break;
                case 2:
                    sprintf(text, QT_TR_NOOP("Stereo"));
                    break;
                default:
                    sprintf(text, "%d",wavinfo->channels);
                    break;
                }
                FILL_ENTRY(label1_audiomode);
              
                sprintf(text, QT_TR_NOOP("%lu Hz"), wavinfo->frequency);
                FILL_ENTRY(label_fq);
                sprintf(text, QT_TR_NOOP("%lu Bps / %lu kbps"), wavinfo->byterate,      wavinfo->byterate * 8 / 1000);
                FILL_ENTRY(label_bitrate);
                sprintf(text, "%s", getStrFromAudioCodec(wavinfo->encoding));
                FILL_ENTRY(label1_audiofourcc);
                // Duration in seconds too
                if(currentaudiostream && wavinfo->byterate>1)
                {
                        uint32_t l=currentaudiostream->getLength();
                        double du;
                        du=l;
                        du*=1000;
                        du/=wavinfo->byterate;
                        ms2time((uint32_t)floor(du), &hh, &mm, &ss, &ms);
                        sprintf(text, QT_TR_NOOP("%02d:%02d:%02d.%03d"), hh, mm, ss, ms);
						FILL_ENTRY(label_audioduration);

						sprintf(text, QT_TR_NOOP("%.2f MB"), l / 1048576.F);
						FILL_ENTRY(labelFileSize);
                }                
                SET_YES(labelVbr, currentaudiostream->isVBR());
        } else
          {
			  DISABLE_WIDGET(frame2);
          }
  
        gtk_dialog_run(GTK_DIALOG(dialog));	
        gtk_unregister_dialog(dialog);
        gtk_widget_destroy(dialog);
}