![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
![[community profile]](https://www.dreamwidth.org/img/silk/identity/community.png)
I stopped by Free Geek Twin
Cities recently and picked up (among other things) a
Blu-ray player. It's the first time I've had one, and I was
pleasantly surprised that it was perfectly happy to play
standard audio and video files right off whatever media you put
in. It's incredibly useful with the USB port on the front, but
it can also read files off a CD or DVD if you happen to have one
(not that uncommon; I've certainly put podcasts on a CD-RW
before - a lot of car radios will play them!)
I also have a DVR that records shows from U.S. over-the-air
digital TV (ATSC 1.0) to a USB device, and the Blu-ray player
will play these raw transport stream files perfectly as well.
This gave me an idea: what if you wanted to permanently save
something you recorded off the antenna, in its original quality,
onto permanent physical media?
Of course, this is a very specific use case, one that I don't
even have a need for - it's definitely another case of me putting the
cart before the snail, if you will. But the fun part is
solving for a specific situation, and making something really
unique and cool in the process. Here were my requirements:
- The content must be a half-hour TV show from U.S. broadcast television, with commercials removed.
- It must be placed onto write-once / read-only DVD media.
- The media must contain a copy of the content, in its original quality, that can be played on a PC (or another device with a USB slot and the appropriate codecs).
- The media must also contain a copy of the content that can be played on a DVD player, with good quality audio, but the video quality of this copy is not important. We're talking about sitcom reruns here - you might as well be watching them on a potato.
- Finally, the DVD used must be one of those 8-centimeter
ones.
- Because they're cute.
Obviously, it's pretty unusual to dedicate most of the space of
a video DVD to data that isn't actually part of the DVD video
content.
But the important thing here is: your hard copy has
the original media (not re-encoded in any way), in case you want
to transfer it to another format; and it can be played on
a standard consumer device still found in many households, as long
as you're only half paying attention. Because although video data
takes up most of the bandwidth of any recording, it's almost
always the audio that's conveying the most important information,
so that's what you want to focus on.
In any case, some of this could probably be
extrapolated to storing more or longer videos onto standard
single- or dual-layer DVDs in much the same fashion, for some of
the same reasons. But in most cases, it would probably better to
just accept the permanent downgrade to standard-definition video
and make a standard DVD, or stick the files onto a USB flash drive
and play them on a smart TV or Blu-ray player or something like
that.
Splicing the (metaphorical) tape
VLC and ffmpeg don't see timestamps in the same way, so without re-encoding the video to some other codec, it's hard to be perfectly exact. But when cutting between the start/end of shows and commercial breaks, it's not really necessary.
To start with, I open VLC and note the timestamp of the beginning of the show:
Then I run an ffmpeg command to cut out everything before that
point. My recording is in a set of 6 or 7 .mts files, which I can
concatenate together before passing to ffmpeg.
cat WQOWABC-12282022-2001.mts* | ffmpeg -i - -c copy -ss 29:21.250 working.mts
I like to work one way in increments of a second until I see that
I'm cutting it off too early/late, then I work in the other
direction in half- or quarter-second increments until it looks OK.
Then I open this new file in VLC and find the next cut (the
beginning of the first commercial break).
ffmpeg -i working.mts -c copy -t 6:42 segment_a.mts
ffmpeg -i working.mts -c copy -ss 6:42 break_a.mts
ffmpeg -i break_a.mts -c copy -ss 2:30.75 break_b.mts
ffmpeg -i break_b.mts -c copy -t 6:26.5 segment_c.mts
ffmpeg -i break_b.mts -c copy -ss 6:26.5 break_c.mts
ffmpeg -i break_c.mts -c copy -ss 3:32.75 break_d.mts
ffmpeg -i break_d.mts -c copy -t 6:55.5 segment_e.mts
ffmpeg -i break_d.mts -c copy -ss 6:55.5 break_e.mts
ffmpeg -i break_e.mts -c copy -ss 1:49.75 break_f.mts
ffmpeg -i break_f.mts -c copy -t 1:03 segment_g.mts
rm -v working.mts break_*.mts
Once I'm happy with all the segment files, I concatenate them
together and put that in an .mkv container (the encoding process
doesn't always keep audio and video in sync if you give it a raw
transport stream).
cat segment_*.mts > output.mts
rm -v segment_*.mts
ffmpeg -i output.mts -c copy output.mkv
I also extract the captions to an .srt file that we'll use later. (The caption timestamps seem to be slightly off after the video gets converted, but I haven't really looked into this yet; there are probably simple ways to adjust them by a second or two, since the .srt file is plain text, after all.)
ccextractor output.mts -in=ts -out=srt
rm -v output.mts
Making the DVD
The first part of this is pretty simple - open DevedeNG and start a new video DVD project, then add the output.mkv file.
Select "output" in the files list and click Properties. We're
working with the very small space that will be left over after we
copy output.mkv onto the disc, so the properties we want to adjust
are:
- Video bitrate: 700 KBits/sec (uncheck "automatic")
- Subtitles: add the output.srt file
- Set the encoding to UTF-8 and the langauge to whatever
language the captions are in
- Audio: "Create DVD with 5.1 channel sound" - because in my case, the original content is in 5.1 as well. Unfortunately I couldn't find a way to get it to use the existing audio track (which I think is AC3).
You'll want to keep the resolution at 480 pixels high - when I
tried 360x240, one of my DVD players decided to have some fun with
the framebuffer, and the bottom of the screen flickered back and
forth rapidly:
I also unchecked "create a menu with the titles" in the main
window, because this disc has just the one episode on it.
This is when you can click "Forward", but once the file starts
converting, you're on the clock - there are a couple changes that
need to be made before it finished. While the files are being
re-encoded, go to the xml_data folder that DevedeNG has created.
Edit the XML file to adjust the automatically inserted chapter
markers near the end of each title:
<vob file="/home/isaac/movie/movies/movie_0.mpg" chapters="0,5:00,10:00,15:00,20:00,21:05" />
You'll need to do some math to figure out where the new chapter
markers should go, based on the size of the segments - or you
could just rewatch the output.mkv, I guess.
<vob file="/home/isaac/movie/movies/movie_0.mpg" chapters="0,6:42,13:08,20:04" />
This is also when you'll need to copy (or hard link) the
output.mkv file into the dvd_tree folder, so it gets copied onto
the disc:
ln output.mkv movie/dvd_tree/Candy\ Zombies.mkv
The result
I told you it was cute.
A mini-DVD like the ones I have will hold about 1.36 GB of data.
The disc I created contains 1.32 GB, of which 1.10 GB (83.2%) is
the "output.mkv" original media file, and just 227 MB (16.8%) is
the DVD video data.
The DVD video, of course, sounds fine but looks pretty
bad, particularly when there's a lot of camera movement. Here's a
side-by-side comparison:
DVD (700 Kbps video)
|
Original
|
But the video does play just fine on all three DVD
players I have - the Blu-ray player, the DVD/VCR combo unit you
see in the photo above, and a Panasonic player that I'm pretty
sure is over 20 years old. Inserting the disc into the Blu-ray
player causes it to start playing the DVD video content, just like
the other players:
But pressing Home on the remote lets me navigate to
"Data DVD", find the .mkv file, and play it. Captions don't work,
and it doesn't have my chapter markers, but it is playing the
original data that came over the air, which is pretty cool.