# study-ffmpeg **Repository Path**: xujieyang/study-ffmpeg ## Basic Information - **Project Name**: study-ffmpeg - **Description**: study ffmpeg - **Primary Language**: Java - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2020-10-19 - **Last Updated**: 2021-06-03 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # study-ffmpeg ## 1. ffmpeg使用指南 1. 获取视频元数据 ```shell script ffprobe -v quiet -print_format json -show_format ~/Downloads/ffmpeg/001.flv ffprobe -i video/001.flv -show_entries format=duration -v quiet ffprobe -i video/001.flv -show_entries format=duration -v quiet -of default=noprint_wrappers=1:nokey=1 ``` 2. 转换视频 ```shell script ## 按原视频质量转换视频 ffmpeg -i input.webm -qscale 0 output.mp4 ``` 3. 裁剪视频 ```shell script ## 下面的三种方式可能会丢失帧 ## 截取从头开始的30s ffmpeg -ss 00:00:00 -t 00:00:30 -i input.mp4 -vcodec copy -acodec copy output.mp4 ## 截取从30s开始的30s ffmpeg -ss 00:00:30 -t 00:00:30 -i input.mp4 -vcodec copy -acodec copy output.mp4 ## 指定开始和结束时间 ffmpeg -i input.mp4 -ss 00:01:54 -to 00:06:53 -c copy output.mp4 ``` ```shell script ## 精确裁剪视频 ## 第一种方式 ffmpeg -i input.mp4 -strict -2 -qscale 0 -intra keyinput.mp4 ffmpeg -ss 00:00:00 -t 00:00:30 -i keyinput.mp4 -vcodec copy -acodec copy output.mp4 ## 第二种方式 ffmpeg -i video/001.flv -ss 00:00:00 -t 00:03:51 video/001.mp4 ``` ```shell script ##进行视频的合并 ffmpeg -f concat -i list.txt -c copy concat.mp4 ## list.txt file ./split.mp4 file ./split1.mp4 ``` 4. 按大小分割文件 ```shell script ## -fs limit_size (output) ## Set the file size limit, expressed in bytes. No further chunk of bytes is written after the limit is exceeded. The size of the output file is slightly more than the requested file size. ## 使用-fs限制输出文件的大小,实际输出的大小会略大于指定的大小 ## bin/mac/ffmpeg -i video/001.flv -ss 00:00:00 -fs 5242880 video/001_1.mp4 bin/mac/ffmpeg -i video/001.flv -ss 00:01:07 -fs 5242880 video/001_1.mp4 bin/mac/ffmpeg -i video/001.flv -ss 00:02:09 -fs 5242880 video/001_3.mp4 totalDuration = ffprobe -i video/001.flv -show_entries format=duration curDuration = 0 i = 1 while [[ $curDuration -lt $totalDuration ]]; do bin/mac/ffmpeg -i video/001.flv -ss curDuration -fs 5242880 video/001_$i.mp4 duration = ffprobe -i video/001_$i.mp4 -show_entries format=duration curDuration = curDuration + duration i++ done ``` 5. 获取视频转换的进度 ```text 读取视频转换的输出的日志,frame=10645 fps=304 q=-1.0 Lsize= 35737kB time=00:07:05.90 bitrate= 687.4kbits/s speed=12.2x ``` 6. ffmpeg资料 + [ffmpeg视频剪切与合并](https://www.jianshu.com/p/eff314074177) + [给新手的 20 多个 FFmpeg 命令示例](https://zhuanlan.zhihu.com/p/67878761) + [ffmpeg flv转MP4 一点心得](https://juejin.im/post/6844903757503807495) ## 2. javafx 1. idea配置 ```shell script ## https://www.jetbrains.com/help/idea/javafx.html --module-path %PATH_TO_FX% --add-modules javafx.controls,javafx.fxml ``` ## 3. 流媒体 https://mp.weixin.qq.com/s/FgvwNUw9e-dvmpgOJ-Itiw ## 4. Android 1. https://developer.android.com/guide 2. [Android 7+ charles抓包](https://mp.weixin.qq.com/s?__biz=MzU4MjgzNzk5MA==&mid=2247483695&idx=1&sn=020fe7fc09eec49ed84c7c111be105ce&chksm=fdb372a6cac4fbb09a2152a1e71da3d18ccc68e31cad0682565d7a3af3444b05269d95ae9edc&token=2000924864&lang=zh_CN#rd ) ## 5. java并发编程 1. https://www.cnblogs.com/dolphin0520/p/3923167.html ## 6. 异常记录 1. Not on FX application thread; currentThread = Thread-9 ```java Exception in thread "Thread-9" java.lang.IllegalStateException: Not on FX application thread; currentThread = Thread-9 at javafx.graphics/com.sun.javafx.tk.Toolkit.checkFxUserThread(Toolkit.java:292) at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.checkFxUserThread(QuantumToolkit.java:446) at javafx.graphics/javafx.scene.Parent$3.onProposedChange(Parent.java:474) at javafx.base/com.sun.javafx.collections.VetoableListDecorator.setAll(VetoableListDecorator.java:113) at javafx.base/com.sun.javafx.collections.VetoableListDecorator.setAll(VetoableListDecorator.java:108) at javafx.controls/javafx.scene.control.skin.ProgressBarSkin.initialize(ProgressBarSkin.java:333) at javafx.controls/javafx.scene.control.skin.ProgressIndicatorSkin.lambda$new$0(ProgressIndicatorSkin.java:130) at javafx.controls/com.sun.javafx.scene.control.LambdaMultiplePropertyChangeListenerHandler.lambda$new$1(LambdaMultiplePropertyChangeListenerHandler.java:49) at javafx.base/javafx.beans.value.WeakChangeListener.changed(WeakChangeListener.java:86) at javafx.base/com.sun.javafx.binding.ExpressionHelper$SingleChange.fireValueChangedEvent(ExpressionHelper.java:181) at javafx.base/com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:80) at javafx.base/javafx.beans.property.ReadOnlyBooleanPropertyBase.fireValueChangedEvent(ReadOnlyBooleanPropertyBase.java:72) at javafx.base/javafx.beans.property.ReadOnlyBooleanWrapper.fireValueChangedEvent(ReadOnlyBooleanWrapper.java:103) at javafx.base/javafx.beans.property.BooleanPropertyBase.markInvalid(BooleanPropertyBase.java:111) at javafx.base/javafx.beans.property.BooleanPropertyBase.set(BooleanPropertyBase.java:145) at javafx.controls/javafx.scene.control.ProgressIndicator.setIndeterminate(ProgressIndicator.java:118) at javafx.controls/javafx.scene.control.ProgressIndicator$2.invalidated(ProgressIndicator.java:170) at javafx.base/javafx.beans.property.DoublePropertyBase.markInvalid(DoublePropertyBase.java:113) at javafx.base/javafx.beans.property.DoublePropertyBase.set(DoublePropertyBase.java:148) at javafx.controls/javafx.scene.control.ProgressIndicator.setProgress(ProgressIndicator.java:159) at small.cute.video.editor.TranscodeController.lambda$handleTranscode$0(TranscodeController.java:134) at java.base/java.lang.Thread.run(Thread.java:834) Exception in thread "Thread-9" java.lang.IllegalStateException: Not on FX application thread; currentThread = Thread-9 at javafx.graphics/com.sun.javafx.tk.Toolkit.checkFxUserThread(Toolkit.java:292) at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.checkFxUserThread(QuantumToolkit.java:446) at javafx.graphics/javafx.scene.Parent$3.onProposedChange(Parent.java:474) at javafx.base/com.sun.javafx.collections.VetoableListDecorator.setAll(VetoableListDecorator.java:113) at javafx.base/com.sun.javafx.collections.VetoableListDecorator.setAll(VetoableListDecorator.java:108) at javafx.controls/javafx.scene.control.skin.ProgressBarSkin.initialize(ProgressBarSkin.java:333) at javafx.controls/javafx.scene.control.skin.ProgressIndicatorSkin.lambda$new$0(ProgressIndicatorSkin.java:130) at javafx.controls/com.sun.javafx.scene.control.LambdaMultiplePropertyChangeListenerHandler.lambda$new$1(LambdaMultiplePropertyChangeListenerHandler.java:49) at javafx.base/javafx.beans.value.WeakChangeListener.changed(WeakChangeListener.java:86) at javafx.base/com.sun.javafx.binding.ExpressionHelper$SingleChange.fireValueChangedEvent(ExpressionHelper.java:181) at javafx.base/com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:80) at javafx.base/javafx.beans.property.ReadOnlyBooleanPropertyBase.fireValueChangedEvent(ReadOnlyBooleanPropertyBase.java:72) at javafx.base/javafx.beans.property.ReadOnlyBooleanWrapper.fireValueChangedEvent(ReadOnlyBooleanWrapper.java:103) at javafx.base/javafx.beans.property.BooleanPropertyBase.markInvalid(BooleanPropertyBase.java:111) at javafx.base/javafx.beans.property.BooleanPropertyBase.set(BooleanPropertyBase.java:145) at javafx.controls/javafx.scene.control.ProgressIndicator.setIndeterminate(ProgressIndicator.java:118) at javafx.controls/javafx.scene.control.ProgressIndicator$2.invalidated(ProgressIndicator.java:170) at javafx.base/javafx.beans.property.DoublePropertyBase.markInvalid(DoublePropertyBase.java:113) at javafx.base/javafx.beans.property.DoublePropertyBase.set(DoublePropertyBase.java:148) at javafx.controls/javafx.scene.control.ProgressIndicator.setProgress(ProgressIndicator.java:159) at small.cute.video.editor.TranscodeController.lambda$handleTranscode$0(TranscodeController.java:134) at java.base/java.lang.Thread.run(Thread.java:834) ``` 2. PKIX path building failed” and “unable to find valid certification path to requested target https://stackoverflow.com/questions/21076179/pkix-path-building-failed-and-unable-to-find-valid-certification-path-to-requ