﻿{"id":2445,"date":"2022-06-09T15:11:54","date_gmt":"2022-06-09T07:11:54","guid":{"rendered":"http:\/\/nick.txtcc.com\/?p=2445"},"modified":"2023-02-09T11:41:09","modified_gmt":"2023-02-09T03:41:09","slug":"ffmpeg%e5%b0%86%e8%a7%86%e9%a2%91%e6%96%87%e4%bb%b6%e6%8f%90%e5%8f%96%e9%9f%b3%e9%a2%91%e8%bd%ac%e6%8d%a2%e4%b8%bamp3","status":"publish","type":"post","link":"http:\/\/nick.txtcc.com\/index.php\/linux\/2445","title":{"rendered":"ffmpeg\u5c06\u89c6\u9891\u6587\u4ef6\u63d0\u53d6\u97f3\u9891\u8f6c\u6362\u4e3amp3"},"content":{"rendered":"<h2 id=\"\u5c06flac\u6587\u4ef6\u8f6c\u6362\u4e3amp3\u6587\u4ef6\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5373\u53ef\">\u5c06flac\u6587\u4ef6\u8f6c\u6362\u4e3amp3\u6587\u4ef6\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5373\u53ef<\/h2>\n<p>\uff08\u540c\u65f6\u4f1a\u5c06flac\u6587\u4ef6\u7684Vorbis\u6ce8\u91ca\u8f6c\u6362\u4e3amp3\u7684ID3v2\u5143\u6570\u636e)<\/p>\n<pre class=\"highlighter-hljs\"><code class=\"language-bash highlighter-hljs hljs hljsln\">ffmpeg -i input.flac -ab 320k -map_metadata 0 -id3v2_version 3 output.mp3\n<\/code><\/pre>\n<h2 id=\"\u89c6\u9891\u63d0\u53d6mp3\">\u89c6\u9891\u63d0\u53d6MP3<\/h2>\n<p>\u4ece\u539f\u6709\u89c6\u9891\u63d0\u53d6\u97f3\u9891<\/p>\n<pre class=\"highlighter-hljs\"><code class=\"language-bash highlighter-hljs hljs hljsln\">ffmpeg.exe&nbsp; -i&nbsp; input.mp4&nbsp; -vn&nbsp; output.mp3\n<\/code><\/pre>\n<p>\u622a\u53d6\u97f3\u9891\u7247\u6bb5<\/p>\n<pre class=\"highlighter-hljs\"><code class=\"language-bash highlighter-hljs hljs hljsln\">ffmpeg.exe&nbsp; -i&nbsp; input.mp3 -ss 00:00:00&nbsp; -t&nbsp; 00:01:00&nbsp; output.mp3\n<\/code><\/pre>\n<p>\u4e0a\u9762\u63d0\u53d6\u548c\u622a\u53d6\u4e5f\u53ef\u5408\u5e76\u4e3a\u4e00\u6b65\u3002<\/p>\n<p>\u53c2\u6570\u8bf4\u660e<\/p>\n<pre class=\"highlighter-hljs\"><code class=\"highlighter-hljs hljs language-diff hljsln\">&lt;span class=&quot;hljs-deletion&quot;&gt;-i   \u8f93\u5165\u6587\u4ef6\uff08\u4efb\u610f\u683c\u5f0f\uff09&lt;\/span&gt;\n&lt;span class=&quot;hljs-deletion&quot;&gt;-vn \u4e0d\u4f7f\u7528\u89c6\u9891\u7eaa\u5f55&lt;\/span&gt;\n&lt;span class=&quot;hljs-deletion&quot;&gt;-ss \u5f00\u59cb\u65f6\u95f4&lt;\/span&gt;\n&lt;span class=&quot;hljs-deletion&quot;&gt;-t  \u6301\u7eed\u65f6\u95f4&lt;\/span&gt;<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p>2.\u97f3\u91cf\u8c03\u6574\n2.1.\u57fa\u4e8e\u5f53\u524d\u97f3\u91cf\u500d\u6570\u5904\u7406\n<1>\u5c06\u5f53\u524d\u97f3\u91cf\u964d\u4f4e\u4e00\u534a\uff1a<\/p>\n<p>ffmpeg -i input.mp3 -af volume=0.5 output.mp3<\/p>\n<p><2>\u5c06\u5f53\u524d\u97f3\u91cf\u63d0\u5347\u4e00\u500d\u3002\u8fd9\u79cd\u5904\u7406\u76f8\u5bf9\u7c97\u66b4\uff0c\u4f1a\u4f7f\u97f3\u9891\u51fa\u73b0\u5931\u771f\u73b0\u8c61\uff1a<\/p>\n<p>ffmpeg -i input.mp3 -af volume=2 output.mp3<\/p>\n<p>2.2.\u57fa\u4e8e\u5206\u8d1d\u6570\u503c\u7684\u5904\u7406\n\u200b \u4e0a\u9762\u57fa\u4e8e\u500d\u6570\u7684\u5904\u7406\u53ef\u80fd\u4f1a\u5bfc\u81f4\u97f3\u9891\u5931\u771f\uff0c\u800c\u57fa\u4e8e\u5206\u8d1d\u6570\u503c\u7684\u5904\u7406\u5219\u76f8\u5bf9\u4f1a\u4fdd\u7559\u97f3\u9891\u7684\u539f\u58f0\u6548\u679c\u3002<\/p>\n<p><1>\u97f3\u91cf\u63d0\u53475\u5206\u8d1d\uff08db\uff09\uff1a<\/p>\n<p>ffmpeg -i input.mp3 -filter\uff1a&#8221;volume=5dB&#8221; output.mp3<\/p>\n<p><2>\u97f3\u91cf\u964d\u4f4e5\u5206\u8d1d\uff08db\uff09\uff1a<\/p>\n<p>ffmpeg -i input.mp3 -filter\uff1a&#8221;volume=-5dB&#8221; output.mp3<\/p>\n<p>3.\u97f3\u91cf\u7684\u6807\u51c6\u5316\n\u200b ffmpeg\u5177\u5907\u5bf9\u97f3\u91cf\u6807\u51c6\u5316\u7684\u5904\u7406\u529f\u80fd\uff0c\u5373\u524a\u5cf0\u586b\u8c37\uff0c\u4f7f\u6574\u4e2a\u97f3\u9891\u7684\u97f3\u91cf\u53d8\u5f97\u5e73\u6ed1<\/p>\n<p>ffmpeg -i input.mp3 -filter:a &#8220;loudnorm=i=-14:tp=0.0&#8221; output.mp3<\/p>\n<p>&nbsp;<\/p>\n<p>\u8c03\u6574\u97f3\u9891\u901f\u5ea6<\/p>\n<p class=\"p1\"><span class=\"s1\">ffmpeg -i welcome_30.mp3 -af &#8220;atempo=2.0&#8221; -vn out.mp3<\/span><\/p>\n<p>\u4f7f\u7528FFmpeg\u5220\u9664\u89c6\u9891\u4e2d\u7684\u97f3\u9891\n\u5f88\u591a\u4eba\u60f3\u8981\u77e5\u9053\u5982\u4f55\u4ece\u5f55\u5236\u7684\u89c6\u9891\u4e2d\u5220\u9664\u97f3\u8f68\uff0c\u6bd4\u5982\u9a6c\u8def\u566a\u97f3\u6216\u8005\u80cc\u666f\u566a\u97f3\u3002<\/p>\n<p>\u5220\u9664\u97f3\u9891\u6700\u7b80\u5355\u7684\u65b9\u6cd5\u662f\uff1a\u53ea\u5c06\u89c6\u9891\u590d\u5236\u5230\u4e00\u4e2a\u65b0\u7684\u6587\u4ef6\u4e2d\uff0c\u800c\u4e0d\u590d\u5236\u97f3\u9891\u3002\u8fd9\u4e2a\u65b9\u6cd5\u4e4b\u6240\u4ee5\u7b80\u5355\uff0c\u662f\u56e0\u4e3a\u5b83\u65e0\u9700\u5c06\u89c6\u9891\u91cd\u65b0\u7f16\u7801\u3002\u4e0b\u9762\u662f\u5220\u9664\u97f3\u9891\u7684\u547d\u4ee4\u884c\uff1a<\/p>\n<p>ffmpeg.exe -i videoWithAudio.mp4 -c:v copy -an videoWithoutAudio.mp4<\/p>\n<p>\u4f7f\u7528-c:v copy\u547d\u4ee4\u5c06\u89c6\u9891\u590d\u5236\u5230videoWithoutAudio.mp4<\/p>\n<p>-an\u544a\u8bc9FFmpeg\u4e0d\u8981\u590d\u5236\u97f3\u9891<\/p>\n<p>\u4e0a\u8ff0\u65b9\u6cd5\u975e\u5e38\u9002\u7528\u4e8e\u7535\u5f71\u4e2d\u53ea\u6709\u4e00\u4e2a\u97f3\u8f68\u7684\u60c5\u51b5\u3002\u4f46\u662f\uff0c\u5982\u679c\u7535\u5f71\u4e2d\u67093~4\u4e2a\u97f3\u8f68\uff0c\u800c\u4f60\u53ea\u60f3\u5220\u9664\u7b2c\u4e8c\u4e2a\u97f3\u8f68\uff0c\u8be5\u5982\u4f55\u64cd\u4f5c\uff1f<\/p>\n<p>\u5982\u4f55\u901a\u8fc7FFmpeg\u5220\u9664\u67d0\u4e2a\u7279\u5b9a\u97f3\u8f68\uff1f<\/p>\n<p>\u6211\u4eec\u5728\u4e0b\u4e00\u90e8\u5206\u5c06\u5b66\u4e60\u5230\u3002<\/p>\n<p>\u4f7f\u7528FFmpeg\u5220\u9664\u7279\u5b9a\u97f3\u9891\n\u4f60\u53ef\u4ee5\u4f7f\u7528FFmpeg\u4e2d\u7684map\u547d\u4ee4\u6765\u5220\u9664\u7279\u5b9a\u97f3\u8f68\u3002<\/p>\n<p>map\u547d\u4ee4\u7684\u901a\u7528\u8bed\u6cd5\u662f\uff1a<\/p>\n<p>-map input_file_index:stream_type_specifier:stream_index<\/p>\n<p>\u7136\u540e\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7-map 0\ud83c\udd70\ufe0f1\uff08\u4ece0\u5f00\u59cb\u8ba1\u6570\uff09\u4ece\u89c6\u9891\u4e2d\u9009\u62e9\u7b2c\u4e8c\u4e2a\u97f3\u8f68\u3002\u5728\u4e0a\u6587\u7684\u4f8b\u5b50\u4e2d\uff0c\u5982\u679c\u4f60\u7684\u6587\u4ef6\u4e2d\u6709\u4e00\u4e2a\u89c6\u9891\u548c\u4e24\u4e2a\u97f3\u8f68\uff0c\u90a3\u4e48\u4f60\u5c31\u53ef\u4ee5\u4f7f\u7528-map 0\ud83c\udd70\ufe0f1\u53ea\u9009\u62e9\u7b2c\u4e8c\u4e2a\u97f3\u8f68\uff0c\u5e76\u5c06\u5b83\u590d\u5236\u5230\u4f60\u7684\u6700\u7ec8\u8f93\u51fa\u6587\u4ef6\u4e2d\u3002<\/p>\n<p>\u540c\u6837\uff0c-map 0\u662f\u6307\u9009\u62e9\u7b2c\u4e00\u4e2a\u8f93\u5165\u6587\u4ef6\u4e2d\u7684\u6240\u6709\u6570\u636e\uff08\u5305\u62ec\u97f3\u9891\u548c\u89c6\u9891\uff09\uff0c\u6240\u4ee5\u4f60\u9700\u8981\u5148\u9009\u62e9\u6240\u6709\u6570\u636e\uff0c\u7136\u540e\u53d6\u6d88\u9009\u62e9\u97f3\u9891\u3002<\/p>\n<p>ffmpeg.exe -i videoWithAudio.mp4 -map 0 -map 0:a:1 -copy videoOutput.mp4<\/p>\n<p>\u5982\u679c\u7535\u5f71\u4e2d\u67095\u4e2a\u97f3\u8f68\uff0c\u9664\u4e86\u7b2c\u4e00\u4e2a\uff0c\u5176\u4ed6\u4f60\u90fd\u60f3\u9009\u62e9\u3002\u8fd9\u4e2a\u65f6\u5019\u4f60\u53ef\u4ee5\u4f7f\u7528\u53cd\u5411\u7684map\u547d\u4ee4\uff08\u5728map\u547d\u4ee4\u7684\u53c2\u6570\u524d\u52a0\u8d1f\u53f7\uff09\u3002\u4f7f\u7528-map -0\ud83c\udd70\ufe0f0 \u8fd9\u4e00\u547d\u4ee4\uff0cFFmpeg\u5728\u9009\u62e9\u65f6\u5c31\u4f1a\u5ffd\u7565\u7b2c\u4e00\u4e2a\u97f3\u8f68\u3002\u53cd\u5411\u7684map\u975e\u5e38\u5f3a\u5927\uff01<\/p>\n<p>\u5b9e\u9645\u4e0a\uff0c\u6211\u4eec\u5df2\u5728\u524d\u6587\u5b66\u4e60\u4e86\u4f7f\u7528 -an\u547d\u4ee4\u4ece\u89c6\u9891\u4e2d\u5220\u9664\u97f3\u9891\u3002\u4f60\u53ef\u4ee5\u901a\u8fc7\u5982\u4e0b\u65b9\u5f0f\uff0c\u4f7f\u7528\u53cd\u5411\u7684map\u6765\u8fbe\u5230\u76f8\u540c\u7684\u6548\u679c\u3002<\/p>\n<p>ffmpeg -i videoWithAudio.mp4 -map 0 -map -0:a videoWithoutAudio.mp4<\/p>\n<p>\u4f7f\u7528FFmpeg\u6dfb\u52a0\u97f3\u9891\n\u4f60\u5df2\u7ecf\u5220\u9664\u4e86\u4e00\u4e2a\u97f3\u8f68\uff0c\u90a3\u4e48\u4f60\u5f88\u53ef\u80fd\u60f3\u8981\u518d\u6dfb\u52a0\u4e00\u4e2a\uff0c\u5bf9\u5427\uff1f\u4e0b\u9762\u6211\u4eec\u5c06\u5b66\u4e60\u5982\u4f55\u4f7f\u7528FFmpeg\u5411\u89c6\u9891\u4e2d\u6dfb\u52a0\u97f3\u9891\u3002<\/p>\n<p>\u5728\u524d\u6587\u4e2d\u4f60\u5df2\u7ecf\u5b66\u4e60\u4e86map\u547d\u4ee4\u7684\u4f7f\u7528\uff0c\u56e0\u6b64\u6dfb\u52a0\u97f3\u9891\u5bf9\u4f60\u6765\u8bf4\u5e94\u8be5\u5f88\u5bb9\u6613\u3002\u547d\u4ee4\u884c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<p>ffmpeg \\<\/p>\n<p>-i video.mp4 \\<\/p>\n<p>-i audio.mp3 \\<\/p>\n<p>-c copy \\<\/p>\n<p>-map 0:v:0 \\<\/p>\n<p>-map 1:a:0 \\\nvideoWithAudio.mp4<\/p>\n<p>\u4e0a\u9762\u7684\u547d\u4ee4\u884c\u5f88\u5bb9\u6613\u7406\u89e3\u3002\u4f60\u6240\u505a\u7684\u5c31\u662f\u4f7f\u7528map\u547d\u4ee4\u5c06\u89c6\u9891\u548c\u97f3\u9891\u5206\u522b\u4ece\u4e0d\u540c\u7684\u6587\u4ef6\u4e2d\u590d\u5236\u5230\u540c\u4e00\u4e2a\u8f93\u51fa\u6587\u4ef6\u3002<\/p>\n<p>-map 0\u270c\ufe0f0 \u9009\u62e9\u4e86\u7b2c0\u4e2a\u8f93\u5165\u6587\u4ef6\uff08\u89c6\u9891\u8f93\u5165\uff09\u7684\u7b2c0\u4e2a\u8f68\u9053\u3002<\/p>\n<p>\u2013map 1\ud83c\udd70\ufe0f0 \u9009\u62e9\u4e86\u7b2c\u4e00\u4e2a\u8f93\u5165\u6587\u4ef6\uff08\u97f3\u9891\u8f93\u5165\uff09\u7684\u7b2c0\u4e2a\u8f68\u9053\u3002<\/p>\n<p>\u4e0d\u7528\u91cd\u65b0\u7f16\u7801\uff0c-c copy\u540c\u65f6\u590d\u5236\u97f3\u8f68\u548c\u89c6\u8f68\u5230\u8f93\u51fa\u6587\u4ef6\u3002\u5982\u679c\u4f60\u60f3\u8981\u91cd\u65b0\u7f16\u7801\uff0c\u53ef\u4ee5\u9009\u62e9\u5408\u9002\u7684\u97f3\u89c6\u9891\u7f16\u89e3\u7801\u5668\uff0c\u914d\u7f6e\u76f8\u5e94\u7684\u7f16\u7801\u8d28\u91cf\u3002<\/p>\n<p>\u751f\u6210\u9759\u97f3\u6587\u4ef6<\/p>\n<p>ffmpeg -f lavfi -i anullsrc -t 10 silent-audio.mp3<\/p>\n<p>ffplay -f lavfi -i anullsrc=r=44100:cl=stereo -t 10 silent-audio.mp3<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>ffmpeg -i input.wav -af silenceremove=stop_periods=-1:stop_duration=1:stop_threshold=-30dB output.wav<\/p>\n<p>\u526a\u53bb\u6240\u6709\u4ece\u5f00\u59cb\u5230\u7ed3\u675f\u9047\u5230\u7684\u97f3\u9891\u4e2d\u8d85\u8fc71\u79d2\u7684\u9759\u97f3\u7247\u6bb5\uff0c<\/p>\n<p>ffmpeg -i input.wav -af silenceremove=stop_periods=-1:stop_duration=0.3:stop_threshold=-30dB output.wav<\/p>\n<p>\u526a\u53bb\u6240\u6709\u4ece\u5f00\u59cb\u5230\u7ed3\u675f\u9047\u5230\u7684\u97f3\u9891\u4e2d\u8d85\u8fc70.3\u79d2\u7684\u9759\u97f3\u7247\u6bb5\uff0c<\/p>\n<p>&nbsp;<\/p>\n<h1 class=\"postTitle\"><span role=\"heading\" aria-level=\"2\">C# FFmpeg\u5408\u5e76\u591a\u4e2a\u97f3\u9891\u6587\u4ef6\uff0c\u5e76\u6307\u5b9a\u6bcf\u6bb5\u97f3\u9891\u7684\u63d2\u5165\u65f6\u95f4\u3002<\/span><\/h1>\n<div class=\"clear\"><\/div>\n<div class=\"postBody\">\n<div id=\"cnblogs_post_body\" class=\"blogpost-body cnblogs-markdown\">\n\n\u5408\u6210\u97f3\u9891\u7684FFmpeg\u547d\u4ee4\u4e3a\uff1a\nffmpeg -i 11.wav -i 13.wav -filter_complex <span class=\"hljs-string\">&#8220;[0]adelay=1s:all=1[0a];[1]adelay=26s:all=1[1a];[0a][1a]amix=inputs=2[a]&#8221;<\/span> -map <span class=\"hljs-string\">&#8220;[a]&#8221;<\/span> output.wav\n\n\u4e0d\u77e5\u9053\u5177\u4f53\u5565\u610f\u601d\uff0c\u5927\u6982\u731c\u6d4b\u4e00\u4e0b\uff0c\n<code>-i &lt;fileName&gt;<\/code>\u00a0\u8f93\u5165\u6587\u4ef6\u7684\u8def\u5f84\uff0c\u6709\u51e0\u4e2a\u6587\u4ef6\u5c31\u51e0\u4e2a-i\u547d\u4ee4\n<code>[0]adelay=1s:all=1[0a]<\/code>\u00a0[0]\u548c[0a]\u6307\u7684\u662f\u7b2c\u51e0\u4e2a\u6587\u4ef6\uff0c\u7d22\u5f15\u4ece0\u5f00\u59cb\uff0c<code>adelay=1s<\/code>\u00a0\u4ece\u97f3\u9891\u7684\u7b2c\u4e00\u79d2\u5f00\u59cb\u63d2\u5165\uff0c\u9ed8\u8ba4\u662f\u6beb\u79d2\uff0cadelay=1000, \u5982\u679c\u52a0\u540e\u7f00s\uff0c\u5219\u6307\u7684\u79d2\u6570\uff0c\u6b64\u65f6\u4e0d\u652f\u6301\u5c0f\u6570\u4f4d\u5199\u6cd5\u3002\uff084.2\u7248\u672c\u4ee5\u4e0b\u4e0d\u652f\u63011s\u8fd9\u79cd\u5199\u6cd5\uff09\uff0call\uff1aUse last set delay for all remaining channels. By default is disabled. This option if enabled changes how option delays is interpreted.\n<code>amix=inputs=2<\/code>\u00a02\u6307\u7684\u662f\u4e00\u5171\u6709\u51e0\u4e2a\u6587\u4ef6\n<code>output.wav<\/code>\u00a0\u8f93\u51fa\u6587\u4ef6\u7684\u8def\u5f84\u6216\u8005\u6587\u4ef6\u540d\n\u6587\u4ef6\u540d\u90fd\u652f\u6301\u5168\u8def\u5f84\u7684\u5199\u6cd5\u3002\u53ef\u4ee5\u662f\u00a0<code>C:\\Data\\CHN\\Other\\FFmpegMergeMp3\\11.wav<\/code>\u00a0\u4e5f\u53ef\u4ee5\u662f\u00a0<code>11.wav<\/code>\n\n<\/div>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>\u5c06flac\u6587\u4ef6\u8f6c\u6362\u4e3amp3\u6587\u4ef6\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5373\u53ef \uff08\u540c\u65f6\u4f1a\u5c06flac\u6587\u4ef6\u7684Vorbis\u6ce8\u91ca\u8f6c\u6362\u4e3amp3\u7684ID3v2\u5143\u6570\u636e) ffmpeg -i input.flac -ab 320k -map_meta&#46;&#46;&#46;<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,340,16],"tags":[507,522,526],"class_list":["post-2445","post","type-post","status-publish","format-standard","hentry","category-linux","category-mac-os","category-other","tag-ffmpeg","tag-mp3","tag-volume"],"_links":{"self":[{"href":"http:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/posts\/2445","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/comments?post=2445"}],"version-history":[{"count":11,"href":"http:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/posts\/2445\/revisions"}],"predecessor-version":[{"id":2490,"href":"http:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/posts\/2445\/revisions\/2490"}],"wp:attachment":[{"href":"http:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/media?parent=2445"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/categories?post=2445"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/tags?post=2445"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}