 |
Making a DVD from the .ts stream Captured from getatsc |
 |
Posted: Mon Dec 06, 2004 11:00 pm |
|
|
| rab45 |
|
|
| |
| Joined: 24 Nov 2004 |
| Posts: 42 |
|
|
|
 |
 |
 |
|
OK, I have everything setup and running with the HD3000. I installed the NVIDIA binary driver (I'm using the 32-bit FC2 on an Athlon 64 system) so that viewing and playback are very smooth.
Is there a simple process for taking the .ts file from getatsc and making a DVD so I can play it back on most generic DVD players? I have K3B - can I use that? Do I have to do any conversions?
Rick B. |
|
|
|
|
 |
Re: Making a DVD from the .ts stream Captured from getatsc |
 |
Posted: Wed Jan 26, 2005 11:56 pm |
|
|
| decourl |
|
|
| |
| Joined: 26 Jan 2005 |
| Posts: 7 |
|
|
|
 |
 |
 |
|
To burn pcHDTV-captured content to DVD in standard format: (rev. 2)
I have edited this post to reflect:
1) a move away from yuv-filters toward mencoder filters
(mjpegtools might be good for your wedding video, but
they take too darn long for be desirable for much else;
although still using mpeg2enc due to superior encoding
quality)
2) now using named pipes for the AVI file. This allows us to
avoid using a lossy intermediate codec while respecting
disk space limitations (mencoder can't produce dvdauthor-
suitable MPEG directly).
3) have begun to frame the response as a shell script.
I hope to flesh out the script to respect a bunch of different run-time
options (ie: use brand-X encoder instead of brand-Y encoder;
use format A instead of format B; target PAL instead of NTSC;
letterbox instead of using anamorphic 16:9; etc). For the mean time,
here is the basic proof of concept script that demonstrates exactly what
needs to be done for the basic case.
The biggest feature of this script is the use of named pipes which
eliminates an entire generation of lossy encoding/decoding (ie mpeg4
or mjpeg) which would otherwise be necessary given the size of raw
video).
| Code: |
#!/usr/bin/ksh
# This script extracts programs from MPEG2 Transport Streams
# and converts them to MPEG2 Elementary Streams suitable for
# multiplexing and burning to DVD.
# nothing ksh-specific here (yet) so you can use bash instead
# not using getopts (yet) so modify next lines for your situation
VID=49 # you can use mpgtx (mpgtx.sourceforge.net) to get a list
AID=52 # of the valid AIDs and VIDs in a TS. then you can use
# mplayer -aid -vid to determine which pairing
# represents the desired program.
TS=dtv.m2t # the file containing your transport stream
# shouldn't need to modify anything past this point
# but that doesn't mean you might not benefit from doing so.
mkfifo prog.avi
mkfifo prog.wav
mencoder -aid $AID \
-vid $VID \
-forceidx \
-vf scale=720:480:1:0:0.00:0.75 \ # scale to NTSC res
-ofps 30000/1001 \ # NTSC frame rate
-of avi \ # mencoder makes bad MPG
-ovc lavc \ # use lossless vid. codec to
-lavcopts vcodec=ljpeg \ # prevent unnecessary degrad.
-oac pcm \ # use raw audio, same reason
-o prog.avi \
$TS &
sleep 3
mplayer -ao pcm \ # demux avi, decode video,
-aofile prog.wav \ # tee off raw audio and video
-noframedrop \ # streams
-vo yuv4mpeg \
prog.avi &
sleep 3
cat stream.yuv | mpeg2enc -a 3 \ # set "anamorphic" aspect
-n n \ # declare NTSC
-f 8 \ # for dvdauthor
-F 4 \ # NTSC frame rate
-o prog.m2v &
ffmpeg -ab 224 \ # produce AC3 audio
-ac 2 \
-ar 48000 \
-i prog.wav \
prog.ac3
### END OF SCRIPT
|
That's the "hard part". To finish up creating and burning the dvd,
execute the rest of these commands. Google for any tools that you
might be missing.
| Code: |
# remove pipes
rm prog.avi prog.wav
# multiplex ESs to PS
mplex -f 8 -o prog.mpg out.m2v out.ac3
# write dvdauthor configuration
cat << EOF > dvdauthor.xml
<dvdauthor dest="/pathto/writable/nonexistant-dir">
<vmgm />
<titleset>
<titles>
<pgc>
<vob file="prog.mpg" />
</pgc>
</titles>
</titleset>
</dvdauthor>
EOF
# note that it would be nice to divide the DVD title into chapters.
# you can edit the above XML to look something like this:
# <vob file="prog.mpg" chapters="0:00,15:00,30:00,45:00" />
# you can also do DVD menus but that's beyond the
# scope of this document
# execute dvdauthor
dvdauthor -x dvdauthor.xml
# burn DVD
growisofs -Z /dev/dvd dvd-video /pathto/dvdauthor-dest
|
Oh, one thing that I haven't encorporated which might be immediately
useful. If you happened to catch, say 22 seconds of stuff in the TS
before your show started, you could throw a "-ss 22" onto the mencoder
command line. Just test it first with mplayer to be sure that it actually
starts playing at the right point.
I hope that this information helps!
-Lincoln DeCoursey
---
| rab45 wrote: | OK, I have everything setup and running with the HD3000. I installed the NVIDIA binary driver (I'm using the 32-bit FC2 on an Athlon 64 system) so that viewing and playback are very smooth.
Is there a simple process for taking the .ts file from getatsc and making a DVD so I can play it back on most generic DVD players? I have K3B - can I use that? Do I have to do any conversions?
Rick B. |
|
|
|
|
|
 |
 |
|
 |
Posted: Sat Feb 05, 2005 8:44 am |
|
|
| johnclubvec |
|
|
| |
| Joined: 17 Nov 2004 |
| Posts: 20 |
| Location: Cambridge, Massachusetts |
|
|
 |
 |
 |
|
Dear Lincoln,
I've tried out your code and I've written to say that I'm most impressed with your knowledge of the intricacies of this, and the result. I did have to reverse a few lines in your script to get it to work, however. Namely, I had to "cat stream.yuv" AFTER everything else; that is, I needed a completed stream.yuv before using mpeg2enc on it. That was the main thing: mencoder & + mplayer & were fine, then ffmpeg, then mpeg2enc.
The completed video quality was really high, and the .mpg file was about 1/5 the size of the original .ts file. On the downside, on my 2.53 Ghz P4, 5 minutes of .ts took about 23 minutes to process, AND the intermediate file (stream.yuv) was about 6 times the size of the original. Moral: you need gobs of time, and PLENTY of disk space.
Memo to anyone interested: in Lincoln's line:
-vf scale=720:480:1:0:0.00:0.75
the "1" appears to set the "Interlaced" flag; if you don't have interlaced content (FOX, ABC, I believe are both 720p), then you can change it to "0" (zero).
Thanks again, Lincoln! |
|
|
|
|
 |
 |
|
 |
Posted: Sat Feb 05, 2005 1:18 pm |
|
|
| johnclubvec |
|
|
| |
| Joined: 17 Nov 2004 |
| Posts: 20 |
| Location: Cambridge, Massachusetts |
|
|
 |
 |
 |
|
Update:
Said "What the heck" and tried it with a full-hour .ts file.
Report:
There are definitely economies of scale.
Total processing time, .ts to .mpg file: 47 min.
original .ts file: 7197 mb (1080i, 1 hr length, 1 stream total)
stream.yuv: 9664 mb
mpg file: 243 mb (yes, that's correct!)
Downside: about the last minute of the file was not processed. |
|
|
|
|
Posted: Sat Feb 05, 2005 3:04 pm |
|
|
|
| johnclubvec wrote: |
mpg file: 243 mb (yes, that's correct!) |
This seems suspiciously low for a decent-quality one-hour MPEG2 file. At 4Mbps (about as low as I'd care to go) it should be 2GB at full resolution. |
|
|
|
|
Posted: Sat Feb 05, 2005 7:35 pm |
|
|
| johnclubvec |
|
|
| |
| Joined: 17 Nov 2004 |
| Posts: 20 |
| Location: Cambridge, Massachusetts |
|
|
 |
 |
 |
|
Dear "Guest,"
re bitrate -- I don't know; you'll have to look at Lincoln's code. For what it's worth, mpeg2enc reports this on processing the file:
INFO: [mpeg2enc] Bitrate: 7500 KBit/s
and in man mpeg2enc re "--format 8":
"Bit-rate defaults to 7500kbps, buffer sizes to the maximum permitted by the DVD specification." |
|
|
|
|
 |
 |
|
 |
Posted: Sat Feb 05, 2005 8:12 pm |
|
|
| ceenvee703 |
|
|
| |
| Joined: 15 Dec 2004 |
| Posts: 13 |
|
|
|
 |
 |
 |
|
| johnclubvec wrote: | Dear "Guest,"
re bitrate -- I don't know; you'll have to look at Lincoln's code. For what it's worth, mpeg2enc reports this on processing the file:
INFO: [mpeg2enc] Bitrate: 7500 KBit/s
and in man mpeg2enc re "--format 8":
"Bit-rate defaults to 7500kbps, buffer sizes to the maximum permitted by the DVD specification." |
Sorry for the anonymous post, that was me.
OK, well, if it really is 7500Kbit/sec, then...
7500Kbit/sec * (60 sec/min) * (60 min/hr) = 27000000 Kbits
27000000 Kbits * (1 byte/8 bits) * (1MB / 1024 KB) * (1GB /1024 MB)
= 3.22 GB.
So something's literally not adding up. |
|
|
|
|
 |
 |
|
 |
Posted: Sat Feb 05, 2005 10:57 pm |
|
|
| pfile |
|
|
| |
| Joined: 06 Aug 2004 |
| Posts: 80 |
|
|
|
 |
 |
 |
|
so one thing about this flow: why convert the audio to PCM and then back to AC3? i think AC3 is the only legal audio format for ATSC (maybe, but every show i've recorded has AC3 audio), and AC3 is a legal DVD audio format, why not just dump the audio with mplayer to a separate file, and then just skip the ffmpeg step, and pass the original AC3 audio to the DVD authoring tool?
mplayer -dumpaudio will dump the audio stream.
edit: also when using mplayer to dump the audio/video, i think you want to use -benchmark so it plays it as fast as it possibly can. |
|
|
|
|
 |
 |
|
 |
Posted: Sun Feb 06, 2005 4:55 am |
|
|
|
Better men than I have the answers to the questions raised (and I hope you do); my bit, it seems, is to try the script out and report the results. The idea of using lossless decoding and named pipes is attractive. There seem to be problems, particularly once "real" .ts streams of sizable length are processed; what the problems are and why they are, and how they can be fixed, is beyond my knowledge, but hopefully not beyond everyone's.
Followup to my above comments:
I am definitely getting a "broken pipe" error re mencoder on 1-hour files. Somewhere around minute 11-16, mencoder stops issuing messages (but apparently continues to do something at least occasionally, since I at least once obtained an almost-complete .mpg file). On another occasion the break was irretrievable and things just stopped.
I also got a very strange error once, which I could reproduce consistently with that particular .ts file. Everything began fine, but after a few minutes of watching the resulting .mpg file, I began to see a different video stream than the one I viewed when watching the original stream. (Yes, I examined the VID prior to running the script and correctly told it whcih to use). Maybe the VID changes somewhere? I don't know, I'm just reporting.
Best of luck to the wiser heads in this discussion. |
|
|
|
|
 |
 |
|
 |
Posted: Sun Feb 06, 2005 7:36 am |
|
|
| johnclubvec |
|
|
| |
| Joined: 17 Nov 2004 |
| Posts: 20 |
| Location: Cambridge, Massachusetts |
|
|
 |
 |
 |
|
johnclubvec (me) is the author of the previous post:I thought for sure that I had logged in.... I am logged in now; hopefully this will "take."
Further update: the mencoder pipe is definitely breaking on longer files.; even my first 1-hour effort, which I had reported as successful but for the last minute, had broken long before the end. On a cursory look-see, I had misidentified the last scene I viewed in the resulting .mpg file as the last scene in the show. I was wrong; what I saw was another scene considerably before the end which looked similar to the final scene in the show. |
|
|
|
|
 |
Converting audio |
 |
Posted: Tue Feb 08, 2005 10:21 am |
|
|
|
Because the AC3 stream is picked up off-the-air, it is often (in my experience)
subtly corrupt due to recovery errors. On the Internet, you check what you receive
for errors. and ask for retransmission if one is detected. On the receiving end of
an ATSC broadcast, you don't check for errors and can't request retransmission.
mplayer/mencoder is engineered to handle subtle errors in input files gracefully, so I believe it is a good idea to have mencoder freshly recode the stream in question.
I have seen some articles suggest using mencoder -oac copy for the first step
and then later using mplayer -dumpaudio (or some similar AC3 extraction technique)
for the second step. I'm not sure if this "copy" process is guaranteed to generate
standards-conforming programs or not. It is difficult to tell: mplayer is forgiving,
maybe our hardware DVD player is forgiving, but what about an arbitrary DVD player?
I am not saying that it won't work, I'm just pointing out that there might be an issue.
-Lincoln
| pfile wrote: | so one thing about this flow: why convert the audio to PCM and then back to AC3? i think AC3 is the only legal audio format for ATSC (maybe, but every show i've recorded has AC3 audio), and AC3 is a legal DVD audio format, why not just dump the audio with mplayer to a separate file, and then just skip the ffmpeg step, and pass the original AC3 audio to the DVD authoring tool?
mplayer -dumpaudio will dump the audio stream.
edit: also when using mplayer to dump the audio/video, i think you want to use -benchmark so it plays it as fast as it possibly can. |
|
|
|
|
|
 |
 |
|
 |
Posted: Tue Feb 08, 2005 10:33 am |
|
|
|
It was intended (but erroneously not mentioned) that stream.yuv was also intended
to be a named pipe. That is, there would be a mkfifo stream.yuv with the other
mkfifo lines.
This will allow the script to work in the presented order, and will eliminate the need for
excessive disk space.
If you want a potentially faster process, you can first use mencoder to scale to
NTSC resolution and to produce an AVI containing mpeg4- or mjpeg-encoded video.
There are many avi2vob-style scripts out there that will automate the generation
of dvdauthor-ready MPEG2 programs given an arbitrary AVI file. I have found
that most rely upon a program called transcode. This would greatly simplify
the process, and would likely result in faster processing. By default, transcode
uses a faster MPEG2 encoder called ffmpeg rather than mpeg2enc.
I'm not sure about the broken pipe issue. If this issue can't be rectified, then the
idea of using lossless coding for the intermediate step quickly becomes quite
unworkable.
| johnclubvec wrote: | Dear Lincoln,
I've tried out your code and I've written to say that I'm most impressed with your knowledge of the intricacies of this, and the result. I did have to reverse a few lines in your script to get it to work, however. Namely, I had to "cat stream.yuv" AFTER everything else; that is, I needed a completed stream.yuv before using mpeg2enc on it. That was the main thing: mencoder & + mplayer & were fine, then ffmpeg, then mpeg2enc.
|
|
|
|
|
|
 |
 |
Re: Converting audio |
 |
Posted: Tue Feb 08, 2005 10:40 am |
|
|
| pfile |
|
|
| |
| Joined: 06 Aug 2004 |
| Posts: 80 |
|
|
|
 |
 |
 |
|
fair enough. my signal strengths are so high that i rarely get a corrupted recording. unless of course i have the dreaded buffer overflow
| Anonymous wrote: | Because the AC3 stream is picked up off-the-air, it is often (in my experience)
subtly corrupt due to recovery errors. On the Internet, you check what you receive
for errors. and ask for retransmission if one is detected. On the receiving end of
an ATSC broadcast, you don't check for errors and can't request retransmission.
|
|
|
|
|
|
Posted: Tue Feb 08, 2005 4:43 pm |
|
|
| Scott Larson |
|
|
| |
| Joined: 15 Oct 2003 |
| Posts: 713 |
| Location: Portland, OR |
|
|
 |
 |
 |
|
| I receive one station at 98%. I would be getting a perfect stream from them.... except they send me a corrupt a52 packet every time they switch to local commercials. Heaven knows how they're doing this. ATSC data can get corrupted even before it gets transmitted although I'm sure it's not intentional. |
|
|
|
|
Posted: Wed Feb 09, 2005 8:29 pm |
|
|
|
| Scott Larson wrote: | | I receive one station at 98%. I would be getting a perfect stream from them.... except they send me a corrupt a52 packet every time they switch to local commercials. Heaven knows how they're doing this. ATSC data can get corrupted even before it gets transmitted although I'm sure it's not intentional. |
Mplayer has reported switches from HD to NTSC mode for some commercials on the transmission I'm using to get used to my new HD-3000 card. Maybe this is the problem? |
|
|
|
|
pcHDTV Forum Index -> General pcHDTV topics
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
|
All times are GMT - 7 Hours
Page 1 of 2
Goto page 1, 2 Next
|
|
|
|
|