首页 > 其他分享 >ffmpeg 切分音频视频,统计音频时长

ffmpeg 切分音频视频,统计音频时长

时间:2023-08-23 16:34:31浏览次数:43  
标签:cmd ffmpeg sp 音频视频 切分 file duration path

# audio duration
    def make_duration(file_path):
        result = sp.run(["ffprobe", "-v", "error", "-show_entries",
                         "format=duration", "-of",
                         "default=noprint_wrappers=1:nokey=1", file_path], 
                         stdout=sp.PIPE,
                         stderr=sp.STDOUT)
        return float(result.stdout)

# cut video and audio
cmd_split_line = 'ffmpeg -loglevel quiet -ss {} -to {} -accurate_seek -i "{}" "{}" -y'.format(start_time, end_time, self.file_path, dst_mp4_path)
sp.check_call(cmd_split_line, shell=True, stderr=open(os.devnull, 'w'))

标签:cmd,ffmpeg,sp,音频视频,切分,file,duration,path
From: https://www.cnblogs.com/yunhgu/p/17652038.html

相关文章

  • FFmpeg 常用命令汇总
    来源:影音视频技术文章作者:YUV420.COM文章链接: https://www.yuv420.com/2019/12/23/ffmpeg-chang-yong-ming-ling-hui-zong/引言开源音视频处理工具FFMPEG以其强大的功能而在音视频领域著称,从音视频格式转换、裁剪、拼接、提取字幕到提取视频流,编解码等无所不能,本页汇集整......
  • SpringBoot整合FFmpeg进行视频分片上传------>Windows
    SpringBoot整合FFmpeg进行视频分片上传------>Windows分片上传的核心思路:将文件按一定的分割规则(静态或动态设定,如手动设置20M为一个分片),用slice分割成多个数据块。为每个文件生成一个唯一标识Key,用于多数据块上传时区分所属文件。所有分片上传完成,服务端校验合并标识为Key的......
  • 麒麟银河系统v10编译ffmpeg并配置QT
    1.前往网站下载安装包https://www.ffmpeg.org/releases/ffmpeg-5.1.2.tar.gz2.解压tar-zxvfffmpeg-5.1.2.tar.gz3.进入文件夹并编译cd/ffmpeg-5.1.2./configure--prefix=/usr/local/ffmpeg--enable-sharedmake-j8makeinstall注意:--prefix:指定安装路径,如果不指定,头文......
  • OpenCV|FFmpeg – OpenCV cv::Mat与FFmpeg AVFrame的相互转换
    1 OpenCV cv::Mat与FFmpeg AVFrame相互转换最近在处理OpenCV采集摄像头图片然后使用ffmpeg编码为h264裸流,之后再将h264裸流转换为OpenCVcv::Mat进行显示的问题,在这个过程中,如何将OpenCV的cv::Mat转化为FFmpegAVFrame在进行h264编码,以及如何将h264解码后的AVFrame转换为cv::......
  • FFmpeg将视频转换成一帧一帧的jpeg图片(代码实现)
      #include<iostream> usingnamespacestd; extern"C" { #include"libavcodec/avcodec.h" #include"libavformat/avformat.h" #include"libswscale/swscale.h" #include......
  • ffmpeg把读取的视频流保存为jpeg文件
    intimg_savejpeg(AVFrame*pFrame,char*out_filename){//视频流保存为jpegintwidth=pFrame->width;intheight=pFrame->height;AVCodecContext*pCodeCtx=NULL;AVFormatContext*pFormatCtx=avformat_alloc_context();//设置输出文件格式pFormatCtx->oformat=av......
  • 使用ffmpeg将MP4文件的每一帧保存为jpg图片
    #include<stdio.h>#include<stdlib.h>#include<string.h>#include<unistd.h>#include<fcntl.h>#include<sys/ioctl.h>#include<string.h>#include<sys/mman.h>#include<assert.h>#include<liba......
  • windows 32位系统和64位系统ffmpeg下载
    64位下载Releases·BtbN/FFmpeg-Builds(github.com)  32位下载https://github.com/sudo-nautilus/FFmpeg-Builds-Win32/releases/tag/latest  ......
  • Win11+ VS2022编译 FFmpeg6.0 静态库
    目录编译前言为什么项目编译?前期准备环境配置ffmpeg外部库额外的编译选项-for渲染opengl(需要glext)ffnvcodec(需要nv-codec-headers)AMFsdk头文件编译工具链开始编译step1.选择编译类型Debug/ReleaseDll/libstep2.打包SDK验证结尾参考链接编译前言编译作为自己持有......
  • Qt+rtsp+ffmpeg 播放声音
    #include<QtCore/QCoreApplication>#include<QtMultimedia/QAudioFormat>#include<QtMultimedia/QAudioOutput>#include<QtCore/QFile>#include<iostream>#ifdef__cplusplusextern"C"{#endif//__cplusplus#include"li......