我正在尝试制作一个录像机,为她的医生拍摄我伴侣癫痫发作的视频。由于它们是不可预测的,系统需要不断录制,例如保存为 15 分钟的剪辑。
该系统实际上是 debian,但我认为这是一个询问的好地方。
我有来自 raspivid 的 h264 原始视频和来自 USB 麦克风的声音。当我使用 arecord 进行测试时,Raspivid 正在运行,并且 USB 麦克风正在捕获声音,但是我使用 avconv 获得的任何文件都无法播放,它们只是在打开时显示一帧,然后完成。
raspivid -t 10000 -rot 270 -w 1280 -h 720 -b 3500000 -fps 30 -n -o - |
avconv -y -ac 2 -f alsa -ar 16000 -i plughw:1 -r 30 -i pipe:0 -filter_complex asyncts=compensate=1
-c:a ac3 -c:v copy -t 300 file%04d.mkv
附加信息:
pi@raspberrypi:~ $ raspivid -t 10000 -rot 270 -w 1280 -h 720 -b 3500000 -fps 30 -n -o - | ffmpeg -f alsa -i plughw:1 -i pipe:0 -codec copy -f segment -segment_time 900 file%04d.mkv
ffmpeg version N-82665-gbda6f29 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 4.9.2 (Raspbian 4.9.2-10)
configuration: --pkg-config-flags=--static --extra-cflags='-fPIC -I/root/ffmpeg_build/include' --extra-ldflags=-L/root/ffmpeg_build/lib --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree --enable-pic --extra-ldexeflags=-pie --enable-shared
libavutil 55. 41.101 / 55. 41.101
libavcodec 57. 66.108 / 57. 66.108
libavformat 57. 58.101 / 57. 58.101
libavdevice 57. 2.100 / 57. 2.100
libavfilter 6. 67.100 / 6. 67.100
libswscale 4. 3.101 / 4. 3.101
libswresample 2. 4.100 / 2. 4.100
libpostproc 54. 2.100 / 54. 2.100
Guessed Channel Layout for Input Stream #0.0 : stereo
Input #0, alsa, from 'plughw:1':
Duration: N/A, start: 1480449777.042259, bitrate: 1536 kb/s
Stream #0:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
Input #1, h264, from 'pipe:0':
Duration: N/A, bitrate: N/A
Stream #1:0: Video: h264 (High), yuv420p(progressive), 1280x720, 25 fps, 25 tbr, 1200k tbn, 50 tbc
Output #0, segment, to 'file%04d.mkv':
Metadata:
encoder : Lavf57.58.101
Stream #0:0: Video: h264 (High), yuv420p(progressive), 1280x720, q=2-31, 25 fps, 25 tbr, 1k tbn, 25 tbc
Stream #0:1: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
Stream mapping:
Stream #1:0 -> #0:0 (copy)
Stream #0:0 -> #0:1 (copy)
[alsa @ 0x80e062f0] ALSA buffer xrun.
[segment @ 0x80e8de90] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
[h264 @ 0x80e17620] Thread message queue blocking; consider raising the thread_queue_size option (current value: 8)
[alsa @ 0x80e062f0] Thread message queue blocking; consider raising the thread_queue_size option (current value: 8)
[alsa @ 0x80e062f0] ALSA buffer xrun.ime=00:04:40.88 bitrate=N/A speed=1.01x
[alsa @ 0x80e062f0] ALSA buffer xrun.ime=00:04:45.77 bitrate=N/A speed=1.01x
[alsa @ 0x80e062f0] ALSA buffer xrun.ime=00:04:50.28 bitrate=N/A speed=1.01x
[alsa @ 0x80e062f0] ALSA buffer xrun.ime=00:04:55.84 bitrate=N/A speed=1.01x
[alsa @ 0x80e062f0] ALSA buffer xrun.ime=00:17:48.47 bitrate=N/A speed= 1x
这会无限期地持续下去。我确实从中得到了一个文件,在尝试了不同的按键组合来终止命令后,它在我放弃后一段时间完成,生成的文件是 10 秒的视频,然后是最后一帧的几分钟和持续的音频。
答案1
您可以使用分段复用器:
raspivid <options> -o - | ffmpeg -f alsa -i plughw:1 -i pipe:0 -codec copy -f segment -segment_time 900 file%04d.mkv
- 您可能需要添加
-sample_rate
和-channels
输入选项对于 ALSA 设备,但无需先尝试。