| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 661 人关注过本帖
标题:VS2022 C++/CLR Winform(窗口程序) 调用ffmpeg 如何实现rmvb转mp4
只看楼主 加入收藏
追梦人zmrghy
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:406
专家分:190
注 册:2021-4-9
结帖率:97.26%
收藏
 问题点数:0 回复次数:4 
VS2022 C++/CLR Winform(窗口程序) 调用ffmpeg 如何实现rmvb转mp4
VS2022 C++/CLR Winform(窗口程序) 调用ffmpeg 如何实现rmvb转mp4

mp4转ts
ffmpeg -i 1.mp4 -vcodec copy -acodec copy -vbsf h264_mp4toannexb 1.ts

ts转mp4
ffmpeg -i 2.ts -acodec copy -vcodec copy -absf aac_adtstoasc output.mp4

ffmpeg提取视频
ffmpeg -i test.mp4 -vcodec copy -an 视频流.avi

ffmpeg mp4转mp3
ffmpeg -i test.mp4 out.mp3

这些命令都可以实现。





图片附件: 游客没有浏览图片的权限,请 登录注册

这7种格式视频都可以转为mp4....
ffmpeg为什么不能转换rmvb视频
搜索更多相关主题的帖子: CLR copy 窗口 视频 调用 
2023-01-22 18:48
追梦人zmrghy
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:406
专家分:190
注 册:2021-4-9
收藏
得分:0 
ffmpeg -i InPut.rmvb -c:v libx264 -strict -2 OutPut.mp4
2023-01-25 12:46
吹水佬
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:451
帖 子:10537
专家分:42927
注 册:2014-5-20
收藏
得分:0 
是不是没有rmvb解码库文件,rmvb不是免费的。
2023-01-25 14:58
万家乐
Rank: 1
等 级:新手上路
威 望:1
帖 子:4
专家分:0
注 册:2023-2-15
收藏
得分:0 
要在C++/CLR Winform应用程序中使用FFmpeg,你需要在项目中包含FFmpeg库并使用相应的头文件和函数。以下是基本的步骤:

下载FFmpeg库并将其解压缩到你的项目文件夹中。

在VS2022中打开你的Winform项目,并选择“项目”菜单,然后选择“属性”。

在属性窗口中,选择“VC++目录”选项卡,并将包含FFmpeg头文件的文件夹路径添加到“包含目录”选项中。

在“链接器”选项卡中,将包含FFmpeg库文件的文件夹路径添加到“库目录”选项中,并将FFmpeg库文件添加到“附加依赖项”选项中。

在你的代码中包含FFmpeg头文件,并使用相应的函数来执行你想要的操作。

例如,要将RMVB文件转换为MP4,可以使用以下命令:

css
Copy code
ffmpeg -i input.rmvb -c:v libx264 -preset slow -crf 22 -c:a copy output.mp4
在C++/CLR Winform应用程序中使用FFmpeg来执行此操作,你可以使用类似以下的代码:

objectivec
Copy code
#include <iostream>
extern "C" {
    #include <libavformat/avformat.h>
    #include <libavcodec/avcodec.h>
    #include <libavutil/imgutils.h>
    #include <libswscale/swscale.h>
}

int main() {
    AVFormatContext *inputContext = NULL;
    AVFormatContext *outputContext = NULL;
    AVCodec *videoCodec = NULL



roselanijamie639@

// 打开输入文件
if (avformat_open_input(&inputContext, "input.rmvb", NULL, NULL) < 0) {
std::cerr << "Could not open input file\n";
return -1;
}

c
Copy code
// 读取输入文件头
if (avformat_find_stream_info(inputContext, NULL) < 0) {
    std::cerr << "Could not find stream info\n";
    return -1;
}

// 找到视频流
int videoStreamIndex = -1;
for (int i = 0; i < inputContext->nb_streams; i++) {
    if (inputContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
        videoStreamIndex = i;
        break;
    }
}

if (videoStreamIndex == -1) {
    std::cerr << "Could not find video stream\n";
    return -1;
}

// 获取视频解码器
AVCodecParameters *videoCodecParameters = inputContext->streams[videoStreamIndex]->codecpar;
videoCodec = avcodec_find_decoder(videoCodecParameters->codec_id);
if (videoCodec == NULL) {
    std::cerr << "Could not find video codec\n";
    return -1;
}

// 打开视频解码器
AVCodecContext *videoCodecContext = avcodec_alloc_context3(videoCodec);
if (avcodec_parameters_to_context(videoCodecContext, videoCodecParameters) < 0) {
    std::cerr << "Could not copy video codec parameters to context\n";
    return -1;
}

if (avcodec_open2(videoCodecContext, videoCodec, NULL) < 0) {
    std::cerr << "Could not open video codec\n";
    return -1;
}

// 打开输出文件
if (avformat_alloc_output_context2(&outputContext, NULL, NULL, "output.mp4") < 0) {
    std::cerr << "Could not create output context\n";
    return -1;
}

// 添加视频流到输出文件
AVStream *outputStream = avformat_new_stream(outputContext, videoCodec);
if (outputStream == NULL) {
    std::cerr << "Could not create output stream\n";
    return -1;
}

// 复制视频流的参数到输出文件
if (avcodec_parameters_copy(outputStream->codecpar, videoCodecParameters) < 0) {
    std::cerr << "Could not copy codec parameters\n";
    return -1;
}

// 写输出文件头
if (avformat_write_header(outputContext, NULL) < 0) {
    std::cerr << "Could not write output file header\n";
    return -1;
}

// 循环读取输入文件中的每一帧,解码并编码到输出文件
AVPacket packet;
while (av_read_frame(inputContext, &packet) == 0) {
    if (packet.stream_index == videoStreamIndex) {
        AVFrame *frame = av_frame_alloc();
        if (frame == NULL) {
            std::cerr << "Could not allocate frame\n";
            break;
        }

        int ret = avcodec_send_packet(videoCodecContext
2023-02-15 21:49
追梦人zmrghy
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:406
专家分:190
注 册:2021-4-9
收藏
得分:0 
回复 4楼 万家乐
谢谢!!!
在CLR中使用ffmpeg, 我的水平当然不会了。

我只是用CLR窗体界面,来输入视频文件路径
然后编写命令脚本。。。
再使用system(),来执行命令脚本。。。。


实现rmvb转mp4命令
ffmpeg -i InPut.rmvb -c:v libx264 -strict -2 OutPut.mp4

2023-02-21 00:02
快速回复:VS2022 C++/CLR Winform(窗口程序) 调用ffmpeg 如何实现rmvb转mp4
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018337 second(s), 10 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved