gpt4 book ai didi

video - gstreamer 记录

转载 作者:行者123 更新时间:2023-12-04 23:17:31 30 4
gpt4 key购买 nike

我使用以下命令从我的网络摄像头录制音频和视频

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

感谢您的帮助。

最佳答案

这就是你可以做的:(比如 900k 视频和 64k 音频。由于你想要 48kHz 采样,你需要提供至少 64Kbits 比特率)

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 ! ffmpegcolorspace ! ffenc_mpeg4 bitrate=900000 ! mux. \
autoaudiosrc ! audiorate ! audio/x-raw-int,rate=48000,channels=1,depth=16 ! queue ! \
audioconvert ! lamemp3enc bitrate=64 target=1 ! queue ! mux. avimux name=mux ! \
filesink location=video.avi

如果您希望获得更小的尺寸并且不介意 mp4,我建议将 ffenc_mp4 替换为 x264enc,将 avimux 替换为 mp4mux。
如果您将 x264enc 与任何其他多路复用器 [不是 mp4mux] 一起使用,请记住还要为 x264enc 设置属性 byte-stream=1。

获取任何元素类型的属性 gst-inspect
所以lamemp3enc信息可以通过做
消费税检查 lamemp3enc。

关于video - gstreamer 记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12822552/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com