我使用以下命令从我的网络摄像头录制音频和视频
gst-launch-0.10 v4l2src ! video/x-raw-yuv,width=640,height=480,framerate=30/1 ! \
tee name=t_vid ! queue ! videoflip method=horizontal-flip ! \
xvimagesink sync=false t_vid. ! queue ! \
videorate ! video/x-raw-yuv,framerate=30/1 ! queue ! mux. \
autoaudiosrc ! audiorate ! audio/x-raw-int,rate=48000,channels=1,depth=16 ! queue ! \
audioconvert ! queue ! mux. avimux name=mux ! \
filesink location=video.avi
结果在流之间的同步性方面是正确的。但是 avi 文件非常大,因为那是未压缩的数据......你能告诉我如何减少记录的大小吗?请注意,我在录制后将音频和视频拆分为单独的文件进行处理。保持同步性至关重要。
* 编辑 *
我尝试使用 ffmpeg 使用以下命令压缩 avi 文件:
ffmpeg -i video.avi -vcodec msmpeg4v2 output.avi
但似乎比特率是无效的(因为它的原始数据不适用?)这是输出:
Input #0, avi, from 'video.avi':
Duration: 00:00:00.00, start: 0.000000, bitrate: -2147483 kb/s
Stream #0.0: Video: rawvideo, yuv420p, 640x480, 30 tbr, 30 tbn, 30 tbc
Stream #0.1: Audio: pcm_s16le, 48000 Hz, 1 channels, s16, 768 kb/s
[buffer @ 0xef57e0] w:640 h:480 pixfmt:yuv420p
Incompatible sample format 's16' for codec 'ac3', auto-selecting format 'flt'
[ac3 @ 0xedece0] channel_layout not specified
[ac3 @ 0xedece0] No channel layout specified. The encoder will guess the layout, but it might be incorrect.
[ac3 @ 0xedece0] invalid bit rate
Output #0, avi, to 'output.avi':
Stream #0.0: Video: msmpeg4v2, yuv420p, 640x480, q=2-31, 200 kb/s, 90k tbn, 30 tbc
Stream #0.1: Audio: ac3, 48000 Hz, mono, flt, 200 kb/s
Stream mapping:
Stream #0.0 -> #0.0
Stream #0.1 -> #0.1
Error while opening encoder for output stream #0.1 - maybe incorrect parameters such as bit_rate, rate, width or height
感谢您的帮助。