Forums » Tutorial and setups »
Script for analog V4L2 device support in TVH (via pipe:// mux)
Added by Diego Rivera almost 9 years ago
Hi, all!
In my setup, I have need to tune analog channels via Kodi/TVH, which is currently not supported in TVHeadEnd. My solution was to make use of the pipe:// mux capability, and the attached script. The script supports indicating multiple sources, and round-robins through them until it's able to lock one (using flock). Once that's done, it then launches VLC command-line for streaming the output. I tried to use ffmpeg (and indeed the command is commented out in the script), but stream synchronization issues proved challenging, and I didn't know how to address them.
This script however requires the presence of VLC (cvlc, really) and IPTV. Here are the setup steps
- Make sure VLC is installed, and cvlc is in the path
- Make sure ivtv-utils is installed, and ivtv-tune is in the path
- Make sure the script is in the path, and works fine from the command-line (instructions below)
- Define a new IPTV Network in which the muxes would live for each channel I wished to support (this will be improved upon later, for now bear with me)
- Define a new MUX for each channel on that network, with the URL being of the pipe:// variety, and triggering the invocation of the script (with -o - for stdout output). Let the MUX "scan"
- Here's the line from my setup:
pipe://capture-analog -c <channel> -s /dev/video1 -o -
- Here's the line from my setup:
- Once each MUX has been scanned, its named service should appear on the "Services" tab - simply map each service to its (set of) channels like you normally would
- If the services don't appear, then check the TVH logs - it's likely the script isn't on the path, or there's a typo somewhere. Simply fix it, then set the MUX's scan status to "PEND" (editing the MUX), and it'll re-attempt the scan. Once the scan is successful, the service will show up.
- Voliá! You're done!
The attached script uses simple round-robin logic to iterate over whatever devices are available until one is successfully "_acquired_" (i.e. locked via flock). Once that happens, then that device will be tuned to the given channel, and its output will be written out to wherever the "-o" option (see below) points, encoded to an MPEGTS stream (MPEG2/AC3/TS).
The script can use a configuration file in /etc/default/capture-analog.conf. Please note that if you decide to name the script something else, that configuration file's name must also match the script's new name (i.e. ${scriptName}.conf), but must always reside in /etc/default. In the configurations, a single SOURCES="" line is supported, where you may specify which devices (i.e. /dev/video0, /dev/video1, etc.) the script will use by default (can be separated by commas or spaces). The devices will be tried in order. The script will not try the same device twice.
Finally, if no "SOURCES" line is present, or its contents are empty (all-spaces, etc.), then devices will be discovered via find command (specifically, find /dev/video* -type c).
The script itself accepts the following command-line arguments:
- -s devices: the list of devices to consider as candidates (same syntax as SOURCES, above. Comma-separated so be mindful of that)
- This overrides the value from the configuration file
- -c channel: the channel to which you wish to tune (mutually exclusive with -f)
- -t table: the tuning table to use (not used if -f is in use)
- -f frequency: the frequency to which you wish to tune (mutually exclusive with -c)
- -o output: the file to which output will be written (use
-
for stdout, this is what TVH needs, the default is stdout) - -g: enable trace mode, showing every instruction as it's executed
- -h: help message
- -?: help message
Interestingly, this script can also be used to display the feed from cameras (as long as they're V4L2 devices as /dev/video*), simply point it at the device and don't include tuning information (-c/-t, or -f).
Hope this works! And thanks to the TVH team for all the great work on TVHeadEnd!!
capture-analog (6.53 KB) capture-analog | Script to capture from analog tuners and V4L2 devices |
Replies (45)
RE: Script for analog V4L2 device support in TVH (via pipe:// mux) - Added by Diego Rivera over 8 years ago
You're right. There's a bug in the script. Please find an updated version attached.
This should cover it.
This script also removes the numeric-only check for channel names, which I forgot existed!
Now if a channel is named in a frequency table, it can be tuned.
Cheers!
capture-analog (10.9 KB) capture-analog | Updated Script |
RE: Script for analog V4L2 device support in TVH (via pipe:// mux) - Added by fa1 fa1 over 8 years ago
Great!
Thanks!
RE: Script for analog V4L2 device support in TVH (via pipe:// mux) - Added by David Blackeby over 8 years ago
OK installed the new script, and the command changing the table now doesn't throw an error, however I still think there are problems with the script
Running:
./capture-analog -t europe-west -c 68 -s /dev/video0 -o sky.mpg
Still shows that its using frequency 487.250Mhz rather than 847.250 which is what channel 68 should be using
SOURCES=[/dev/video0]
Using frequency table [europe-west]
Will tune to channel [68] (table=europe-west)
Begin capture from /dev/video0 (VBI=none AUDIO=hw:1,0 TUNER=true)
Querying audio capabilities for [hw:1,0]...
/dev/video0: 487.250 MHz
ivtv-tune -t europe-west -l
Channels/Frequencies (MHz) for 'europe-west':
E2 48.250
E3 55.250
E4 62.250
....
....
67 839.250
68 847.250
69 855.250
I tried falling back and using the -f command (with the full frequency, however it still errors
./capture-analog -f 847.250 -s /dev/video0 -o sky.mpg
ERROR: Frequency specification [847.250] is not valid
RE: Script for analog V4L2 device support in TVH (via pipe:// mux) - Added by Diego Rivera over 8 years ago
Try this version. This one should get you sailing smoothly.
Cheers!
capture-analog (10.8 KB) capture-analog | Updated script |
RE: Script for analog V4L2 device support in TVH (via pipe:// mux) - Added by Yakumo Fuji over 8 years ago
Hi I am trying to get this working but I have run in to some very annoying issues.
If i try to use ffmpeg conversion i get the following -->capture-analog -t europe-west -c E7 -s /dev/video1 -o -
0x79c540] ioctl(VIDIOC_G_PARM): Invalid argument
SOURCES=[/dev/video1]
Using frequency table [europe-west]
Will tune to channel [E7] (table=europe-west)
find: ‘/video4linux’: No such file or directory
find: ‘/lost+found’: Permission denied
find: ‘/tmp/systemd-private-2f22e0c0007649cea449ab2a247f039c-systemd-timesyncd.service-DRzg6N’: Permission denied
find: ‘/tmp/systemd-private-2f22e0c0007649cea449ab2a247f039c-rtkit-daemon.service-V9mSC1’: Permission denied
find: ‘/tmp/systemd-private-2f22e0c0007649cea449ab2a247f039c-colord.service-D8u7R9’: Permission denied
find: ‘/tmp/pulse-PKdhtXMmr18n’: Permission denied
find: ‘/run/wpa_supplicant’: Permission denied
find: ‘/run/sudo’: Permission denied
find: ‘/run/udisks2’: Permission denied
find: ‘/run/gdm3’: Permission denied
find: ‘/run/watershed’: Permission denied
find: ‘/run/lvm’: Permission denied
find: ‘/dev/sundtek’: Permission denied
find: ‘/boot/efi’: Permission denied
find: ‘/boot/lost+found’: Permission denied
find: ‘/root’: Permission denied
Begin capture from /dev/video1 (VBI=none AUDIO=hw:0,0 TUNER=true)
Querying audio capabilities for [hw:0,0]...
+ tune_device /dev/video1
+ local DEVICE=/usr/bin/capture-analog
+ local TUNING_FLAG=
+ local TABLE_FLAG=
+ true
+ true
+ TUNING_FLAG='-c E7'
+ false
+ true
+ TABLE_FLAG='-t europe-west'
+ /usr/bin/ivtv-tune -t europe-west -c E7 -d /dev/video1
/dev/video1: 189.250 MHz (Signal Detected)
+ /usr/bin/ffmpeg -r 30000/1001 -f v4l2 -i /dev/video1 -f alsa -ac 2 -ar 192000 -i hw:0,0 -f mpegts -c:v mpeg2video -b:v 8000k -filter:v yadif=0:-1:0 -c:a ac3 -b:a 224k -y -
ffmpeg version 2.8.6-1ubuntu2 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 5.3.1 (Ubuntu 5.3.1-11ubuntu1) 20160311
configuration: --prefix=/usr --extra-version=1ubuntu2 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-libx264 --enable-libopencv
libavutil 54. 31.100 / 54. 31.100
libavcodec 56. 60.100 / 56. 60.100
libavformat 56. 40.101 / 56. 40.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 40.101 / 5. 40.101
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.101 / 1. 2.101
libpostproc 53. 3.100 / 53. 3.100
[video4linux2,v4l2
/dev/video1: Invalid argument
+ set +x
@
I can't figure out what is causing this to happen. (But I suspect something in ffmpeg v4l2 conversion.)
If i use the E vlc option it fires up briefly and I get sound from my speakers (should I get that) and then it crashes ->
capture-analog -E vlc -t europe-west -c E7 -s /dev/video1 -o -
SOURCES=[/dev/video1]
Using frequency table [europe-west]
Will tune to channel [E7] (table=europe-west)
find: ‘/video4linux’: No such file or directory
find: ‘/lost+found’: Permission denied
find: ‘/tmp/systemd-private-2f22e0c0007649cea449ab2a247f039c-systemd-timesyncd.service-DRzg6N’: Permission denied
find: ‘/tmp/systemd-private-2f22e0c0007649cea449ab2a247f039c-rtkit-daemon.service-V9mSC1’: Permission denied
find: ‘/tmp/systemd-private-2f22e0c0007649cea449ab2a247f039c-colord.service-D8u7R9’: Permission denied
find: ‘/tmp/pulse-PKdhtXMmr18n’: Permission denied
find: ‘/run/wpa_supplicant’: Permission denied
find: ‘/run/sudo’: Permission denied
find: ‘/run/udisks2’: Permission denied
find: ‘/run/gdm3’: Permission denied
find: ‘/run/watershed’: Permission denied
find: ‘/run/lvm’: Permission denied
find: ‘/dev/sundtek’: Permission denied
find: ‘/boot/efi’: Permission denied
find: ‘/boot/lost+found’: Permission denied
find: ‘/root’: Permission denied
Begin capture from /dev/video1 (VBI=none AUDIO=hw:0,0 TUNER=true)
Querying audio capabilities for [hw:0,0]...
+ set +x
+ exec /usr/bin/cvlc -I dummy --quiet --live-caching 500 --v4l2-fps 0 --v4l2-dev /dev/video1 --v4l2-tuner-audio-mode 3 --v4l2-standard PAL-B/B1/G --v4l2-tuner-frequency 189250 --v4l2-chroma YUYV --input-slave alsa://hw:0,0 --sout-mux-caching 500 --sout '#transcode{vcodec=mp2v,vb=8000,vfilter=deinterlace,scale=Auto,acodec=a52,ab=224,channels=2,samplerate=192000}:file{mux=ts,dst=-}' --play-and-exit v4l2:///dev/video1
VLC media player 2.2.2 Weatherwax (revision 2.2.2-0-g6259d80)
/usr/bin/capture-analog: line 267: 20321 Floating point exception(core dumped) coproc COPROC exec "${CVLC}" -I dummy --quiet --live-caching 500 --v4l2-fps 0 --v4l2-dev ${SOURCE} ${SAP:+--v4l2-tuner-audio-mode ${SAP}} ${STANDARD:+--v4l2-standard ${STANDARD}} ${FREQUENCY:+--v4l2-tuner-frequency ${FREQUENCY%.*}} ${SOURCE_VBI:+--v4l2-vbidev ${SOURCE_VBI}} ${PIXEL_FORMAT:+--v4l2-chroma ${PIXEL_FORMAT}} ${SOURCE_AUDIO:+--input-slave alsa://${SOURCE_AUDIO}} --sout-mux-caching 500 --sout "${TRANSCODE}:file{mux=ts,dst=-}" --play-and-exit v4l2://${SOURCE}
/usr/bin/capture-analog: line 356: kill: (20321) - No such process
Copy stopped...
/usr/bin/capture-analog: line 356: kill: (20321) - No such process
vlc 2.2.2
ffmpeg version 2.8.6
Does anyone got any ideas?
Capture card is a Sundtek Media Pro I.
If i tune the card with v4l2-ctl and then open the device inside vlc it is working fine.
RE: Script for analog V4L2 device support in TVH (via pipe:// mux) - Added by Max Nordanåker over 8 years ago
Hi, I have been trying to get this script going for a couple of days with no luck. I think Im close though.
Tuner card : Sundtek MediaTV Pro 3 DVB-C
Computer : Raspberry Pi 2 running wheezy with Tvheadend 4.08
Error log in terminal:
root@tvheadend:/home/hts/.hts/tvheadend# ./capture-analog -t europe-west -c SE12 -s /dev/video0 -o -
SOURCES=[/dev/video0]
Using frequency table [europe-west]
Will tune to channel [SE12] (table=europe-west)
find: `/video4linux': No such file or directory
Begin capture from /dev/video0 (VBI=none AUDIO=hw:0,0 TUNER=true)
Querying audio capabilities for [hw:0,0]...
+ tune_device /dev/video0
+ local DEVICE=./capture-analog
+ local TUNING_FLAG=
+ local TABLE_FLAG=
+ true
+ true
+ TUNING_FLAG='-c SE12'
+ false
+ true
+ TABLE_FLAG='-t europe-west'
+ /usr/bin/ivtv-tune -t europe-west -c SE12 -d /dev/video0
/dev/video0: 238.250 MHz (Signal Detected)
+ /usr/bin/ffmpeg -r 30000/1001 -f v4l2 -i /dev/video0 -f alsa -ac -ar -i hw:0,0 -f mpegts -c:v mpeg2video -b:v 8000k -filter:v yadif=0:-1:0 -c:a ac3 -b:a 224k -y -
ffmpeg version 0.8.17-6:0.8.17-2+rpi1+deb7u1, Copyright (c) 2000-2014 the Libav developers
built on May 18 2016 02:40:46 with gcc 4.6.3
The ffmpeg program is only provided for script compatibility and will be removed
in a future release. It has been deprecated in the Libav project to allow for
incompatible command line syntax improvements in its replacement called avconv
(see Changelog for details). Please use avconv instead.
Unknown input format: 'v4l2'
+ set +x
Any ideas guys?
RE: Script for analog V4L2 device support in TVH (via pipe:// mux) - Added by Diego Rivera over 8 years ago
At this point, it looks as if that device doesn't work the same way the other USB devices I have available do. This makes it impossible for me to debug directly.
But I'm not 100% helpless. There's a "hidden" debug flag (-g) that you can use to produce more output, but it's not fully implemented in the version you guys have. Try this version (attached), instead. It adds some checks and makes sure the debug flag works as intended.
Post the full output with the "-g" flag on, and we can take it from there.
Cheers!
capture-analog (11.1 KB) capture-analog | Updated script version |
RE: Script for analog V4L2 device support in TVH (via pipe:// mux) - Added by Max Nordanåker over 8 years ago
Thanks for the help! I contacted Sundtek also, they said something about TVheadend not supporting dual mode tuners and that they are building their own streaming service, that will be available soon for Linux.
But I tried the new script and it said:
root@tvheadend:/home/hts/.hts/tvheadend# ./capture-analog -t europe-west -c SE12 -s /dev/video0 -o -g
SOURCES=[/dev/video0]
Using frequency table [europe-west]
Will tune to channel [SE12] (table=europe-west)
Device [/dev/video0] is not a valid video device, skipping
root@tvheadend:/home/hts/.hts/tvheadend#
root@tvheadend:/home/hts/.hts/tvheadend# ./capture-analog g
+ getopts :s:c:t:f:o:E:g OPT -g
+ false
+ TARGET=
+ false
+ '[' -z '' ']'
+ err 'No devices specified, will attempt to discover them'
+ say 'No devices specified, will attempt to discover them'
+ echo -e 'No devices specified, will attempt to discover them'
No devices specified, will attempt to discover them
+ find /sys/class/video4linux -mindepth 1 -maxdepth 1 -name 'video*' -type l -printf '%f\n'
+ sed -e 's;^;/dev/;g'
+ paste -sd , -
+ sort
+ SOURCES=
+ IFS=', '
+ read -r -a SOURCES
+ '[' 0 -lt 1 ']'
+ fail 'No sources found or specified'
+ err 'ERROR: No sources found or specified'
+ say 'ERROR: No sources found or specified'
+ echo -e 'ERROR: No sources found or specified'
ERROR: No sources found or specified
+ exit 1
root@tvheadend:/home/hts/.hts/tvheadend#
RE: Script for analog V4L2 device support in TVH (via pipe:// mux) - Added by Diego Rivera over 8 years ago
Ok...I have a better idea of what's (not) going on here. First, you're right that TVH doesn't support dual-mode tuners. That's what this script addresses - it accesses the tuners directly using the Video4Linux2 API and command-line utilities to produce a stream that TVH can then propagate "outwards". In that respect, the tuners aren't even accessed directly by TVH.
Second, it appears the tuner either doesn't have drivers for V4L2, or names the devices something other than /dev/videoX. Can you run the following commands, and tell me their output?
- List the V4L devices that are available via v4l API
v4l2-ctl --list-devices
- List all the info V4L knows about any video capture devices
v4l2-ctl --all
- List the V4L devices that are available via /sys
find /sys/class/video4linux -mindepth 1 -maxdepth 1
This info will help me in making any adjustments to the script to support your stuff, assuming V4L supports the device to begin with.
Cheers!
RE: Script for analog V4L2 device support in TVH (via pipe:// mux) - Added by Max Nordanåker over 8 years ago
Here is the output I got when running the commands:
root@tvheadend:/home/pi# v4l2-ctl --list-devices
Sundtek MediaTV Pro 2k12 (usb-):
/dev/video0
/dev/radio0
/dev/vbi0
---------
root@tvheadend:/home/pi# v4l2-ctl --all
Driver Info (not using libv4l2):
Driver name : Sundtek
Card type : Sundtek MediaTV Pro 2k12
Bus info : usb-
Driver version: 4.0.0
Capabilities : 0x84030001
Video Capture
Tuner
Audio
Streaming
Device Capabilities
Device Caps : 0x04030001
Video Capture
Tuner
Audio
Streaming
Frequency for tuner 0: 3924 (245.250000 MHz)
Tuner 0:
Name : Tuner
Capabilities : 62.5 kHz multi-standard stereo
Frequency range : 44.000 MHz - 958.000 MHz
Signal strength/AFC : 100%/0
Current audio mode : mono
Available subchannels:
Video input : 0 (Television: ok)
Audio input : 0 (TV)
Video Standard = 0x00000007
PAL-B/B1/G
Format Video Capture:
Width/Height : 720/576
Pixel Format : 'UYVY'
Field : Interlaced
Bytes per Line: 1440
Size Image : 829440
Colorspace : Broadcast NTSC/PAL (SMPTE170M/ITU601)
Format VBI Capture:
Sampling Rate : 27000000 Hz
Offset : 0 samples (0 secs after leading edge)
Samples per Line: 1440
Sample Format : GREY
Start 1st Field : 6
Count 1st Field : 17
Start 2nd Field : 317
Count 2nd Field : 12
Crop Capability Video Capture:
Bounds : Left 0, Top 0, Width 720, Height 576
Default : Left 0, Top 0, Width 720, Height 720
Pixel Aspect: 54/59
Crop: Left 0, Top 0, Width 720, Height 576
brightness (int) : min=0 max=100 step=1 default=50 value=50
contrast (int) : min=0 max=100 step=0 default=50 value=50
saturation (int) : min=0 max=100 step=1 default=50 value=50
volume (int) : min=0 max=255 step=1 default=219 value=219
mute (bool) : default=0 value=0
soft_volume (int) : min=0 max=100 step=1 default=100 value=0
treble (int) : min=0 max=100 step=1 default=100 value=0
--------
root@tvheadend:/home/pi# find /sys/class/video4linux -mindepth 1 -maxdepth 1
root@tvheadend:/home/pi#
RE: Script for analog V4L2 device support in TVH (via pipe:// mux) - Added by Diego Rivera over 8 years ago
Hmmm....for some reason the /sys interface isn't working as I expect it to with respect to V4L devices. Let me research this a little. The /sys interface is used to identify the audio device associated with the video input device. This way we can produce a single, homogenous stream that includes both audio (captured from the appropriate ALSA device) and videdo, turn it into an MPEG2 stream, and send it to TVHeadend.
As I said - I'll need to figure this out. In the mean time: what Linux (distro/version) are you using? Also, can you run these two commands to help me figure things out:
lsmod | grep -i v4l
lsmod | grep -i video
Cheers!
RE: Script for analog V4L2 device support in TVH (via pipe:// mux) - Added by Max Nordanåker over 8 years ago
Diego Rivera wrote:
Hmmm....for some reason the /sys interface isn't working as I expect it to with respect to V4L devices. Let me research this a little. The /sys interface is used to identify the audio device associated with the video input device. This way we can produce a single, homogenous stream that includes both audio (captured from the appropriate ALSA device) and videdo, turn it into an MPEG2 stream, and send it to TVHeadend.
As I said - I'll need to figure this out. In the mean time: what Linux (distro/version) are you using? Also, can you run these two commands to help me figure things out:
lsmod | grep -i v4l
lsmod | grep -i video
Cheers!
Hello! Have been away for a while.
When I run the commands I get:
root@headendserver:/home/hts/.hts/tvheadend# lsmod | grep -i v4l
root@headendserver:/home/hts/.hts/tvheadend# lsmod | grep -i video
This is my setup:
Raspberry Pi with Raspbian Jessie Lite
-- Max
RE: Script for analog V4L2 device support in TVH (via pipe:// mux) - Added by Diego Rivera over 8 years ago
Maybe this device requires specific firmware to be loaded prior to use? Maybe a userland service needs to be started or configured?
Without one of these devices to test with, it's impossible for me to debug the issue if the device behaves differently from the other "more standard" devices out there. I have tested this script with two different Hauppauge devices, and others have had success with other devices.
Not sure what I can do to help here...
RE: Script for analog V4L2 device support in TVH (via pipe:// mux) - Added by Max Nordanåker over 8 years ago
No problem. Did see that it was an hassel to get the analog output working or just to tune the analog channels manually so I ended up ordering the Hauppauge-tuner instead.
RE: Script for analog V4L2 device support in TVH (via pipe:// mux) - Added by Michal Smolinsky about 8 years ago
Hello.
Thank you for the good solution to work with analog tuners.
I have problems when switching channels.
My configuration:
Ubuntu 14.04 trusty, HTS Tvheadend 4.0.9-7~gbf276e0~trusty, Hauppauge WinTV PVR-150.
===
ffmpeg version N-80901-gfebc862 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04.3)
===
VLC media player 2.1.6 Rincewind (revision 2.1.6-0-gea01d28)
===
http://prntscr.com/c5cu5z
http://prntscr.com/c5cut8
http://prntscr.com/c5cv0e
http://prntscr.com/c5cvsi
http://paste.ubuntu.com/23052711/
RE: Script for analog V4L2 device support in TVH (via pipe:// mux) - Added by Diego Rivera about 8 years ago
Edit the network's configuration and set the "Max Input Streams" value to 1. This value controls how many concurrent streams you can obtain from a single "network" (tuner, really). Thus, if you have a single tuner, in this mode, you have to explicitly tell TVH that it can only obtain a single stream at a time from it. In this case, a single instance of the analog capture script can be used at any given time, and thus the network must be told this, lest it try to start more than one instance, which is what's happening here (see line 143 where it complains that the device is locked...the process locking it is the previous version of the script itself).
RE: Script for analog V4L2 device support in TVH (via pipe:// mux) - Added by Max Nordanåker about 8 years ago
Diego Rivera wrote:
Maybe this device requires specific firmware to be loaded prior to use? Maybe a userland service needs to be started or configured?
Without one of these devices to test with, it's impossible for me to debug the issue if the device behaves differently from the other "more standard" devices out there. I have tested this script with two different Hauppauge devices, and others have had success with other devices.
Not sure what I can do to help here...
Hello again!
Back with another tuner (Hauppauge) and I think I'm close to figure this out.
Raspberry Pi 3, Wheezy, Kernel 3.19.
VLC, FFmpeg, ivtv-tune and v4l-utils are installed.
root@tvheadend:/home/hts/.hts/tvheadend# ./capture-analog -t europe-west -c SE12 -s /dev/video0 -o
SOURCES=[/dev/video0]
Using frequency table [europe-west]
Will tune to channel [SE12] (table=europe-west)
Begin capture from /dev/video0 (TUNER=true)
+ tune_device /dev/video0
+ local DEVICE=./capture-analog
+ local TUNING_FLAG=
+ local TABLE_FLAG=
+ true
+ true
+ TUNING_FLAG='-c SE12'
+ false
+ true
+ TABLE_FLAG='-t europe-west'
+ /usr/bin/ivtv-tune -t europe-west -c SE12 -d /dev/video0
/dev/video0: 238.250 MHz (Signal Detected)
+ cat /dev/video0
+ /usr/bin/ffmpeg -i pipe:///dev/stdin -f mpegts -c:v copy -c:a ac3 -b:a 224k -
ffmpeg version 0.8.17-6:0.8.17-2+rpi1+deb7u2, Copyright (c) 2000-2014 the Libav developers
built on Jun 18 2016 00:05:51 with gcc 4.6.3
The ffmpeg program is only provided for script compatibility and will be removed
in a future release. It has been deprecated in the Libav project to allow for
incompatible command line syntax improvements in its replacement called avconv
(see Changelog for details). Please use avconv instead.
[mpeg 0x1583660] max_analyze_duration reached
0x1583660] Estimating duration from bitrate, this may be inaccurate
[mpeg
Input #0, mpeg, from 'pipe:///dev/stdin':
Duration: N/A, start: 0.169356, bitrate: 8224 kb/s
Stream #0.0[0x1e0]: Video: mpeg2video (Main), yuv420p, 720x480 [PAR 8:9 DAR 4:3], 8000 kb/s, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
Stream #0.1[0x1c0]: Audio: mp2, 48000 Hz, stereo, s16, 224 kb/s
Unrecognized option 'c:v'
Failed to set value 'copy' for option 'c:v'
+ set +x
root@tvheadend:/home/hts/.hts/tvheadend#
RE: Script for analog V4L2 device support in TVH (via pipe:// mux) - Added by Bavo Verlackt almost 8 years ago
I will give it a try with the sundtek mediaTV pro (treiber 31 dec 2016), RPI 2, Archlinux, TVHeadend 4.1 and Kodi jarvis. Is there an update on this tuner or did you stop looking after the above conversation ended?
RE: Script for analog V4L2 device support in TVH (via pipe:// mux) - Added by nf gb almost 6 years ago
Bavo Verlackt wrote:
I will give it a try with the sundtek mediaTV pro (treiber 31 dec 2016), RPI 2, Archlinux, TVHeadend 4.1 and Kodi jarvis. Is there an update on this tuner or did you stop looking after the above conversation ended?
Hi, have you managed to use this tuner with analog TV? I've used the same tuner with the script with some changes, however in a raspberry pi 2 it is too slow. With a nanopi m4 can't get the audio, but I think this is a vlc/ffmpeg problem because I can capture both video and audio with mencoder. The problem is I don't know how to output to MPEG-TS from mencoder.
RE: Script for analog V4L2 device support in TVH (via pipe:// mux) - Added by Tobi Habich over 2 years ago
Very interesting work and nice to see that it is possible to widen the TVH capabilities by adding external scripts.
I was in a similiar situation when I wanted to make wilmaa (swiss IPTV provider) work with TVH in a reliable way.
When I read your description about the script I got reminded of many obstacles I had to tackle when I was creating my wilmaa solution.
One almost funny thing is, that I tried first with a VLC command line but did not get it to work. Therefore I switched to ffmpeg and (of course) I had synchronisation isuues for a long long time. So while you started with ffmpeg and ended up using VLC, I was doinig it the exact other way around. I failed on VLC but managed with ffmpeg. This is actually why I'm writing this. I want to share my ffmpg input and output filters with you, hoping this might safe some time in case you want to retry with ffmpeg at some point again. At the same time, I'll try to use VLC for my stuff and the way you create the VLC command line will be very helpful for me.
So here are the input and output sections of my finally well working ffmpeg command line. The audio and video of the output are perfectly in sync.....
Input:
pipe:///usr/bin/ffmpeg -loglevel fatal -reconnect 1 -reconnect_at_eof 1 -reconnect_streamed 1 -reconnect_delay_max 0 -err_detect ignore_err -analyzeduration 1 -probesize 32 -copyts -r 25
-i VIDEOSTREAM -i AUDIOSTREAM
Output:
-c:v copy -bufsize 5M -maxrate 10M -qmin 0 -g 250 -bf 1 -c:a copy -f tee -map 0:v -map 1:a -f mpegts pipe:1
The important parts to get the synchronisation issue solved are:
-copyts:
'at the input (the ts here stands for timestamp not for transport stream - just mentioning this because this confused me quite some time)
-r 25:
'leads to rewritten timestamps (why the copyts is still needed is something I can't explain but I can tell it is needed; you'll probably need to set it to r 30)
-f tee and map:
'first have to seperate streams (individual audio and video streams) and then combine them again (this is done with "tee" and the "map" commands in the output filer section; without seperating and a certain way of rejoining I had no success ever)
Maybe this safes time for someone....
- « Previous
- 1
- 2
- Next »