From c0251c4aa0754d808fdf454534b32de8175b6fa0 Mon Sep 17 00:00:00 2001 From: Good Guy Date: Thu, 8 Jul 2021 19:30:13 -0600 Subject: [PATCH] Andrew has fixed Export EDL for CMX3600 output --- cinelerra-5.1/cinelerra/exportedl.C | 78 ++++++++++++++++++++++--- cinelerra-5.1/cinelerra/mainmenu.C | 2 +- cinelerra-5.1/cinelerra/pluginfclient.C | 3 +- 3 files changed, 72 insertions(+), 11 deletions(-) diff --git a/cinelerra-5.1/cinelerra/exportedl.C b/cinelerra-5.1/cinelerra/exportedl.C index f4e3805c..d4d670eb 100644 --- a/cinelerra-5.1/cinelerra/exportedl.C +++ b/cinelerra-5.1/cinelerra/exportedl.C @@ -65,7 +65,7 @@ void ExportEDLAsset::double_to_CMX3600(double seconds, double frame_rate, char * TIME_HMSF, 0, // sample_rate ... unnecessary frame_rate, - 0); // frames per foot + 0); // frames per foot if ((int)(seconds / 3600) <= 9) { str[0]='0'; @@ -92,18 +92,25 @@ int ExportEDLAsset::edit_to_timecodes(Edit *edit, double edit_sourceend; double edit_deststart; double edit_destend; - + double timecode_offset; + + // timecode_offset in seconds + timecode_offset = edit->track->edl->session->timecode_offset; + //printf("tc offset %f, \n", timecode_offset); + + + if(!strcmp(reel_name,"")) strcpy(reel_name, " BL "); - edit_sourcestart = 0; - edit_sourceend = track->from_units(edit->length); - + edit_sourcestart = track->from_units(edit->startsource); + edit_sourceend = track->from_units(edit->length + edit->startsource); + edit_deststart = track->from_units(edit->startproject); edit_destend = track->from_units(edit->startproject + edit->length); double_to_CMX3600(edit_sourcestart, frame_rate, sourceinpoint); double_to_CMX3600(edit_sourceend, frame_rate, sourceoutpoint); - double_to_CMX3600(edit_deststart, frame_rate, destinpoint); - double_to_CMX3600(edit_destend, frame_rate, destoutpoint); + double_to_CMX3600(edit_deststart + timecode_offset, frame_rate, destinpoint); + double_to_CMX3600(edit_destend + timecode_offset, frame_rate, destoutpoint); return 0; } @@ -138,8 +145,32 @@ void ExportEDLAsset::export_it() { // TODO: Find docs about exact header for CMX3600 - fprintf(fh, "TITLE: Cinproj FORMAT: CMX 3600 4-Ch\n"); - + // https://xmil.biz/EDL-X/CMX3600.pdf + double frame_rate = edl->session->frame_rate; + int frame_rate_int = (int)frame_rate; + char proj_title[BCTEXTLEN]; + strcpy(proj_title,basename(mwindow->session->filename)); + fprintf(fh, "TITLE: %s fps: %f\n", proj_title, frame_rate); + switch(frame_rate_int) { + case 24: + case 25: + case 50: + case 60: + case 30: + { + if (frame_rate - frame_rate_int < 0.001) + fprintf(fh, "FCM: NON-DROP FRAME\n"); // fixme: select depending on fps + break; + } + default: + { + if ((frame_rate - frame_rate_int) > 0.001) + fprintf(fh, "FCM: DROP FRAME\n"); + } + } + // newline after FCM + fprintf(fh, "\n"); + int colnum = 1; @@ -147,6 +178,11 @@ void ExportEDLAsset::export_it() edit; edit = edit->next) { + + // max number of entries in cmx3600 + if (colnum > 999) + return; + char reel_name[BCTEXTLEN]; char avselect[5]; char edittype[5] = "C "; @@ -155,6 +191,16 @@ void ExportEDLAsset::export_it() char sourceoutpoint[12]; char destinpoint[12]; char destoutpoint[12]; + + char filename[1024]; + if (edit->asset) + strcpy(filename,basename(edit->asset->path)); + + if(!edit->asset) + strcpy(reel_name,"BL "); + else + strcpy(reel_name,"AX "); + if (track->data_type == TRACK_AUDIO) strcpy(avselect, "A "); else @@ -174,6 +220,8 @@ void ExportEDLAsset::export_it() fprintf(fh, " %s %s", last_sourceout, last_sourceout); fprintf(fh, " %s %s", destinpoint, destinpoint); fprintf(fh,"\n"); + if(edit->asset) + fprintf(fh,"* FROM CLIP NAME: %s\n", filename); } else { colnum --; @@ -183,6 +231,8 @@ void ExportEDLAsset::export_it() fprintf(fh, " %s %s", sourceinpoint, sourceoutpoint); fprintf(fh, " %s %s", destinpoint, destoutpoint); fprintf(fh,"\n"); + if(edit->asset) + fprintf(fh,"* FROM CLIP NAME: %s\n", filename); last_dissolve = 1; } else { @@ -191,12 +241,22 @@ void ExportEDLAsset::export_it() fprintf(fh, " %s %s", sourceinpoint, sourceoutpoint); fprintf(fh, " %s %s", destinpoint, destoutpoint); fprintf(fh,"\n"); + if(edit->asset) + fprintf(fh,"* FROM CLIP NAME: %s\n", filename); last_dissolve = 0; } colnum ++; } + + fprintf(fh, "\n"); + + // file end for final cut pro 1.2.5 ? + fprintf(fh, "\x0D"); + fprintf(fh, "\x0A"); + fprintf(fh, "\x1A"); + fprintf(fh, "\x1A"); } diff --git a/cinelerra-5.1/cinelerra/mainmenu.C b/cinelerra-5.1/cinelerra/mainmenu.C index 60d72d5a..e2902b3b 100644 --- a/cinelerra-5.1/cinelerra/mainmenu.C +++ b/cinelerra-5.1/cinelerra/mainmenu.C @@ -134,7 +134,7 @@ void MainMenu::create_objects() filemenu->add_item(new SubttlSWin(mwindow)); filemenu->add_item(render = new RenderItem(mwindow)); -// filemenu->add_item(new ExportEDLItem(mwindow)); + filemenu->add_item(new ExportEDLItem(mwindow)); filemenu->add_item(new BatchRenderMenuItem(mwindow)); filemenu->add_item(new CreateBD_MenuItem(mwindow)); filemenu->add_item(new CreateDVD_MenuItem(mwindow)); diff --git a/cinelerra-5.1/cinelerra/pluginfclient.C b/cinelerra-5.1/cinelerra/pluginfclient.C index a0756e73..f4d9ba3a 100644 --- a/cinelerra-5.1/cinelerra/pluginfclient.C +++ b/cinelerra-5.1/cinelerra/pluginfclient.C @@ -845,7 +845,8 @@ static AVRational best_frame_rate(double frame_rate) static const int m1 = 1001*12, m2 = 1000*12; static const int freqs[] = { 40*m1, 48*m1, 50*m1, 60*m1, 80*m1,120*m1, 240*m1, - 24*m2, 30*m2, 60*m2, 12*m2, 15*m2, 48*m2, 0, + 24*m2, 30*m2, 60*m2, 12*m2, 15*m2, 48*m2, 90*m2, + 100*m2, 120*m2, 144*m2, 72*m2, 0, }; double max_err = 1.; int freq, best_freq = 0; -- 2.26.2