View previous topic :: View next topic |
Author |
Message |
beandog Bodhisattva
Joined: 04 May 2003 Posts: 2072 Location: /usa/utah
|
Posted: Mon Feb 17, 2014 4:31 am Post subject: DAE use DVD tools in scripts? |
|
|
I'm just curious if anyone else there has some scripting that they with some of the DVD tools out there. I have a *huge* library of DVDs myself, and I've started writing a few helper programs in C instead of in shell scripts now. And just to prove that this post isn't self-promotion, I'm not even going to give a link to them! Take that! (although seriously, if you want to find it, it'd be easy)
Anyway, I just finished putting one together this week that polls the DVD drive for it's status, so scripts can know when the DVD is actually accessible.
I'm writing some more, but if someone had some ideas for more, I'd be curious to hear what people have been looking for.
Edit: links: http://dvds.beandog.org/ https://github.com/beandog/dvd_tools _________________ If it ain't broke, tweak it. dvds | blurays | blog | wiki
Last edited by beandog on Mon Feb 17, 2014 3:40 pm; edited 2 times in total |
|
Back to top |
|
|
DawgG l33t
Joined: 17 Sep 2003 Posts: 866
|
Posted: Mon Feb 17, 2014 1:19 pm Post subject: |
|
|
Quote: | I've started writing a few helper programs in C instead of in shell scripts |
sounds interesting - what's your goal?
i use shellscripts to convert my dvds to mkvs (convert video to x264 with ffmpeg/mencoder, keep surround-sound, keep English and German Vobsubs, generate SRT-Subs from them) but since there is no kind of "standadized" structure for dvds (eg. audio-track 0 is always English) it's all single scripts for single steps and manual selection is often required. also spell-checking and srt-"cleanup" are done almost manually.
i think for auto-playing or auto-converting dvds i'd probably use a udev-rule. _________________ DUMM KLICKT GUT. |
|
Back to top |
|
|
beandog Bodhisattva
Joined: 04 May 2003 Posts: 2072 Location: /usa/utah
|
Posted: Mon Feb 17, 2014 3:38 pm Post subject: |
|
|
DawgG wrote: | Quote: | I've started writing a few helper programs in C instead of in shell scripts |
sounds interesting - what's your goal?
i use shellscripts to convert my dvds to mkvs (convert video to x264 with ffmpeg/mencoder, keep surround-sound, keep English and German Vobsubs, generate SRT-Subs from them) but since there is no kind of "standadized" structure for dvds (eg. audio-track 0 is always English) it's all single scripts for single steps and manual selection is often required. also spell-checking and srt-"cleanup" are done almost manually.
i think for auto-playing or auto-converting dvds i'd probably use a udev-rule. |
I've got my own *massive* ripper program that I wrote in PHP, which is all shell scripts. It actually automates everything you mentioned except for the SRT subs -- I just use the vob subs and the closed captioning and cram them in there.
As far as my goal, I'm just looking to drop as many dependencies as possible. For example:
- using HandBrakeCLI to get DVD serial ID, check if there are closed captioning subtitles
- use small individual programs to replace lsdvd
- alternative program to dump chapter info from DVDs
Also, I can tell you how to automate finding the English track. I'd have to look through my code to find it exactly, but here's basically what it does:
- Re-order the list of audio streams, by the audio stream ID sequentially
- The English track to rip is the *first* English track from that list that also has the most channels
- Prefer DTS over AC3 (personal preference)
That's worked for about 99% of my DVDs.
Mind if I take a look at your ripper scripts? I'm curious to see what you've got. _________________ If it ain't broke, tweak it. dvds | blurays | blog | wiki |
|
Back to top |
|
|
Nicias Guru
Joined: 06 Dec 2005 Posts: 446
|
Posted: Mon Feb 17, 2014 5:47 pm Post subject: |
|
|
I also have a few scripts to do this. I used to use a combination of ffmpeg dvdxchap lsdvd mkvmerge & mencoder/mplayer to make mkv copies with all tracks.
I then manually check for telecine, frame rate, etc. and tag the files accordingly. If Movie.mkv is 24fps pretending to be 30fps. I name it Movie.film.mkv. If I want to keep non-english audio. I label it Movie.nostrip.mkv
Then I use ffmpeg to transcode the video and mkvmerge to remove surplus tracks (I do this part in batches.)
I've since switched to mostly using makemkvcon to produce the raw mkv's.
I've put them up at github
<scripts removed to github>
Last edited by Nicias on Mon Feb 17, 2014 7:22 pm; edited 1 time in total |
|
Back to top |
|
|
beandog Bodhisattva
Joined: 04 May 2003 Posts: 2072 Location: /usa/utah
|
Posted: Mon Feb 17, 2014 5:54 pm Post subject: |
|
|
Nicias wrote: | I also have a few scripts to do this. I used to use a combination of ffmpeg dvdxchap lsdvd mkvmerge & mencoder/mplayer to make mkv copies with all tracks.
I then manually check for telecine, frame rate, etc. and tag the files accordingly. If Movie.mkv is 24fps pretending to be 30fps. I name it Movie.film.mkv. If I want to keep non-english audio. I label it Movie.nostrip.mkv
Then I use ffmpeg to transcode the video and mkvmerge to remove surplus tracks (I do this part in batches.)
I've since switched to mostly using makemkvcon to produce the raw mkv's.
Here are my scripts. (Spacing is likely to be ruined) |
*snip code*
The dvdxchap program is old (ogmtools) and doesn't work 100% correctly, so I'm looking to do a rewrite for that.
As far as the scripts go, stuff looks good, I'm doing really similar stuff. You should throw it up on github so people can poke at it.
The big thing with the scripts, and this is the same stuff I run into, is I hate parsing output of all these little multimedia tools. So my little programs I'm writing are specifically designed with shell scripts in mind. fex: dvd_title returns just the title string. _________________ If it ain't broke, tweak it. dvds | blurays | blog | wiki |
|
Back to top |
|
|
beandog Bodhisattva
Joined: 04 May 2003 Posts: 2072 Location: /usa/utah
|
Posted: Mon Feb 17, 2014 5:58 pm Post subject: |
|
|
beandog wrote: | The big thing with the scripts, and this is the same stuff I run into, is I hate parsing output of all these little multimedia tools. So my little programs I'm writing are specifically designed with shell scripts in mind. fex: dvd_title returns just the title string. |
Case in point:
Nicias wrote: | DISC=`/usr/bin/lsdvd ${TARGET} | /bin/grep Disc | /bin/sed 's/Disc\ Title:\ //'` |
Here's my C program that grabs it. Eventually it'll go into a larger program where you can query all the info.
Code: |
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <linux/cdrom.h>
/**
* A simple little program to get the DVD title
*
* Checks if the device is a DVD drive or not, and if it is, also looks to see
* if it can be polled or not.
*/
int main(int argc, char **argv) {
int cdrom;
int drive_status;
int disc_status;
char* dvd_device;
char* status;
char title[33];
FILE* filehandle = 0;
int x, y, z;
if(argc == 1)
dvd_device = "/dev/dvd";
else
dvd_device = argv[1];
// Check if device exists
if(access(dvd_device, F_OK) != 0) {
fprintf(stderr, "cannot access %s\n", dvd_device);
return 1;
}
// Open device
cdrom = open(dvd_device, O_RDONLY | O_NONBLOCK);
if(cdrom < 0) {
fprintf(stderr, "error opening %s\n", dvd_device);
return 1;
}
drive_status = ioctl(cdrom, CDROM_DRIVE_STATUS);
// If the device is a DVD drive, then wait up to 30 seconds for it to be ready (not opening or closing),
// and then check if there is a disc in the tray. If there's no disc, exit quietly.
// If the drive is open, then it just quietly exits.
if(drive_status > 0) {
int max_sleepy_time = 30;
int num_sleepy_times = 0;
while(ioctl(cdrom, CDROM_DRIVE_STATUS) == CDS_DRIVE_NOT_READY && num_sleepy_times < max_sleepy_time) {
sleep(1);
num_sleepy_times++;
}
if(ioctl(cdrom, CDROM_DRIVE_STATUS) != CDS_DISC_OK) {
close(cdrom);
return 1;
}
}
close(cdrom);
filehandle = fopen(dvd_device, "r");
if(filehandle == NULL) {
fprintf(stderr, "could not open device %s for reading\n", dvd_device);
return 1;
}
if(fseek(filehandle, 32808, SEEK_SET) == -1) {
fprintf(stderr, "could not seek on device %s\n", dvd_device);
fclose(filehandle);
return 1;
}
x = fread(title, 1, 32, filehandle);
if(x == 0) {
fprintf(stderr, "could not read device %s\n", dvd_device);
fclose(filehandle);
return 1;
}
title[32] = '\0';
fclose(filehandle);
y = sizeof(title);
while(y-- > 2) {
if(title[y] == ' ') {
title[y] = '\0';
}
}
for(z = 0; z < strlen(title); z++) {
printf("%c", title[z]);
}
printf("\n");
return 0;
}
|
Code: |
clang -o dvd_title dvd_title.c
|
(gcc works too) _________________ If it ain't broke, tweak it. dvds | blurays | blog | wiki |
|
Back to top |
|
|
Nicias Guru
Joined: 06 Dec 2005 Posts: 446
|
Posted: Mon Feb 17, 2014 7:24 pm Post subject: |
|
|
beandog wrote: |
The dvdxchap program is old (ogmtools) and doesn't work 100% correctly, so I'm looking to do a rewrite for that.
|
I've ditched it in favor of makemkv.
Quote: |
As far as the scripts go, stuff looks good, I'm doing really similar stuff. You should throw it up on github so people can poke at it.
The big thing with the scripts, and this is the same stuff I run into, is I hate parsing output of all these little multimedia tools. So my little programs I'm writing are specifically designed with shell scripts in mind. fex: dvd_title returns just the title string. |
I've put them up on github |
|
Back to top |
|
|
beandog Bodhisattva
Joined: 04 May 2003 Posts: 2072 Location: /usa/utah
|
Posted: Mon Feb 17, 2014 8:57 pm Post subject: |
|
|
Nicias wrote: | beandog wrote: |
The dvdxchap program is old (ogmtools) and doesn't work 100% correctly, so I'm looking to do a rewrite for that.
|
I've ditched it in favor of makemkv. |
Ah, nice. I was looking through mine, I forgot that I just use HandBrake now. I still wanna fix dvdxchap though, it's a nice little app.
Nicias wrote: | Quote: | As far as the scripts go, stuff looks good, I'm doing really similar stuff. You should throw it up on github so people can poke at it.
The big thing with the scripts, and this is the same stuff I run into, is I hate parsing output of all these little multimedia tools. So my little programs I'm writing are specifically designed with shell scripts in mind. fex: dvd_title returns just the title string. |
I've put them up on github |
Thanks man, that's much easier to read.
I threw mine up on github as well: https://github.com/beandog/dart _________________ If it ain't broke, tweak it. dvds | blurays | blog | wiki |
|
Back to top |
|
|
DawgG l33t
Joined: 17 Sep 2003 Posts: 866
|
Posted: Tue Feb 18, 2014 11:58 am Post subject: |
|
|
well, looking at your stuff i'm certain the scripts i use will not help you any further (i'm no programmer). basically they show me what's there and i select the stuff i want manually (eg. for kids' movies no english soundtrack, sometimes director's comments etc.) - BECAUSE Quote: | parsing output of all these little multimedia tools | is such a PITA.
i thought about using makemkv(con) too (so far i only use it for blurays) but it is non-GPL and the lastest version does not work anymore (on my ~-systems) _________________ DUMM KLICKT GUT. |
|
Back to top |
|
|
beandog Bodhisattva
Joined: 04 May 2003 Posts: 2072 Location: /usa/utah
|
Posted: Tue Feb 18, 2014 9:07 pm Post subject: |
|
|
DawgG wrote: | well, looking at your stuff i'm certain the scripts i use will not help you any further (i'm no programmer). basically they show me what's there and i select the stuff i want manually (eg. for kids' movies no english soundtrack, sometimes director's comments etc.) - BECAUSE Quote: | parsing output of all these little multimedia tools | is such a PITA. |
Yah, that's what I'm making, is new little proggies that dump really simple output specifically to be used in batch scripts. I've got the git repo here: https://github.com/beandog/dvd_info
Right now there are (obviously) very few things: grabbing the DVD title, provider id, VMG id, drive status, number of tracks, but I'm working on evolving it into basically something similar to lsdvd, but outputting simple strings. (Also, it'll all be packed into one binary .. I'm just keeping it separate for now)
DawgG wrote: | i thought about using makemkv(con) too (so far i only use it for blurays) but it is non-GPL and the lastest version does not work anymore (on my ~-systems) |
I'm hearing that a lot ... have you guys tried using an older version?
Edit: For the record, *this* github repo I'm mentioning here is *not* the one I mentioned earlier ... the other one is PHP, this one is all C. _________________ If it ain't broke, tweak it. dvds | blurays | blog | wiki |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|