利用qt和ffmpeg軟件來制作視頻裁剪工具

0 什么是ffmpeg?

Libav(舊稱:FFmpeg)是一個自由軟件,可以運行音頻和視頻多種格式的錄影、轉檔、流功能[1],包含了libavcodec ─這是一個用于多個專案中音頻和視頻的解碼器庫,以及 libavformat ——一個音頻與視頻格式轉換庫。

libav的舊稱"FFmpeg"這個單詞中的 "FF" 指的是 "Fast Forward"[2]。有些新手寫信給"FFmpeg"的項目負責人,詢問FF是不是代表“Fast Free”或者“Fast Fourier”等意思,"FFmpeg"的項目負責人回信說“Just for the record, the original meaning of "FF" in FFmpeg is "Fast Forward"...”

http://zh.wikipedia.org/wiki/Libav

?

?一 下載ffmpeg

官方網站: ????http://ffmpeg.zeranoe.com/

訪問???????????????http://ffmpeg.zeranoe.com/builds/

下載ffmpeg windows下發布版

FFmpeg git-f514695 32-bit Shared (Latest)?

?

二?在命令行下學會ffmpeg使用

cd 進入ffmpeg解壓縮目錄下的bin目錄

ffmpeg.exe -i D:/source.avi -vcodec copy -y -r 25 -ss 8 -t 971 D:/demo.mp4? >> D:\clip_info.txt 2>&1

?

這里-vcodec copy參數一定要加,這樣裁剪的時候不會改變視頻的編碼方式,裁剪非常快。

?

ffmpeg主要參數一覽

Hyper fast Audio and Video encoder

usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

Main options:
-L????????????????? show license
-h????????????????? show help
-?????????????????? show help
-help?????????????? show help
--help????????????? show help
-version??????????? show version
-formats??????????? show available formats
-codecs???????????? show available codecs
-bsfs?????????????? show available bit stream filters
-protocols????????? show available protocols
-filters??????????? show available filters
-pix_fmts?????????? show available pixel formats
-sample_fmts??????? show available audio sample formats
-loglevel loglevel? set libav* logging level
-v loglevel???????? set libav* logging level
-debug flags??????? set debug flags
-report???????????? generate a report
-max_alloc bytes??? set maximum size of a single allocated block
-f fmt????????????? force format
-i filename???????? input file name
-y????????????????? overwrite output files
-n????????????????? do not overwrite output files
-c codec??????????? codec name
-codec codec??????? codec name
-pre preset???????? preset name
-map_metadata outfile[,metadata]:infile[,metadata]? set metadata information of outfile from infile
-t duration???????? record or transcode "duration" seconds of audio/video
-fs limit_size????? set the limit file size in bytes
-ss time_off??????? set the start time offset
-itsoffset time_off? set the input ts offset
-itsscale scale???? set the input ts scale
-timestamp time???? set the recording timestamp ('now' to set the current time)
-metadata string=string? add metadata
-dframes number???? set the number of data frames to record
-timelimit limit??? set max runtime in seconds
-target type??????? specify target file type ("vcd", "svcd", "dvd", "dv", "dv50", "pal-vcd", "ntsc-svcd", ...)
-xerror???????????? exit on error
-frames number????? set the number of frames to record
-tag fourcc/tag???? force codec tag/fourcc
-filter filter_list? set stream filterchain
-stats????????????? print progress report during encoding
-attach filename??? add an attachment to the output file
-dump_attachment filename? extract an attachment into a file
-bsf bitstream_filters? A comma-separated list of bitstream filters
-dcodec codec?????? force data codec ('copy' to copy stream)

Advanced options:
-map [-]input_file_id[:stream_specifier][,sync_file_id[:stream_s? set input stream mapping
-map_channel file.stream.channel[:syncfile.syncstream]? map an audio channel from one stream to another
-map_chapters input_file_index? set chapters mapping
-benchmark????????? add timings for benchmarking
-dump?????????????? dump each input packet
-hex??????????????? when dumping packets, also dump the payload
-re???????????????? read input at native frame rate
-loop_input???????? deprecated, use -loop
-loop_output??????? deprecated, use -loop
-vsync????????????? video sync method
-async????????????? audio sync method
-adrift_threshold threshold? audio drift threshold
-copyts???????????? copy timestamps
-copytb source????? copy input stream time base when stream copying
-shortest?????????? finish encoding within shortest input
-dts_delta_threshold threshold? timestamp discontinuity delta threshold
-copyinkf?????????? copy initial non-keyframes
-q q??????????????? use fixed quality scale (VBR)
-qscale q?????????? use fixed quality scale (VBR)
-streamid streamIndex:value? set the value of an outfile streamid
-muxdelay seconds?? set the maximum demux-decode delay
-muxpreload seconds? set the initial demux-decode delay
-fpre filename????? set options from indicated preset file

Video options:
-vframes number???? set the number of video frames to record
-r rate???????????? set frame rate (Hz value, fraction or abbreviation)
-s size???????????? set frame size (WxH or abbreviation)
-aspect aspect????? set aspect ratio (4:3, 16:9 or 1.3333, 1.7777)
-bits_per_raw_sample number? set the number of bits per raw sample
-croptop size?????? Removed, use the crop filter instead
-cropbottom size??? Removed, use the crop filter instead
-cropleft size????? Removed, use the crop filter instead
-cropright size???? Removed, use the crop filter instead
-padtop size??????? Removed, use the pad filter instead
-padbottom size???? Removed, use the pad filter instead
-padleft size?????? Removed, use the pad filter instead
-padright size????? Removed, use the pad filter instead
-padcolor color???? Removed, use the pad filter instead
-vn???????????????? disable video
-vcodec codec?????? force video codec ('copy' to copy stream)
-sameq????????????? use same quantizer as source (implies VBR)
-same_quant???????? use same quantizer as source (implies VBR)
-pass n???????????? select the pass number (1 or 2)
-passlogfile prefix? select two pass log file name prefix
-vf filter list???? video filters
-b bitrate????????? video bitrate (please use -b:v)
-dn???????????????? disable data

?

三 利用QT4做個簡單圖形界面工具

?

?

這里主要用了QProcess這個類,可以調用外部程序。

關鍵代碼:?

?

??? QString program = "D:\\maxview_video_demo\\ffmpeg\\ffmpeg-git-985e768-win64-static\\bin\\ffmpeg.exe";
??? QString inputPath = ui->videopathLineEdit->text();
??? QFile sourceFile(inputPath);
??? if(!sourceFile.exists()){
??????? QMessageBox::information(this,QString::fromUtf8("提示"),QString::fromUtf8("找不到源文件"));
??????? return;
??? }

??? QString outputPath = QFileInfo(sourceFile).absolutePath() +"/clip.mp4";

??? QFile destFile(outputPath);
??? if(destFile.exists()){
??????? destFile.remove();
??? }

??? QString startTime = ui->videoStartTimeEdit->time().toString("hh:mm:ss");
??? QString len= ui->videoLengthTimeEdit->time().toString("hh:mm:ss");
??? QStringList arguments;
??? arguments << "-i" << inputPath << "-r" << "25"<<"-ss";
??? arguments <<startTime<< "-t" <<?len<< outputPath;

??? QProcess *clipProcess = new QProcess(this);
??? connect(clipProcess,SIGNAL(finished(int)),this,SLOT(clipVideoFinished(int)));

??? clipProcess->start(program, arguments);

?

當視頻截取完成后,進程會發生信號finished(int),并被QProcess捕捉到,這樣可以調用

clipVideoFinished函數來通知程序視頻裁剪完成了。


本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/453931.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/453931.shtml
英文地址,請注明出處:http://en.pswp.cn/news/453931.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

fresco使用中圓角出現了黑邊

其實并不是出現了黑邊&#xff0c;而是圖片上有顏色滲出 如何修改 在xml加入 fresco:roundWithOverlayColor "color/transparent" //就是把圓角覆蓋圖改為透明色 轉載于:https://www.cnblogs.com/vete-l/p/7998122.html

Python 第三方庫之 docxtpl (處理word文檔)

項目官方文檔 項目官方git docxtpl 軟件包使用兩個主要軟件包&#xff1a; python docx&#xff0c;用于讀取、寫入和創建子文檔jinja2用于管理插入到模板docx中的標記。jinja官網, jinja中文網站 簡單示例 from docxtpl import DocxTemplatetpl DocxTemplate(test.docx)con…

域添加另一臺機器_巨杉Tech | SequoiaDB數據域概念解讀與實踐

近年來&#xff0c;銀行各項業務發展迅猛&#xff0c;客戶數目不斷增加&#xff0c;后臺服務系統壓力也越來越大&#xff0c;系統的各項硬件資源也變得非常緊張。因此&#xff0c;在技術風險可控的基礎上&#xff0c;希望引入大數據技術&#xff0c;利用大數據技術優化現有IT系…

Citrix XenServer 池要求

池要求 資源池是一臺或多臺服務器的同類或異類聚合&#xff0c;每個池最多包含 16 臺服務器。創建池或將服務器加入現有池前&#xff0c;應確保池中的所有服務器滿足下面介紹的要求。 硬件要求 XenServer 資源池中的所有服務器必須具有廣泛兼容的 CPU&#xff0c;也就是說&…

推薦一個接口文檔工具

ShowDoc 轉載于:https://www.cnblogs.com/LW-baiyun/p/8003975.html

自動轉換flv文件

在線轉化.誰有 把其他的視頻文件格式的視頻,經過上傳自動轉化FLV格式的一種插件.提供編程接口.給我一份.類似新浪網播客上傳視頻的一樣. (還有上傳是的哪個效果,進度條如何作的?)或者給我個參考地址什 ... 環境&#xff1a;redhat as41。首先獲取ffmpeg很多人找不到怎么下載,其…

云計算的概念_云計算概念掀起漲停潮 美利云奠定板塊龍頭地位

溫馨提示&#xff1a;股市風險時刻存在&#xff0c;文中所提個股僅為個人觀點&#xff0c;請勿盲目跟隨操作&#xff0c;筆者希望大家都做到不貪婪&#xff0c;不恐懼&#xff0c;不瞎猜&#xff0c;不跟風做一個紀律嚴明輕松淡定的股票交易者。社4月26日訊&#xff0c;滬深兩市…

Python 第三方模塊之 PDFMiner(pdf信息提取)

PDFMiner簡介 pdf提取目前的解決方案大致只有pyPDF和PDFMiner。據說PDFMiner更適合文本的解析&#xff0c;首先說明的是解析PDF是非常蛋疼的事&#xff0c;即使是PDFMiner對于格式不工整的PDF解析效果也不怎么樣&#xff0c;所以連PDFMiner的開發者都吐槽PDF is evil. 不過這些…

TFS2017持續發布中調用PowerShell啟停遠程應用程序

目前團隊項目中有多個Web、服務以及與大數據平臺對接接口等應用&#xff0c;每次的發布和部署采用手工的方式進行。停止應用程序&#xff0c;拷貝發布包&#xff0c;啟動應用程序&#xff0c;不停的循環著&#xff0c;并且時不時地會出現一些人為錯誤性問題。這種模式消耗的很多…

Flask 多線程

參數 app.run()中可以接受兩個參數&#xff0c;分別是threaded和processes&#xff0c;用于開啟線程支持和進程支持。 threaded&#xff1a; 是否開啟多線程&#xff0c;默認不開啟。 if __name__ __main__:app.run(threadedTrue)processes&#xff1a;進程數量&#xff0c…

40天python入門教程_Python入門教程超詳細1小時學會Python

Java和Javascript,不用1小時你就可以用Python快速流暢地寫有用的Python程序.為什么使用Python假設我們有這么一項任務:簡單測試局域網中的電腦是否連通.這些電腦的ip范圍從192.168.0.101到192.168.0.200.思路:用shell編程.(Linux通常是bash而Windows是批處理腳本).例如,在Windo…

基于LVS對LAMP做負載均衡集群

一、簡介 LVS是Linux Virtual Server的簡稱&#xff0c;也就是Linux虛擬服務器, 是一個由章文嵩博士發起的自由軟件項目&#xff0c;它的官方站點是www.linuxvirtualserver.org。現在LVS已經是 Linux標準內核的一部分&#xff0c;在Linux2.4內核以前&#xff0c;使用LVS時必須要…

Python_Day1

1、猜年齡游戲&#xff1a; &#xff08;1&#xff09;&#xff1a;每循環3次&#xff0c;counter值返回為0&#xff0c;重新開始循環&#xff1b;&#xff08;2&#xff09;&#xff1a;continue 意思是跳出當前循環&#xff1b;&#xff08;3&#xff09;&#xff1…

kafka 入門

初識 Kafka 什么是 Kafka Kafka 是由 Linkedin 公司開發的&#xff0c;它是一個分布式的&#xff0c;支持多分區、多副本&#xff0c;基于 Zookeeper 的分布式消息流平臺&#xff0c;它同時也是一款開源的 基于發布訂閱模式的消息引擎系統。 Kafka 的基本術語 消息&#xf…

實體詞典 情感詞典_tidytextpy包 | 對三體進行情感分析

騰訊課堂 | Python網絡爬蟲與文本分析TidyTextPy前天我分享了 tidytext | 耳目一新的R-style文本分析庫 但是tidytext不夠完善&#xff0c;我在tidytext基礎上增加了情感詞典&#xff0c;可以進行情感計算&#xff0c;為了區別前者&#xff0c;將其命名為tidytextpy。大家有時間…

TensorFlow實現LeNet5模型

# -*- coding: utf-8 -*-import tensorflow as tffrom tensorflow.examples.tutorials.mnist import input_data# 獲取mnist數據mnist input_data.read_data_sets("MNIST_data/", one_hotTrue)# 注冊默認session 后面操作無需指定session 不同sesson之間的數據是獨立…

Python基礎第一天

一、內容 二、練習 練習1 題目&#xff1a;使用while循環輸出1 2 3 4 5 6 8 9 10 方法一&#xff1a; 圖示&#xff1a; 代碼&#xff1a; count 1 while count < 11:if count ! 7:print(count)count 1輸出結果&#xff1a; 1 2 3 4 5 6 8 9 10 View Code方法二&#xff1…

python flask 上傳下載 api_Flask 文件下載API

給前端提供一個文件下載接口時, 遇到了文件名亂碼的問題, 幾經折騰總算實現效果, 代碼如下:import requestsfrom flask import Response, jsonify, request, stream_with_contextfrom flask_login import login_requiredfrom . import bpfrom .models import Coursewarebp.rout…

OpenGL實用開源代碼列表

有了網絡的最大好處就是可以資源共享。網絡是最大的知識庫&#xff0c;也是最好的老師&#xff0c;正所謂“沒有你想不到的&#xff0c;只有你找不到的”。以下是我收集的以游戲編程&#xff0c;OpenGL 3D編程相關的免費擴展庫資料。不斷更新中&#xff0c;如果你有好的建義&am…

vaOJ10369 - Arctic Network

1 /*2 The first line of each test case contains 1 < S < 100, the number of satellite channels!3 注意&#xff1a;S表示一共有多少個衛星&#xff0c;那么就是有 最多有S-1個通道&#xff01; 然后將最小生成樹中的后邊的 S-1通道去掉就行了&#xff01; 4…