A few people have shown interest in commercial_cut, so in the interest of open-ness, to let eveyone know what is happening I will post some of the private messages here:
nigelpearson wrote:
Hi Greg. Finally got around to testing this thoroughly.
(actually, I had to grab a .vob file from a DVD I burnt
a few months ago, insert that file into /myth/tv using
myth.rebuilddatabase.pl, build a seek table for it
using mythcommflag --rebuild, and use v4 to cut it,
because it had markups of type 6 instead of 9)
The program had a minor problems.
Here are the changes I made to:
1) make it cope with any number of extra fields in
the recorded table (like for CVS updated DBs),
2) cope with a null recordid,
3) let it keep the original recording, when run from
the command line, without cutpoint trickery
% diff -u commercial_cut.c.orig commercial_cut.c
--- commercial_cut.c.orig 2005-05-27 22:30:14.000000000 +0000
+++ commercial_cut.c 2005-06-13 20:30:38.000000000 +0000
@@ -114,8 +114,9 @@
char *title = NULL;
char *subtitle = NULL;
char *description = NULL;
- int delete_original = 0;
+ int delete_original = 1;
int experimental_pvr_x50_mode = 0;
+ int num_fields;
MYSQL mysql;
MYSQL_RES *res;
@@ -180,6 +181,11 @@
printf ("Ignoring -d (not really sure what it does).\n");
break;
+ case 'k':
+ printf ("Keeping the original recording.\n");
+ delete_original = 0;
+ break;
+
case 'l':
printf ("Using cutlist (which will be used regardless).\n");
break;
@@ -195,8 +201,9 @@
"Usage:\n"
"\n"
"./commercial_cut [-T "Title"] [-S "Subtitle"] [-D "Description"]\n"
- " [-c chanid -s starttime] [input.nuv]\n"
+ " [-c chanid -s starttime] [-k] [input.nuv]\n"
"\n"
+ "-k means keep the original file.\n"
"You must either pass a file that is a valid myth recording that can\n"
"be found in the mythconverg database, or a chanid and starttime of\n"
"such a recording (this is the format supplied to mythtranscode).\n");
@@ -449,19 +456,18 @@
/* If there is at least one cut, and the first cut is non-zero and */
/* less than 25 (i.e a delete after right near the start of the */
/* recording) then keep the original recording. */
-
+
if ((num_cuts > 0) && (cut_start[0] > 0) && (cut_start[0] < 25))
{
delete_original = 0;
cut_start[0] = 0;
- fprintf (output, "Will keep the original recording\n");
- }
- else
- {
- delete_original = 1;
- fprintf (output, "Will delete the original recording\n");
}
+ if (delete_original)
+ fprintf (output, "Will delete the original recording\n");
+ else
+ fprintf (output, "Will keep the original recording\n");
+
for (int cut = 0; cut < num_cuts; cut++)
{
fprintf (output, "Cutlist %d: %d - %d\n",
@@ -865,14 +871,14 @@
}
else
{
- fprintf (output, "Result with %d fields\n", mysql_field_count (&mysql));
+ num_fields = mysql_field_count (&mysql);
+ fprintf (output, "Result with %d fields\n", num_fields);
}
- if (mysql_field_count (&mysql) != 25)
+ if (num_fields != 25)
{
- fprintf (output, "Expected 25 fields in recorded got %d\n",
- mysql_field_count (&mysql));
- exit (1);
+ fprintf (output, "Expected 25 fields in recorded got %d\n", num_fields);
+ fprintf (output, "Database is newer than expected. Resultant file may cause problems.\n");
}
row = mysql_fetch_row (res);
@@ -900,21 +906,44 @@
mysql_real_escape_string (
&mysql, escaped_description, description, strlen (description));
- sprintf (buffer, "INSERT INTO recorded VALUES "
- "(%s,'%s','%s','%s','%s','%s','%s','%s',NULL,%s,'',%s,%s,"
- "'%s',%d,'%s','%s',%s,%lld,%s,%s,'%s','%s','%s','%s')",
- row[0],
- time_t_to_date_string (new_start_time_t),
- time_t_to_date_string (new_end_time_t),
- escaped_title,
- escaped_subtitle,
- escaped_description,
- row[6], row[7], row[9],row[11],row[12],row[13],atoi(row[14]) + 1,
- row[15],row[16],row[17],output_file_size,row[19],
- row[20],row[21],row[22],row[23],row[24]);
+ sprintf (buffer, "INSERT INTO recorded VALUES (%s,'%s','%s','%s','%s','%s',",
+ row[0],
+ time_t_to_date_string (new_start_time_t),
+ time_t_to_date_string (new_end_time_t),
+ escaped_title,
+ escaped_subtitle,
+ escaped_description);
+
+ sprintf (buffer+strlen(buffer), "'%s','%s',NULL,%s,'',%s,%s,'%s',",
+ row[6], // category
+ row[7], // hostname
+ row[9], // editing
+ row[11], // autoexpire
+ row[12], // commflagged
+ row[13]); // recgroup
+
+ if (!row[14])
+ row[14] = "0";
+
+ sprintf (buffer+strlen(buffer), "%d,'%s','%s',%s,%lld,%s,%s",
+ atoi(row[14]) + 1, // recordid
+ row[15], // seriesid
+ row[16], // programid
+ row[17], // lastmodified
+ output_file_size,
+ row[19], // stars
+ row[20]); // previouslyshown
+
+ for (int field = 21; field < num_fields; ++field)
+ {
+//fprintf(output,"Adding field %d - %s\n", field, row[field]);
+ sprintf (buffer+strlen(buffer), ",'%s'", row[field]);
+ }
+
+ strcat(buffer+strlen(buffer), ")");
}
-
+
mysql_free_result (res);
printf ("%s\n", buffer);
%
Also:
1) v0.4 changes the start time of the original file
(subtracts a minute), where 0.1 didn't. This is a pain if I
am extracting several clips from the original file,
because I have to change the file name each time I run
the program. Any reason why this has to happen?
2) For the way I use it (cutting multiple clips from a file),
it would be handy if the script prompted for a new Title,
Subtitle or Description of the new file.
Do you reckon other people would find this useful?
Should that be farmed off to a different script?
(e.g. make cutlib.c, cut.c and cut-and-copy.c)
Greg Frost wrote:
Good stuff Nigel. I will have a close look at your changes soon and try to put them up as 0.5. They seem reasonable at first glance to me.
nigelpearson wrote:
1) v0.4 changes the start time of the original file
(subtracts a minute), where 0.1 didn't. This is a pain if I
am extracting several clips from the original file,
because I have to change the file name each time I run
the program. Any reason why this has to happen?
The reason I do this is because when I run it from the myth interface as a substitute for transcode, it is actually the backend that removes the original recording and renames the .tmp file after mythtranscode completes. I though I could get around this by renaming the original to its .tmp name so that the backend would put the same recording back, and this worked but for some reason, the backend blows away the recordedmarkup info. I couldnt work out how the new recordedmarkup info for the cut recording actually got into the database. So as a quick hack, I renamed the original with a new starttime and updated its info in the database for the new start time so that the backend did not stuff it up.
nigelpearson wrote:
2) For the way I use it (cutting multiple clips from a file),
it would be handy if the script prompted for a new Title,
Subtitle or Description of the new file.
Do you reckon other people would find this useful?
Should that be farmed off to a different script?
(e.g. make cutlib.c, cut.c and cut-and-copy.c)
Not a different script. I think just add a command line switch that makes it prompt for the Title/Subtitle/Description
nigelpearson wrote:
OK. Maybe we could make the script behave differently, depending on whether it is being called as transcode or not?
1) If transcode, default delete_original=1 and change timestamp of original
2) If command-line and -k (delete_original=0), prompt for new title, etc
Greg Frost wrote:
Sounds reasonable.
I guess you just check arg[0] to see if it is called as transcode.
Also if the title/sub/desc are specified on the command line, don't prompt, and when prompting, the default should be the existing title/sub/desc if you just press enter.
Wanna implement and post to the wiki yourself?
nigelpearson wrote:
Yes, in my spare time
Note that the patch I gave you this morning is missing a 'k' in the arg checking.
Note also that a lot of the time the Wiki is not accessible by me
Greg Frost wrote:
Well, I'll give it a go in my spare time too. If your spare time is like mine, chances are very slim that we'll duplicate effort. Shocked
Then just recently:
mwahal wrote:
Greg,
I've modified verion 4 to make it work on 0.18.1 (which has 26 fields).
I'm also in process of specifying an alternate directory for tmp files.
The reason is when commercial cut is running, its reading and writing the files on the same hard drive. The iowait jumps to 90%+ on the system. Any access to the system slows down a lot. I need to experiment by adding another hard drive in the system and use that as tmp directory. So, hopefully, the iowait wont the that high.
Will let you know.
Thanks
Mudit
Sorry Mundit, it would appear that I got the myth/knoppmyth versions a bit confused when I replied to you. It 0.18.1 was actually introduced at R5A16, so I'm not using it yet, and from your comments, it would appear that 0.18 to 0.18.1 changed the recorded table. The patches posted by nigel are a better solution because it should work after they change the recorded table (so long as all they do is add integer fields). Unfortunately neither I, nor (it would appear) nigel, has had time to release a new version.
To make a new version, just change the name of the directory it is in and type make dist. This will create a commercial_cut-newversion.tar.gz in the parent directory (where the version number comes from the directory name).