From bbc8b3af4efa5ddefc1ba85cbdda620a0e21bcd3 Mon Sep 17 00:00:00 2001
From: Andrew Randrianasulu <randrianasulu@gmail.com>
Date: Fri, 17 Dec 2021 15:41:24 +0300
Subject: [PATCH 18/24] NOT YET

---
 cinelerra-5.1/cinelerra/bdcreate.C | 12 +++++++++++-
 cinelerra-5.1/cinelerra/bdcreate.h |  3 +++
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/cinelerra-5.1/cinelerra/bdcreate.C b/cinelerra-5.1/cinelerra/bdcreate.C
index 6f4e9675..738026a4 100644
--- a/cinelerra-5.1/cinelerra/bdcreate.C
+++ b/cinelerra-5.1/cinelerra/bdcreate.C
@@ -152,10 +152,15 @@ int BD_BatchRenderJob::get_udfs_mount(char *udfs, char *mopts, char *mntpt)
 	return ret;
 }
 
+
+
 char *BD_BatchRenderJob::create_script(EDL *edl, ArrayList<Indexable *> *idxbls)
 {
 	char script[BCTEXTLEN];
 	strcpy(script, edl_path);
+	
+	int tsmuxer = 1;
+	
 	FILE *fp = 0;
 	char *bp = strrchr(script,'/');
 	int fd = -1;
@@ -183,6 +188,9 @@ char *BD_BatchRenderJob::create_script(EDL *edl, ArrayList<Indexable *> *idxbls)
 	fprintf(fp,"sz=`du -cb $dir/bd.m2ts* | tail -1 | sed -e 's/[ 	].*//'`\n");
 	fprintf(fp,"blks=$((sz/2048 + 4096))\n");
 	fprintf(fp,"rm -f %s\n", udfs);
+	if (tsmuxer) {
+	fprintf(fp,"tsmuxer bd.meta $dir/bd.m2ts \n");
+	} else {
 	fprintf(fp,"mkudffs -b 2048 %s $blks\n", udfs);
 	fprintf(fp,"mount %s%s\n", mopts, mntpt);
 	fprintf(fp,"bdwrite %s $dir/bd.m2ts*\n",mntpt);
@@ -193,7 +201,7 @@ char *BD_BatchRenderJob::create_script(EDL *edl, ArrayList<Indexable *> *idxbls)
 	fprintf(fp,"echo for WORM: growisofs -dvd-compat -Z /dev/bd=$dir/bd.udfs\n");
 	fprintf(fp,"echo for RW:   dd if=$dir/bd.udfs of=/dev/bd bs=2048000\n");
 	fprintf(fp,"kill $$\n");
-	fprintf(fp,"\n");
+	fprintf(fp,"\n"); }
 	fclose(fp);
 	return cstrdup(script);
 }
@@ -226,6 +234,7 @@ CreateBD_Thread::CreateBD_Thread(MWindow *mwindow)
 	this->bd_max_bitrate = BD_MAX_BITRATE;
 	this->bd_kaudio_rate = BD_KAUDIO_RATE;
 	this->max_w = this->max_h = 0;
+	this->batchrender = 0;
 }
 
 CreateBD_Thread::~CreateBD_Thread()
@@ -430,6 +439,7 @@ void CreateBD_Thread::handle_close_event(int result)
 	char asset_dir[BCTEXTLEN], jobs_path[BCTEXTLEN];
 	snprintf(asset_dir, sizeof(asset_dir), "%s/%s", tmp_path, asset_title);
 	snprintf(jobs_path, sizeof(jobs_path), "%s/bd.jobs", asset_dir);
+	//batchrender->tsmuxered = use_tsmuxer;
 	mwindow->batch_render->reset(jobs_path);
 	int ret = create_bd_jobs(&mwindow->batch_render->jobs, asset_dir);
 	mwindow->undo->update_undo_after(_("create bd"), LOAD_ALL);
diff --git a/cinelerra-5.1/cinelerra/bdcreate.h b/cinelerra-5.1/cinelerra/bdcreate.h
index 6744e027..c9bbc5f9 100644
--- a/cinelerra-5.1/cinelerra/bdcreate.h
+++ b/cinelerra-5.1/cinelerra/bdcreate.h
@@ -30,6 +30,7 @@ public:
 	static int get_udfs_mount(char *udfs, char *mopts, char *mntpt);
 	BD_BatchRenderJob(Preferences *preferences, int labeled, int farmed);
 	char *create_script(EDL *edl, ArrayList<Indexable *> *idxbls);
+	int tsmuxered;
 };
 
 
@@ -76,6 +77,8 @@ public:
 	double bd_kaudio_rate;
 	int bd_interlace_mode;
 	int max_w, max_h;
+	
+	BD_BatchRenderJob *batchrender;
 };
 
 class CreateBD_OK : public BC_OKButton
-- 
2.34.1

