Spela in TV i Linux

Det bästa programmet, i mitt tycke, att spela in DVB TV från kommandoraden är dvbstream (läs mer här nedan). Detta program gör också post-processing av inspelningen enklare.

Det minst resurskrävande uppnår man med "tzap" och dumpa tv strömmen via "/dev/dvb/adapter0/dvr0".

Se till att ha fungerande kanaler "cp ~/.mplayer/channels.conf ~/.tzap/channels.conf" eller scanna till fil som redigeras efter eget tycke. Så här ser en kanallista ut gällande Stockholm/Nackamasten:

SVT1:490000000:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_2_3:FEC_1_2:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_8:HIERARCHY_NONE:1019:1018:5770
SVT2:490000000:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_2_3:FEC_1_2:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_8:HIERARCHY_NONE:1029:1028:5510
Kunskapskanalen:490000000:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_2_3:FEC_1_2:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_8:HIERARCHY_NONE:1249:1248:1240
Barnkanalen:490000000:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_2_3:FEC_1_2:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_8:HIERARCHY_NONE:879:878:870
SVT24:490000000:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_2_3:FEC_1_2:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_8:HIERARCHY_NONE:879:878:870
TV4:642000000:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_2_3:FEC_NONE:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_8:HIERARCHY_NONE:1049:1048:6110
TV6:642000000:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_2_3:FEC_1_2:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_8:HIERARCHY_NONE:1079:1078:1070

Denna kanallista funkar både för tzap och mplayer.

Enkel uppspelning

För att bara titta på TV är det enklast, via en terminal skriva:

mplayer dvb://"SVT1"

För att deinterlaca (ta bort uppdelningen i fält) och cacha lite innan uppspelning kan man använda följade:

mplayer -cache 2048 -vf pp=l5 dvb://"SVT1"

 

Kortfattad enkel inspelning med tzap

Starta detta i en terminal

tzap -r "SVT2" >> /dev/null

Dumpa i en annan terminal

cat /dev/dvb/adapter0/dvr0 > inspelning.mpg

Gör om DVB-t strömmen till MPEG-PS

mencoder -oac lavc -ovc lavc -of mpeg -mpegopts format=dvd -vf scale=720:576,harddup -srate 48000 -lavcopts vcodec=mpeg2video:vrc_buf_size=1835:vrc_maxrate=9800:vbitrate=5000:keyint=15:acodec=ac3:abitrate=192:aspect=16/9 -ofps 25 $INPUT_FILE -o $OUTPUT_FILE

Eller en enklare variant

mencoder -of mpeg -ni -mpegopts format=dvd:vbitrate=9000 -o inspeling_mpeg-ps.mpg -oac copy -ovc copy inspelning.mpg

Redigera filen med gopedit (installera source qt3 och mpeg2-4 libs)

http://gopdit.ath.cx/

Mer avancerat inspelningskommando lämplig för script

Spela in en timme (-n 3600) från Kunskapskanalen direkt med dvbstream.

dvbstream -qam 64 -cr 2_3 -gi 8 -bw 8 -tm 8 -f 490000000 -ps -n 3600 -o 879 878 > masterverk_kk_081116.ts
...
dvbstream v0.6 - (C) Dave Chapman 2001-2004
Released under the GPL.
Latest version available from http://www.linuxstb.org/
Tuning to 490000000 Hz
Using DVB card "DiBcom 7000PC", freq=490000000
tuning DVB-T (in United Kingdom) to 490000000 Hz, Bandwidth: 8
Getting frontend status
Event: Frequency: 490000000
Bit error rate: 2097151
Signal strength: 40848
SNR: 0
UNC: 0
FE_STATUS: FE_HAS_SIGNAL FE_HAS_LOCK FE_HAS_CARRIER FE_HAS_VITERBI FE_HAS_SYNC
dvbstream will stop after 3300 seconds (55 minutes)
Output to stdout
Streaming 2 streams
Audiostream: Layer: 2 BRate: 256 kb/s Freq: 48.0 kHz
Videostream: ASPECT: 16:9 Size = 720x576 FRate: 25 fps BRate: 15.00 Mbit/s

Detta kommando drar bara ca 0.7% av CPU i ett 2.4 GHz system.

dvbstream inställningar för olika kanaler

Ett enkel shell script för att spela in TV (kanalerna är för Stockholm Nacka eller Marieberg)

#!/bin/sh
-c 0 (/dev/dvb/adapter0)
-c 1 (/dev/dvb/adapter1)
DVBS="/usr/bin/dvbstream"
DUR=ARG1
OUT=ARG2
SVT1="-c 0 -qam 64 -cr 2_3 -gi 8 -bw 8 -tm 8 -f 490000000 -ps -n $DUR -o 1019 1018 > $OUT"
SVT2="-c 0 -qam 64 -cr 2_3 -gi 8 -bw 8 -tm 8 -f 490000000 -ps -n $DUR -o 1029 1028 > $OUT"
Barnkanalen="-c 0 -qam 64 -cr 2_3 -gi 8 -bw 8 -tm 8 -f 490000000 -ps -n $DUR -o 879 878 > $OUT"
SVT24="-c 0 -qam 64 -cr 2_3 -gi 8 -bw 8 -tm 8 -f 490000000 -ps -n $DUR -o 1249 1248 > $OUT"
# SVT har slutat sända HD TV över DVB-T!
#SVTHD="-c 0 -qam 64 -cr 2_3 -gi 32 -bw 8 -tm 8 -f 730000000 -ps -n $DUR -o 619 618> $OUT"
TV4="-c 0 -qam 64 -cr 2_3 -gi 8 -bw 8 -tm 8 -f 642000000 -ps -n $DUR -o 1049 1048 > $OUT"
TV6="-c 0 -qam 64 -cr 2_3 -gi 8 -bw 8 -tm 8 -f 642000000 -ps -n $DUR -o 1079 1078 > $OUT"

Spara denna som inspelning.sh och kör med kommandot

sh scriptnamn.sh inspelningslängd utfil.mpg

 

Perl script för direktinspelning

 

#!/usr/bin/perl
# rec-direct
# Hans E Andersson, 2008-11-17 05.04.30
my $DVBS="/usr/bin/dvbstream";
# my $ARGS="-c 0 -ps";
# -c 0 (/dev/dvb/adapter0)
# -c 1 (/dev/dvb/adapter1)

print "*************************************************\n";
print "Kanal väljare\n";
print "*************************************************\n";
print qq|SVT1
SVT2
Barnkanalen
SVT24
TV4
TV6
*************************************************
Välj kanal (hela namnet): |;
my $CHAN = <STDIN>;
chomp($CHAN);
print $CHAN;

print "*************************************************\n";
print "Längd i min: ";
my $DUR = <STDIN>;
chomp($DUR);
$DUR = $DUR * 60;
print "*************************************************\n";

print "*************************************************\n";
print "Utfil (my_rec.mpg): ";
my $OUT = <STDIN>;
chomp($OUT);
$OUT = "/srv/media/TV/REC/$OUT";
if (-e $OUT) {
chdir("/srv/media/TV/REC/");
print system("ls -1");
print "\nFilen finns redan, annat namn: ";
my $OUT = <STDIN>;
chomp($OUT);
$OUT = "/srv/media/TV/REC/$OUT";
}
#print "$OUT";
print "*************************************************\n";



my $REC = "";
if ($CHAN eq "SVT1") {
$REC="-c 0 -qam 64 -cr 2_3 -gi 8 -bw 8 -tm 8 -f 490000000 -ps -n $DUR -o 1019 1018 > $OUT";
}
if ($CHAN eq "SVT2") {
$REC="-c 0 -qam 64 -cr 2_3 -gi 8 -bw 8 -tm 8 -f 490000000 -ps -n $DUR -o 1029 1028 > $OUT";
}
if ($CHAN eq "Barnkanalen") {
$REC="-c 0 -qam 64 -cr 2_3 -gi 8 -bw 8 -tm 8 -f 490000000 -ps -n $DUR -o 879 878 > $OUT";
}
if ($CHAN eq "SVT24") {
$REC="-c 0 -qam 64 -cr 2_3 -gi 8 -bw 8 -tm 8 -f 490000000 -ps -n $DUR -o 1249 1248 > $OUT";
}

# Denna funkar inte längre!
# SVT slutade sända HD över DVB-T den 1 mars 2010 #if ($CHAN eq "SVTHD") { #$REC="-c 0 -qam 64 -cr 2_3 -gi 32 -bw 8 -tm 8 -f 730000000 -ps -n $DUR -o 619 618> $OUT"; #} if ($CHAN eq "TV4") { $REC="-c 0 -qam 64 -cr 2_3 -gi 8 -bw 8 -tm 8 -f 642000000 -ps -n $DUR -o 1049 1048 > $OUT"; } if ($CHAN eq "TV6") { $REC="-c 0 -qam 64 -cr 2_3 -gi 8 -bw 8 -tm 8 -f 642000000 -ps -n $DUR -o 1079 1078 > $OUT"; } if (!$REC) { print "Ingen kanal vald, avslutar nu!\n"; exit; } #Annars spelar vi in else { print "Spelar in $CHAN i $DUR sekunder\n"; print "Kommando: $DVBS $REC\n"; system("$DVBS $REC"); my $size = system("du -sh $OUT"); print "Inspelingen avslutad\n"; exit; }

 

TV Guider

http://tvsajten.com/tv

http://tv.swedb.se/xmltv/

http://xmltv.org/wiki/

http://converter.xmltv.se/

Syntax för XMLTV

http://tv.swedb.se/content/view/55/48/

Data Layout

Data is stored in a number of separate gzipped xml-files that can be downloaded from an http-server. To download data, you should start by retrieving the root-url. For tv.swedb.se, the root-url is http://tv.swedb.se/xmltv/channels.xml.gz. The root-url for Sweden will likely remain the same for the foreseeable future, but there might be data-sources available in the future, so you should make the root-url user configurable.

This file describes which channels are available and where data can be found for each channel. A typical entry looks like this:

<channel id="svt1.svt.se">
<display-name lang="sv">SVT1</display-name>
<base-url>http://xmltv.tvsajten.com/xmltv/</base-url>
<icon src ="http://xmltv.tvsajten.com/chanlogos/svt1.svt.se.png"/>
</channel>

The contents of the channel-entry is the same as specified by the xmltv-dtd with the addition of the base-url element. The base-url specifies where data for this particular channel can be found. Note that one base-url is specified for each channel. Right now, all channels use the same base-url, but this might change in the future.

If a channel-entry specifies more than one base-url for the channel,
the grabber shall use the first base-url.

The actual programs for each channel are stored in one file per channel and day in the location specified by the base-url for the channel. The name of each file is <id>_<yyyy-mm-dd>.xml.gz. As an example, the data for SVT1 on July 2nd, 2006, can be found at:
http://xmltv.tvsajten.com/xmltv/svt1.svt.se_2006-07-02.xml.gz

Each of these files follow the xmltv dtd, with the exception that they don't contain any <channel> elements.

A valid xmltv file can be constructed from the above data by removing all base-url fields from channels.xml.gz and outputting the relevant channel-entries concatenated with the contents of all program-files with the first and last lines omitted.

 

Länkar

http://www.turtlespond.net/scripts/dvb-t.html

http://wiki.arts.usyd.edu.au/meta/index.php/Building_a_DVB_streaming_server

 


"Spela in TV i Linux", Hans E Andersson: 2008-11-16 23:09:19, ändrad: 2014-01-16 01:19:41

 

Copyright © 2005 - 2019 HEAP. Alla rätter förbehållna. Integritetspolicy