Transmitting mp4 video file
First we're going to need an mp4 video file. One can be downloaded from the internet, or an existing video can be converted with the following command:
ffmpeg -i input.avi -c:v mpeg4 -c:a aac -b:v 1024k -pix_fmt yuv420p output.mp4
The required video file can also be created by looping an image file:
ffmpeg -loop 1 -i ~/Pictures/testPattern.png -c:v mpeg4 -t 30 -pix_fmt yuv420p output.mp4
A sample test pattern can be downloaded here.
A video file can also be captured from and attached webcam and microphone.
First, list available video devices:
ubuntu@linuxsdr:~$ v4l2-ctl --list-devices
HP Webcam-50: HP Webcam-50 (usb-0000:00:1d.0-1.5):
/dev/video0
/dev/video1
Next, list audio devices:
ubuntu@linuxsdr:~$ arecord -l
**** List of CAPTURE Hardware Devices ****
card 1: PCH [HDA Intel PCH], device 0: 92HD87B2/4 Analog [92HD87B2/4 Analog]
Subdevices: 1/1
Subdevice #0: subdevice #0
Replacing /dev/video0 and hw:1,0 with your output from above, create the video with the following command:
ffmpeg -f v4l2 -i /dev/video0 -f alsa -i hw:1,0 -pix_fmt yuvj420p -level:v 4.1 -c:v mpeg4 -r 10 -b:v 1024k -c:a aac -strict -2 -ac 2 -ab 32k -ar 44100 -f mpegts output.mp4
The audio from the mic and video may not sync up nicely with the above command. If the audio is ahead of the video add -itsoffset <sec>
after the video input. If the video is ahead of the audio add the option after the audio input in the command. My audio was ahead of the video by a little more than a second so I'll use the command:
ffmpeg -f v4l2 -i /dev/video0 -itsoffset 1.15 -f alsa -i hw:1,0 -pix_fmt yuvj420p -level:v 4.1 -vcodec mpeg4 -r 10 -b:v 1024k -acodec aac -strict -2 -ac 2 -ab 32k -ar 44100 -f mpegts output.mp4
Once we have the video to transmit, the frequency and format needs to be determined.
I'm located in the U.S.A. and have only been able to receive NTSC AM with the tv's that I have, so that's what I'll be using here. If you're in a location that uses PAL try modes i, b, g, pal-fm, pal, or view the hacktv help dialog for a complete list.
The website otadtv.com has a list of the center frequencies of the analog tv stations. Select a channel that is not in use in your area. I'll be using channel 14 at 473 MHz in the UHF band.
Make sure the antenna connected to your radio is a fairly close to your tv antenna. I made an antenna for this using 8ft of coaxial cable following instructions from a video I found on youtube.
Transmit the video file with the following command:
hacktv -f 473000000 -m m -g 20 output.mp4
Increase gain as needed up to 47. Depending on the tv you're using to receive rescanning for channels may be required.
Transmitting live video stream
First, we'll create a udp stream on the local ip for the camera and mic. Locate addresses of video and audio input as in the example above and replace your devices in the following command:
ffmpeg -f v4l2 -i /dev/video0 -itsoffset 1.15 -f alsa -i hw:1,0 -pix_fmt yuvj420p -level:v 4.1 -vcodec mpeg4 -r 10 -b:v 1024k -acodec aac -strict -2 -ac 2 -ab 32k -ar 44100 -f mpegts udp://127.0.0.1:6575
Transmit video stream:
hacktv -f 473000000 -m m -g 20 udp://127.0.0.1:6575
Thanks !!