我正在通过USB Terratec Grabster AV350(基于em2860芯片)捕捉视频。
播放时我没有成功获取音频。如果我用vlc或ffplay播放捕获的视频,我只有3秒钟的声音,然后对视频的其余部分保持沉默......
在捕获过程中,我没有收到任何错误。最后它表示捕获的视频和音频的大小......
我正在使用ffmpeg命令:
ffmpeg -f alsa -ac 2 -i hw:3 -f video4linux2 -i / dev / video0 -acodec ac3 -ab 128k -vcodec mpeg4 -b 6000k -r 25 test5.avi < / p>
日志是:
[alsa @ 0x9bcd420]Estimating duration from bitrate, this may be inaccurate
Input #0, alsa, from 'hw:3':
Duration: N/A, start: 69930.998994, bitrate: N/A
Stream #0.0: Audio: pcm_s16le, 44100 Hz, 2 channels, s16, 1411 kb/s
[video4linux2 @ 0x9bf5d30]Estimating duration from bitrate, this may be inaccurate
Input #1, video4linux2, from '/dev/video0':
Duration: N/A, start: 1307111377.654173, bitrate: -2147483 kb/s
Stream #1.0: Video: rawvideo, yuyv422, 720x576, -2147483 kb/s, 1000k tbr, 1000k tbn, 1000k tbc
[ac3 @ 0x9bf9590]No channel layout specified. The encoder will guess the layout, but it might be incorrect.
Output #0, avi, to 'test5.avi':
Metadata:
ISFT : Lavf52.64.2
Stream #0.0: Video: mpeg4, yuv420p, 720x576, q=2-31, 6000 kb/s, 25 tbn, 25 tbc
Stream #0.1: Audio: ac3, 44100 Hz, stereo, s16, 128 kb/s
Stream mapping:
Stream #1.0 -> #0.0
Stream #0.0 -> #0.1
Press [q] to stop encoding
frame= 1283 fps= 25 q=2.3 Lsize= 38677kB time=51.32 bitrate=6173.9kbits/s
**video:37755kB audio:846kB** global headers:0kB muxing overhead 0.198922%
如果我减少仅捕获音频的命令,则可以成功播放音频文件:
ffmpeg -f alsa -ac 2 -i hw:3,0 -acodec ac3 -ab 128k test5.avi
[alsa @ 0x8ede420]Estimating duration from bitrate, this may be inaccurate
Input #0, alsa, from 'hw:3,0':
Duration: N/A, start: 70395.998935, bitrate: N/A
Stream #0.0: Audio: pcm_s16le, 44100 Hz, 2 channels, s16, 1411 kb/s
[ac3 @ 0x8eebac0]No channel layout specified. The encoder will guess the layout, but it might be incorrect.
Output #0, avi, to 'test5.avi':
Metadata:
ISFT : Lavf52.64.2
Stream #0.0: Audio: ac3, 44100 Hz, stereo, s16, 128 kb/s
Stream mapping:
Stream #0.0 -> #0.0
Press [q] to stop encoding
size= 227kB time=13.62 bitrate= 136.8kbits/s
**video:0kB audio:213kB** global headers:0kB muxing overhead 6.902375%
如果我只运行命令进行视频捕获,那么vlc或ffplay可以成功播放视频:
ffmpeg -f video4linux2 -i / dev / video0 -vcodec mpeg4 -b 12000k -r 25 test5.avi
[video4linux2 @ 0x91d6420]Estimating duration from bitrate, this may be inaccurate
Input #0, video4linux2, from '/dev/video0':
Duration: N/A, start: 1307112044.025687, bitrate: -2147483 kb/s
Stream #0.0: Video: rawvideo, yuyv422, 720x576, -2147483 kb/s, 1000k tbr, 1000k tbn, 1000k tbc
Output #0, avi, to 'test5.avi':
Metadata:
ISFT : Lavf52.64.2
Stream #0.0: Video: mpeg4, yuv420p, 720x576, q=2-31, 12000 kb/s, 25 tbn, 25 tbc
Stream mapping:
Stream #0.0 -> #0.0
Press [q] to stop encoding
frame= 388 fps= 25 q=2.0 Lsize= 12963kB time=15.52 bitrate=6842.5kbits/s
**video:12949kB audio:0kB** global headers:0kB muxing overhead 0.114584%
我注意到的奇怪行为是,当我尝试捕获视频和音频时,我无法再捕获音频了, 除非我先拔下AV350。
G350位于卡3:
htpc@htpc-01:/proc/asound/G350/pcm0c$ more info
card: 3
device: 0
subdevice: 0
stream: CAPTURE
id: USB Audio
name: USB Audio
subname: subdevice #0
class: 0
subclass: 0
subdevices_count: 1
subdevices_avail: 1
操作系统是Linux 2.6.38-8-Ubuntu Natty Narwhal版本的通用
如何解决这个问题的任何帮助都会很棒......
谢谢!
答案 0 :(得分:1)
我正在做类似的事情,我使用了这个命令:
ffmpeg -y -f alsa -i default -f v4l2 -i /dev/video0 -acodec aac -strict -2 -ac 1 -b:a 64k -vcodec libx264 -b:v 300k -r 30 -g 30 prueba1.mp4
一开始我遇到了hw:3
组件的问题。而不是我放入default
,代码实际上工作。我希望这会有所帮助。
答案 1 :(得分:0)
我发现使用底部的命令可用于外部USB网络摄像头(我的目前是Logitech C310)。我在我的笔记本电脑上使用了这个命令,它已经内置了麦克风/网络摄像头,它仍然从我的C310中捕获了音频和视频。显然,更改/ dev / video0以满足您的需求。你可以使用
ls /dev/video*
在终端中查看您的操作系统已设置的视频捕获设备。
ffmpeg -f alsa -i default -itsoffset 00:00:00 -f video4linux2 -s 1280x720 -r 25 -i /dev/video0 out.avi
答案 2 :(得分:0)
适用于高质量视频:
ffmpeg -f alsa -ac 2 -i hw:1,0 -f video4linux2 -i /dev/video0 -acodec ac3 -ab
128k -f matroska -s 1280x720 -vcodec libx264 -preset ultrafast -qp 16 testsize.mkv