Home > FFmpeg, Linux > Capturing video input for authoring to DVD with Linux

Capturing video input for authoring to DVD with Linux

The goal that I am trying to achieve is to capture video from an external source and encode it into a format that will be easily authored to a DVD. I will cover the DVD authoring process in another article.
Since I am using Linux one obvious solution is to use ffmpeg which is what I am going to use.
My video source is a dvd player (via composite video out and RCA audio) and I’m capturing video with a Viewcast Osprey 230 (capturing via the composite video ) and audio via the motherboard onboard AC-97 line-in.

The Osprey 230 uses the Bt878 chipset and does have both audio and video capture capabilities but I have not yet had any success in actually capturing audio from the device so I’m using the motherboard onboard audio.

Here is the ffmpeg capture line that I am currently testing:

ffmpeg -y -t 01:08:52 -f oss -ac 1 -i /dev/dsp -f video4linux2 -r 30000/1001 -s 720×480 -i /dev/video -target ntsc-dvd -vcodec mpeg2video -ab 256k -acodec ac3 -r 30000/1001 -aspect 1.3333 -async 1 -b 3200k dv d19.mpg

Here are the explanations of the options I’m using and why I think I need them.

First let me mention my understanding of ffmpeg and how the parameters work. It is my understanding that you set the options for the input audio and/or video and output audio and/or video and output file by putting parameters directly before the -i (input audio and/or video), -acodec (audio codec output), -vcodec (video codec output) or the output file.

So you can have the same option multiple times but for different inputs and the final output, you can see for instance that I set the frame rate to 30000/1001 (29.97 fps for NTSC) for both the video input and the output file.

There are some options however that this doesn’t necessarily apply to such as the -y flag which only makes sense for the output file.

-y: overwrite output file without prompting, I’m testing various parameters so this makes sense at the moment.

-t 01:08:52: timed capture of one hour, eight minutes and 52 seconds, I don’t want to sit there waiting to hit ‘q’ to stop encoding so I’m setting the time to the length of my input video. I want to be able to compare output file size and quality so having the exact same length of video is helpful.

-f oss: Setting the audio input format to oss (Open Sound System), this appears to be my only real option as I don’t believe that ALSA is supported at this time except via the ALSA OSS emulation.

-ac 1: Set the audio input channels to one (mono) for the input device (/dev/dsp), haven’t been able to get stereo to work yet but for the audio that I’m working with it’s currently not important. I will attempt to find out why this doesn’t work in the future as I’m aware that I (or others) may want to have stereo audio.

-i /dev/dsp: Specify the audio input device (/dev/dsp(n) is the digital sampling and recording device for audio, this may take some trial and error if you have multiple audio capture devices ( I have two for instance /dev/dsp onboard AC-97 audio and /dev/dsp1 the Osprey 230 audio capture device).

-f video4linux2: Set the format for the input (/dev/video) to video4linux2 (out video capture driver).

-r 30000/1001: Set the frame rate at which we want to capture our video from (/dev/video). This translates to an NTSC frame rate of 29.97fps.

-s 720×480: set the resolution size for the video input (/dev/video). I was using 640×480 which is what the max capture size is suppose to be for the Osprey 230 but I haven’t seen any problems with setting this to 720×480 which is what I would prefer for DVD output. Maybe there is some interpolation going on with the video4linux2 driver that I’m not seeing, I’ll have to investigate that further. NOTE: if I don’t set this then I get the following error: [video4linux2 @ 0x9e46990]Wrong size (0×0)

-target ntsc-dvd: set the target output for the video codec (-vcodec mpeg2video). So far this has yielded good output.

-vcodec mpeg2video: Setting the output video codec to mpeg2video, this would be MPEG 2 video which should be able to be put on a DVD without transcoding since DVD’s use MPEG 2 for the video stream.

-ab 256kb: Setting the audio bit rate for the output audio codec (-acodec ac3), this is probably higher than is needed (64kb would be sufficient) since the audio I am dealing with is primarily spoken word with little music but for future use this would probably be good.

-r 30000/1001: Setting the output video frame rate to for NTSC 29.97, my target output, this might not be necessary since I set the -target of the video codec to ntsc-dvd. Maybe these options would make more sense flip-flopped or just have one, probably should look into it.

-aspect 1.3333: Set the aspect ratio for the output video, I think this could also be 4:3 (4/3 = 1.3333). This is somewhat confusing since I’ve set the resolution size to 720×480 which is standard for DVD’s but 720×480 would in fact be and aspect ratio of 1.5. Standard (non widescreen) TV’s however use an aspect ratio of 4:3 or 1.3333 so the DVD aspect ratio of 1.5 (720×480) would get adjusted to fit the TV aspect ratio of 1.3333. So, maybe I should set my capture size to 640×480 and save myself some space? Again, have to look into this further as setting the input size to 640×480 might conflict with the -target ntsc-dvd setting for the video output codec. Confused yet? I am.

-async 1: This tells ffmpeg to try to sync the audio with the video once at the beginning, this seems to help keep the audio and video in sync, without this the audio tended to drift away from the video and started to look like a poorly dubbed film.

-b 3200k: Set the bit rate for the output video, this was my attempt at making the output video files a little smaller.

dvd19.mpg: The name of the output file.

So the resulting file that I have is 1.8GB for one hour, eight minutes and 52 seconds of video, seems to be of decent quality and requires minimal modification for DVD authoring.

For Hardware and Software specifications please see below:

Testing Hardware:
Capture Card:
Viewcast Osprey 230
Input source: Philips DVP5982 DVD Player
Computer: Dell Precision 530
Specs:
Processor(s): 2 32bit Physical CPU’s

  1. Intel(R) XEON(TM) CPU 1.80GHz
  2. Intel(R) XEON(TM) CPU 1.80GHz

Memory: 1 GB Total Memory

  1. 256MiB RIMM RDRAM RAMBUS 400 MHz (2.5 ns)
  2. 256MiB RIMM RDRAM RAMBUS 400 MHz (2.5 ns)
  3. 256MiB RIMM RDRAM RAMBUS 400 MHz (2.5 ns)
  4. 256MiB RIMM RDRAM RAMBUS 400 MHz (2.5 ns)

Hard Disk(s):

  1. 36GB SCSI Disk – IBM IC35L036UWDY10-0

Optical Disk:

  1. DVD reader – HL-DT-ST RW/DVD GCC-4521B
  2. CD-ROM – Lite-On LTN486S 48x Max

Audio: Onboard Intel Corporation 82801BA/BAM AC’97 Audio Controller (rev 04)
Lan: Onboard 3Com Corporation 3c905C-TX/TX-M [Tornado] (rev 78)
Graphics Adapter: nVidia Corporation NV18 [GeForce4 MX 440 AGP 8x] (rev c1)
PCI Cards:

  1. Viewcast Osprey 230 ( Brooktree Corporation Bt878 Video Capture (rev 11) )
  2. Adaptec AIC-7892P U160/m SCSI storage controller

Testing Software:

Operating System: Ubuntu Linux 9.04

Kernel: Linux 2.6.28-13-generic #45-Ubuntu SMP Tue Jun 30 19:49:51 UTC 2009 i686 GNU/Linux

Capture Software:

ffmpeg: SVN-r19426

Configuration: –enable-libmp3lame –enable-libfaad –enable-libxvid –enable-libfaac –enable-gpl –enable-libvorbis –enable-libfaadbin –enable-libgsm –enable-pthreads –enable-postproc –enable-nonfree –enable-libtheora

libavutil 50. 3. 0 / 50. 3. 0
libavcodec 52.32. 0 / 52.32. 0
libavformat 52.36. 0 / 52.36. 0
libavdevice 52. 2. 0 / 52. 2. 0
libswscale 0. 7. 1 / 0. 7. 1
libpostproc 51. 2. 0 / 51. 2. 0
built on Jul 13 2009 16:08:32, gcc: 4.3.3

Support Software:

v4l2-ctrl: ivtv-utils 1.2.0-1

Kernel Modules (drivers):

v4l2_common:
description : misc helper functions for v4l2 device drivers
srcversion : 3CA2C700C624D5A395E16FC
vermagic : 2.6.28-13-generic SMP mod_unload modversions 586

bttv :
description : bttv – v4l/v4l2 driver module for bt848/878 based cards
srcversion : 97A8FA06F360905675E7702
vermagic : 2.6.28-13-generic SMP mod_unload modversions 586

  1. Kirby
    August 10th, 2009 at 10:00 | #1

    I was reading your post while having the same type of problem. I have figured out capturing both audio and video from my osprey 440 card. Thought maybe I could help you out if you haven’t figured this out yet. Feel free to send me an e-mail.

  2. ankit
    February 6th, 2010 at 13:38 | #2

    @Kirby
    can u plz tell me ur email id? i m facing similar prob and i will be grateful to u if u could provide any pointers….u can reach me at ankit_jain@ureach.com . I am using gstreamer (ubuntu9.04). I get the audio if i use the pipeline: gst-launch-0.10 alsasrc device=hw:1,0 ! audioconvert ! alsasink sync=false My prob is I can get the audio but its at 32000 sampling rate whereas the alsasrc tells the audioconvert that the sampling rate is 44100. so it appears for eg in a news video that the person is speaking at a very fast rate. thanks a lot in advance….

  1. No trackbacks yet.