From 018c9250fb76528e1eae0b031c6126aa50b0ecc8 Mon Sep 17 00:00:00 2001
From: Good Guy <good1.2guy@gmail.com>
Date: Sun, 24 Apr 2022 19:25:13 -0600
Subject: [PATCH] fix chapter interval and tsmuxer by Andrew and company

---
 cinelerra-5.1/cinelerra/bdcreate.C | 5 +++--
 cinelerra-5.1/cinelerra/bdwrite.C  | 7 ++++---
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/cinelerra-5.1/cinelerra/bdcreate.C b/cinelerra-5.1/cinelerra/bdcreate.C
index 7420a31f..61362cfc 100644
--- a/cinelerra-5.1/cinelerra/bdcreate.C
+++ b/cinelerra-5.1/cinelerra/bdcreate.C
@@ -191,8 +191,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);
-	fprintf(fp,"if [ -f bd.meta ]; then\n");
-	fprintf(fp,"tsmuxer bd.meta $dir/bd.iso \n");
+	fprintf(fp,"if [ -f $dir/bd.meta ]; then\n");
+	fprintf(fp,"sed -i \"s|bd.m2ts|$dir\/bd.m2ts|g\" $dir/bd.meta\n");
+	fprintf(fp,"tsmuxer $dir/bd.meta $dir/bd.iso \n");
 	fprintf(fp,"mv $dir/bd.iso $dir/bd.udfs\n");
 	fprintf(fp,"else\n");
 	fprintf(fp,"mkudffs -b 2048 %s $blks\n", udfs);
diff --git a/cinelerra-5.1/cinelerra/bdwrite.C b/cinelerra-5.1/cinelerra/bdwrite.C
index d2ae7e6f..96526002 100644
--- a/cinelerra-5.1/cinelerra/bdwrite.C
+++ b/cinelerra-5.1/cinelerra/bdwrite.C
@@ -3161,7 +3161,7 @@ int
 main(int ac, char **av)
 {
   char *path = av[1];
-  if( mkbdmv(path) ) return 1;
+  
   av_log_set_level(AV_LOG_FATAL);
   //av_log_set_level(AV_LOG_VERBOSE);
   //av_log_set_level(AV_LOG_DEBUG);
@@ -3171,10 +3171,11 @@ main(int ac, char **av)
 
   int opt = getopt(ac, av, "c:");
   if (opt == 'c') {
-  chapter_every_n_sec = optarg[0]; start = 3; }
+  chapter_every_n_sec = atoi(optarg); start = 4;
+  path = av[3]; printf("Chapter interval: %i \n", chapter_every_n_sec );}
   else
   start = 2;
-
+  if( mkbdmv(path) ) return 1;
   for( int ii=start; ii<ac; ++ii ) {
     char *ap = av[ii];
     // any dash seq followed by number sets curr title pgm_pid
-- 
2.26.2