Rust Gstreamer encodebin在使用h.264编码时输出低比特率视频

Rust Gstreamer encodebin在使用h.264编码时输出低比特率视频,rust,gstreamer,video-processing,Rust,Gstreamer,Video Processing,我使用gstreamer的rust绑定来拍摄视频的前10秒,并将其制作成自己的视频。理想情况下,我想输出一个带有h.264和mp3编码的mp4。我遇到的问题是最终结果的比特率约为1600kbps,因此所有内容都被极度压缩。理想情况下,我希望至少3000kbps。因为我使用gst编辑服务来完成所有这些,我使用的是GESPipeline,所以我很难以某种方式设置比特率。我不确定如何在encodebin的编码配置文件中设置比特率 作为补充说明,使用带有vp8和vorbis编码的webm,我获得了更高质

我使用gstreamer的rust绑定来拍摄视频的前10秒,并将其制作成自己的视频。理想情况下,我想输出一个带有h.264和mp3编码的mp4。我遇到的问题是最终结果的比特率约为1600kbps,因此所有内容都被极度压缩。理想情况下,我希望至少3000kbps。因为我使用gst编辑服务来完成所有这些,我使用的是GESPipeline,所以我很难以某种方式设置比特率。我不确定如何在encodebin的编码配置文件中设置比特率

作为补充说明,使用带有vp8和vorbis编码的webm,我获得了更高质量的输出,但我仍然更喜欢使用h.264

以下是我的编码配置文件:

fn get_container_profile()->gst_pbutils::EncodingContainerProfile{
let video_profile=gst_pbutils::EncodingVideoProfileBuilder::new()
.名称(“h.264”)
.说明(“h.264-profile”)
.format(&gst::caps::caps::new_simple(“视频/x-h264”,&[]))
.build()
.unwrap();
让audio_profile=gst_pbutils::EncodingAudioProfileBuilder::new()
.名称(“mp3”)
.说明(“mp3档案”)
.format(&gst::caps::caps::new_simple(
“音频/mpeg”,
&[(&“mpegversion”、&1i32)、(&“layer”、&3i32)],
))
.build()
.unwrap();
让contianer_profile=gst_pbutils::EncodingContainerProfileBuilder::new()
.名称(“默认-mp4-profile”)
.说明(“mp4-with-h.264-mp3”)
.format(&gst::caps::caps::new_simple(
“视频/快速时间”,
&[(“变体”和“iso”)],
))
.已启用(真)
.添加配置文件(&视频配置文件)
.添加\u配置文件(&音频\u配置文件)
.build()
.unwrap();
返回contianer_配置文件;
}
下面是完整的代码

pub fn clip_video(){
匹配ges::init(){
Err(e)=>eprintln!(“{:?}”,e),
_ => (),
}
let(_timeline,pipeline,layer)=init_processing_structs();
让contianer_profile=get_container_profile();
让资产=ges::UricLipSet::请求\u同步(
"file:///home/ryan/repos/auto-highlighter-processing-service/input/test-video.mp4",
)
.预期(“未能创建资产”);
匹配图层。添加资源(
&资产,
0*gst::秒,
0*gst::秒,
10*消费税:第二,
ges::TrackType::未知,
) {
Err(e)=>eprintln!(“{:?}”,e),
_ => (),
}
匹配管道。设置\渲染\设置(
"file:///home/ryan/repos/auto-highlighter-processing-service/input/test-video.mp4",
&contianer_简介,
) {
Err(e)=>eprintln!(“{:?}”,e),
_ => (),
}
渲染视频(管道);
}
pub fn init_processing_structs()->(ges::Timeline,ges::Pipeline,ges::Layer){
让timeline=ges::timeline::新建音频视频();
让pipeline=ges::pipeline::new();
匹配管道。设置\u时间线(&时间线){
Err(e)=>eprintln!(“{:?}”,e),
_ => (),
}
let layer=timeline.append_layer();
返回(时间线、管道、层);
}
fn渲染_视频(管道:ges::管道){
匹配管道。设置_模式(ges::PipelineFlags::智能_渲染){
Err(e)=>eprintln!(“{:?}”,e),
_ => (),
}
管道
.set_state(gst::state::Ready)
.expect(“无法将管道设置为“就绪”状态”);
管道
.set_状态(gst::state::暂停)
.expect(“无法将管道设置为“就绪”状态”);
匹配管道。设置_状态(gst::state::Playing){
Err(e)=>eprintln!(“{:?}”,e),
_ => (),
}
let bus=pipeline.get_bus().unwrap();
用于总线中的msg。iter\U定时(gst::时钟\U时间\U无){
使用gst::MessageView;
匹配msg.view(){
MessageView::Eos(..)=>中断,
MessageView::Error(err)=>{
普林顿(
“来自{:?}:{}({:?})的错误”,
err.get_src().map(| s | s.get_path_string()),
err.get_error(),
err.get_debug()
);
打破
}
_ => (),
}
}
管道
.set_状态(gst::state::暂停)
.expect(“无法将管道设置为“就绪”状态”);
管道
.set_state(gst::state::Ready)
.expect(“无法将管道设置为“就绪”状态”);
管道
.set_state(gst::state::Null)
.expect(“无法将管道设置为`Null`状态”);
}
fn get_container_profile()->gst_pbutils::EncodingContainerProfile{
let video_profile=gst_pbutils::EncodingVideoProfileBuilder::new()
.名称(“h.264”)
.说明(“h.264-profile”)
.format(&gst::caps::caps::new_simple(“视频/x-h264”,&[]))
.build()
.unwrap();
让audio_profile=gst_pbutils::EncodingAudioProfileBuilder::new()
.名称(“mp3”)
.说明(“mp3档案”)
.format(&gst::caps::caps::new_simple(
“音频/mpeg”,
&[(&“mpegversion”、&1i32)、(&“layer”、&3i32)],
))
.build()
.unwrap();
让contianer_profile=gst_pbutils::EncodingContainerProfileBuilder::new()
.名称(“默认-mp4-profile”)
.说明(“mp4-with-h.264-mp3”)
.format(&gst::caps::caps::new_simple(
“视频/快速时间”,
&[(“变体”和“iso”)],
))
.已启用(真)
.添加配置文件(&视频配置文件)
.添加\u配置文件(&音频\u配置文件)
.build()
.unwrap();
返回contianer_配置文件;
}