合并一张幻灯片,音频使用ffmpeg-输出仅在视频容器中的音频(一张幻灯片在vid tr中)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了合并一张幻灯片,音频使用ffmpeg-输出仅在视频容器中的音频(一张幻灯片在vid tr中)相关的知识,希望对你有一定的参考价值。

podcast to youtube . the output will upload ok using mpeg container for audio only
2 examples:
2 pass libx264
output .wmv file
  1. =============== 2 pass libx264 example outputs mp4 file with low video bandwidth
  2.  
  3. ./ffmpeg -y -loop_input -shortest -i test_album_cover.png -i rec_1448.3gpp -pass 1 -vframes 500
  4. -vcodec libx264 -r 1/100 -vf 'scale=320:180' -b 2k -g 250 -b_strategy 0 -coder 1 -qmin 10 -qmax 55 -sc_threshold 40
  5. -flags -loop -subq 1 -i_qfactor 0.71 -qcomp 0.6 -qdiff 4
  6. -flags2 +dct8x8+wpred+bpyramid+mixed_refs -trellis 1
  7. -partitions +parti8x8+parti4x4+partp8x8+partp4x4+partb8x8
  8. -acodec libmp3lame -ac 1 -ar 22050 -ab 22k t_album.mp4
  9.  
  10. ffmpeg version N-30956-g81ef892, Copyright (c) 2000-2011 the FFmpeg developers
  11. built on Jun 22 2011 17:37:00 with gcc 4.5.3
  12. configuration: --enable-gpl --enable-version3 --enable-memalign-hack --enable-runtime-cpudetect --enable-avisynth --enable-bzlib --enable-frei0r --enable-libo
  13. pencore-amrnb --enable-libopencore-amrwb --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-libopenjpeg --enable-librtmp --enable-libschroedinger
  14. --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
  15. libavutil 51. 9. 1 / 51. 9. 1
  16. libavcodec 53. 7. 0 / 53. 7. 0
  17. libavformat 53. 4. 0 / 53. 4. 0
  18. libavdevice 53. 1. 1 / 53. 1. 1
  19. libavfilter 2. 23. 0 / 2. 23. 0
  20. libswscale 2. 0. 0 / 2. 0. 0
  21. libpostproc 51. 2. 0 / 51. 2. 0
  22. [image2 @ 000000000026BA60] max_analyze_duration 5000000 reached at 5000000
  23. Input #0, image2, from 'test_album_cover.png':
  24. Duration: 00:00:00.04, start: 0.000000, bitrate: N/A
  25. Stream #0.0: Video: png, rgb24, 671x799, 25 fps, 25 tbr, 25 tbn, 25 tbc
  26. Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'rec_1448.3gpp':
  27. Metadata:
  28. major_brand : 3gp4
  29. minor_version : 0
  30. compatible_brands: isom3gp4
  31. Duration: 00:02:55.76, start: 0.000000, bitrate: 5 kb/s
  32. Stream #1.0(eng): Audio: amrnb, 8000 Hz, 1 channels, flt, 5 kb/s
  33. Incompatible sample format 'flt' for codec 'libmp3lame', auto-selecting format 's16'
  34. Incompatible pixel format 'rgb24' for codec 'libx264', auto-selecting format 'yuv420p'
  35. [buffer @ 0000000000306CE0] w:671 h:799 pixfmt:rgb24 tb:1/1000000 sar:0/1 sws_param:
  36. [scale @ 0000000000306DE0] w:671 h:799 fmt:rgb24 -> w:320 h:180 fmt:yuv420p flags:0x4
  37. [libx264 @ 000000000026A540] using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.1 Cache64
  38. [libx264 @ 000000000026A540] profile Main, level 1.1
  39. [libx264 @ 000000000026A540] 264 - core 115 r2008 4c552d8 - H.264/MPEG-4 AVC codec - Copyleft 2003-2011 - http://www.videolan.org/x264.html - options: cabac=1 r
  40. ef=1 deblock=0:0:0 analyse=0x1:0 me=dia subme=1 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=4 chroma_me=0 trellis=0 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 c
  41. hroma_qp_offset=0 threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=2 keyint=250 keyint_min=25 scene
  42. cut=40 intra_refresh=0 rc_lookahead=40 rc=abr mbtree=1 bitrate=2 ratetol=1.0 qcomp=0.60 qpmin=10 qpmax=55 qpstep=4 ip_ratio=1.41 aq=1:1.00
  43. Output #0, mp4, to 't_album_cover.mp4':
  44. Metadata:
  45. encoder : Lavf53.4.0
  46. Stream #0.0: Video: libx264, yuv420p, 320x180, q=10-55, pass 1, 2 kb/s, 1 tbn, 0.01 tbc
  47. Stream #0.1(eng): Audio: libmp3lame, 22050 Hz, 1 channels, s16, 22 kb/s
  48. Stream mapping:
  49. Stream #0.0 -> #0.0
  50. Stream #1.0 -> #0.1
  51. Press [q] to stop, [?] for help
  52. Warning, using s16 intermediate sample format for resamplingitrate= 0.0kbits/s dup=0 drop=99698
  53. frame= 43 fps= 0 q=13.0 Lsize= 575kB time=00:02:55.83 bitrate= 26.8kbits/s dup=0 drop=102209
  54. video:6kB audio:515kB global headers:0kB muxing overhead 10.379900%
  55. frame I:1 Avg QP:10.00 size: 2777
  56. [libx264 @ 000000000026A540] frame P:42 Avg QP:10.44 size: 61
  57. [libx264 @ 000000000026A540] mb I I16..4: 79.6% 0.0% 20.4%
  58. [libx264 @ 000000000026A540] mb P I16..4: 21.2% 0.0% 0.0% P16..4: 0.8% 0.0% 0.0% 0.0% 0.0% skip:78.0%
  59. [libx264 @ 000000000026A540] final ratefactor: -23.41
  60. [libx264 @ 000000000026A540] coded y,uvDC,uvAC intra: 1.6% 2.6% 2.5% inter: 0.2% 0.0% 0.0%
  61. [libx264 @ 000000000026A540] i16 v,h,dc,p: 98% 2% 0% 0%
  62. [libx264 @ 000000000026A540] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 39% 38% 19% 0% 2% 0% 1% 0% 2%
  63. [libx264 @ 000000000026A540] i8c dc,h,v,p: 37% 62% 1% 0%
  64. [libx264 @ 000000000026A540] Weighted P-Frames: Y:0.0% UV:0.0%
  65. [libx264 @ 000000000026A540] kb/s:0.01
  66.  
  67. pass #2:
  68.  
  69. ./ffmpeg -y -loop_input -shortest -i test_album_cover.png -i rec_1448.3gpp -pass 2 -vframes 500
  70. -vcodec libx264 -r 1/100 -vf 'scale=320:180' -b 2k -g 250 -b_strategy 0 -coder 1 -qmin 10 -qmax 55 -sc_threshold 40
  71. -flags -loop -subq 1 -i_qfactor 0.71 -qcomp 0.6 -qdiff 4
  72. -flags2 +dct8x8+wpred+bpyramid+mixed_refs -trellis 1
  73. -partitions +parti8x8+parti4x4+partp8x8+partp4x4+partb8x8
  74. -acodec libmp3lame -ac 1 -ar 22050 -ab 22k t_album.mp4
  75.  
  76.  
  77. ffmpeg version N-30956-g81ef892, Copyright (c) 2000-2011 the FFmpeg developers
  78. built on Jun 22 2011 17:37:00 with gcc 4.5.3
  79. configuration: --enable-gpl --enable-version3 --enable-memalign-hack --enable-runtime-cpudetect --enable-avisynth --enable-bzlib --enable-frei0r --enable-libo
  80. pencore-amrnb --enable-libopencore-amrwb --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-libopenjpeg --enable-librtmp --enable-libschroedinger
  81. --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
  82. libavutil 51. 9. 1 / 51. 9. 1
  83. libavcodec 53. 7. 0 / 53. 7. 0
  84. libavformat 53. 4. 0 / 53. 4. 0
  85. libavdevice 53. 1. 1 / 53. 1. 1
  86. libavfilter 2. 23. 0 / 2. 23. 0
  87. libswscale 2. 0. 0 / 2. 0. 0
  88. libpostproc 51. 2. 0 / 51. 2. 0
  89. [image2 @ 000000000035BA60] max_analyze_duration 5000000 reached at 5000000
  90. Input #0, image2, from 'test_album_cover.png':
  91. Duration: 00:00:00.04, start: 0.000000, bitrate: N/A
  92. Stream #0.0: Video: png, rgb24, 671x799, 25 fps, 25 tbr, 25 tbn, 25 tbc
  93. Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'rec_1448.3gpp':
  94. Metadata:
  95. major_brand : 3gp4
  96. minor_version : 0
  97. compatible_brands: isom3gp4
  98. Duration: 00:02:55.76, start: 0.000000, bitrate: 5 kb/s
  99. Stream #1.0(eng): Audio: amrnb, 8000 Hz, 1 channels, flt, 5 kb/s
  100. Incompatible sample format 'flt' for codec 'libmp3lame', auto-selecting format 's16'
  101. Incompatible pixel format 'rgb24' for codec 'libx264', auto-selecting format 'yuv420p'
  102. [buffer @ 00000000002D6CE0] w:671 h:799 pixfmt:rgb24 tb:1/1000000 sar:0/1 sws_param:
  103. [scale @ 00000000002D6DE0] w:671 h:799 fmt:rgb24 -> w:320 h:180 fmt:yuv420p flags:0x4
  104. [libx264 @ 000000000035A540] using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.1 Cache64
  105. [libx264 @ 000000000035A540] Error: 2pass curve failed to converge
  106. [libx264 @ 000000000035A540] target: 2.00 kbit/s, expected: 0.01 kbit/s, avg QP: 10.0000
  107. [libx264 @ 000000000035A540] try reducing target bitrate or reducing qp_min (currently 10)
  108. [libx264 @ 000000000035A540] profile High, level 1.1
  109. [libx264 @ 000000000035A540] 264 - core 115 r2008 4c552d8 - H.264/MPEG-4 AVC codec - Copyleft 2003-2011 - http://www.videolan.org/x264.html - options: cabac=1 r
  110. ef=1 deblock=0:0:0 analyse=0x3:0x133 me=dia subme=1 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=4 chroma_me=0 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip
  111. =1 chroma_qp_offset=0 threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=2 keyint=250 keyint_min=25 s
  112. cenecut=40 intra_refresh=0 rc_lookahead=40 rc=2pass mbtree=1 bitrate=2 ratetol=1.0 qcomp=0.60 qpmin=10 qpmax=55 qpstep=4 cplxblur=20.0 qblur=0.5 ip_ratio=1.41 a
  113. q=1:1.00
  114. Output #0, mp4, to 't_album_cover.mp4':
  115. Metadata:
  116. encoder : Lavf53.4.0
  117. Stream #0.0: Video: libx264, yuv420p, 320x180, q=10-55, pass 2, 2 kb/s, 1 tbn, 0.01 tbc
  118. Stream #0.1(eng): Audio: libmp3lame, 22050 Hz, 1 channels, s16, 22 kb/s
  119. Stream mapping:
  120. Stream #0.0 -> #0.0
  121. Stream #1.0 -> #0.1
  122. Press [q] to stop, [?] for help
  123. Warning, using s16 intermediate sample format for resampling
  124. frame= 3 fps= 0 q=12.0 Lsize= 573kB time=00:02:55.83 bitrate= 26.7kbits/s dup=0 drop=2248
  125. video:4kB audio:515kB global headers:0kB muxing overhead 10.362358%
  126. frame I:1 Avg QP:10.00 size: 2940
  127. [libx264 @ 000000000035A540] frame P:2 Avg QP:10.03 size: 93
  128. [libx264 @ 000000000035A540] mb I I16..4: 77.9% 2.5% 19.6%
  129. [libx264 @ 000000000035A540] mb P I16..4: 21.3% 0.0% 0.0% P16..4: 2.9% 0.0% 0.0% 0.0% 0.0% skip:75.8%
  130. [libx264 @ 000000000035A540] 8x8 transform intra:1.8% inter:70.0%
  131. [libx264 @ 000000000035A540] coded y,uvDC,uvAC intra: 10.3% 18.1% 16.4% inter: 0.9% 1.1% 0.0%
  132. [libx264 @ 000000000035A540] i16 v,h,dc,p: 87% 13% 0% 0%
  133. [libx264 @ 000000000035A540] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 0% 33% 54% 0% 8% 0% 4% 0% 0%
  134. [libx264 @ 000000000035A540] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 39% 44% 13% 0% 1% 0% 0% 0% 2%
  135. [libx264 @ 000000000035A540] i8c dc,h,v,p: 29% 63% 9% 0%
  136. [libx264 @ 000000000035A540] Weighted P-Frames: Y:0.0% UV:0.0%
  137. [libx264 @ 000000000035A540] kb/s:0.08
  138.  
  139.  
  140. =============== output .wmv file
  141.  
  142. FFMPEG_HOME=C:/e/utility/ffmpeg-git-81ef892-win64-static
  143. FFMPEG_DATADIR=$MPEG_HOME/presets
  144.  
  145. $FFMPEG_HOME/bin/ffmpeg -loop_input -r ntsc -i Optimized-DSC01459.JPG -i rec_1459.3gpp -r .2 -s 640x480 -b 100k -bt 240k -acodec libmp3lame -ar 22050 -vcodec libx264 -vpre ipod640 -crf 22 -threads 0 -shortest e:/movies/dev/output_r.mp4
  146.  
  147. --stdout
  148.  
  149.  
  150. Input #0, image2, from 'Optimized-DSC01459.JPG':
  151. Duration: 00:00:00.03, start: 0.000000, bitrate: N/A
  152. Stream #0.0: Video: mjpeg, yuvj420p, 1200x798 [PAR 96:96 DAR 200:133], 29.97 fps, 29.97 tbr, 29.97 tbn, 29.97 tbc
  153. Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'rec_1459.3gpp':
  154. Metadata:
  155. major_brand : 3gp4
  156. minor_version : 0
  157. compatible_brands: isom3gp4
  158. Duration: 00:02:33.62, start: 0.000000, bitrate: 5 kb/s
  159. Stream #1.0(eng): Audio: amrnb, 8000 Hz, 1 channels, flt, 5 kb/s
  160. Incompatible sample format 'flt' for codec 'libmp3lame', auto-selecting format 's16'
  161. File 'e:/movies/dev/output_r.mp4' already exists. Overwrite ? [y/N] y
  162. [buffer @ 0000000004B4E6A0] w:1200 h:798 pixfmt:yuvj420p tb:1/1000000 sar:96/96 sws_param:
  163. [scale @ 0000000004B4E7A0] w:1200 h:798 fmt:yuvj420p -> w:640 h:480 fmt:yuvj420p flags:0x4
  164. [libx264 @ 0000000001E49460] Default settings detected, using medium profile
  165. [libx264 @ 0000000001E49460] using SAR=1/1
  166. [libx264 @ 0000000001E49460] using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.1 Cache64
  167. [libx264 @ 0000000001E49460] VBV buffer size cannot be smaller than one frame, using 49999 kbit
  168. [libx264 @ 0000000001E49460] profile High, level 3.0
  169. [libx264 @ 0000000001E49460] 264 - core 115 r2008 4c552d8 - H.264/MPEG-4 AVC codec - Copyleft 2003-2011 - http://www.videolan.org/x264.html - options: cabac=1 r
  170. ef=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pski
  171. p=1 chroma_qp_offset=-2 threads=3 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 dir
  172. ect=1 weightb=1 open_gop=0 weightp=0 keyint=250 keyint_min=1 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=22.0 qcomp=0.60 qpmin=0 qpmax=69 qp
  173. step=4 vbv_maxrate=10000 vbv_bufsize=49999 crf_max=0.0 nal_hrd=none ip_ratio=1.40 aq=1:1.00
  174. Output #0, mp4, to 'e:/movies/dev/output_r.mp4':
  175. Metadata:
  176. encoder : Lavf53.4.0
  177. Stream #0.0: Video: libx264, yuvj420p, 640x480 [PAR 96:96 DAR 4:3], q=2-31, 100 kb/s, 1 tbn, 0.20 tbc
  178. Stream #0.1(eng): Audio: libmp3lame, 22050 Hz, 1 channels, s16, 64 kb/s
  179. Stream mapping:
  180. Stream #0.0 -> #0.0
  181. Stream #1.0 -> #0.1
  182. Press [q] to stop, [?] for help
  183. [libx264 @ 0000000001E49460] VBV buffer size cannot be smaller than one frame, using 49999 kbit
  184. Warning, using s16 intermediate sample format for resamplingitrate= 0.0kbits/s dup=0 drop=6825
  185. Last message repeated 1 times 1340kB time=00:02:30.00 bitrate= 73.2kbits/s dup=0 drop=11563
  186. frame= 80 fps= 1 q=29.0 Lsize= 1457kB time=00:02:33.67 bitrate= 77.7kbits/s dup=0 drop=11595
  187. video:208kB audio:1201kB global headers:0kB muxing overhead 3.437844%
  188. frame I:1 Avg QP:10.49 size:211039
  189. [libx264 @ 0000000001E49460] frame P:20 Avg QP:21.57 size: 24
  190. [libx264 @ 0000000001E49460] frame B:59 Avg QP:29.00 size: 19
  191. [libx264 @ 0000000001E49460] consecutive B-frames: 1.3% 0.0% 3.8% 95.0%
  192. [libx264 @ 0000000001E49460] mb I I16..4: 0.2% 17.6% 82.3%
  193. [libx264 @ 0000000001E49460] mb P I16..4: 0.0% 0.0% 0.0% P16..4: 0.1% 0.0% 0.0% 0.0% 0.0% skip:99.9%
  194. [libx264 @ 0000000001E49460] mb B I16..4: 0.0% 0.0% 0.0% B16..8: 0.0% 0.0% 0.0% direct: 0.0% skip:100.0% L0:-1.$% L1:-1.$% BI:-1.$%
  195. [libx264 @ 0000000001E49460] 8x8 transform intra:17.6%
  196. [libx264 @ 0000000001E49460] coded y,uvDC,uvAC intra: 99.6% 98.3% 97.5% inter: 0.0% 0.0% 0.0%
  197. [libx264 @ 0000000001E49460] i16 v,h,dc,p: 0% 50% 0% 50%
  198. [libx264 @ 0000000001E49460] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 16% 28% 13% 6% 6% 6% 7% 6% 12%
  199. [libx264 @ 0000000001E49460] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 20% 15% 11% 8% 7% 10% 9% 9% 12%
  200. [libx264 @ 0000000001E49460] i8c dc,h,v,p: 44% 24% 23% 10%
  201. [libx264 @ 0000000001E49460] kb/s:4.25
  202. bench: utime=122.055s maxrss=98648kB

以上是关于合并一张幻灯片,音频使用ffmpeg-输出仅在视频容器中的音频(一张幻灯片在vid tr中)的主要内容,如果未能解决你的问题,请参考以下文章

ffmpeg图片转视频,图片+音频合成视频每秒一张图

ffmpeg合并音频和视频

将youtube上传的幻灯片和音频与ffmpeg合并

在颤动中合并视频和音频

一次用ffmpeg实现图片+音频合成视频的开发

如何在ffmpeg中合并音频和两个视频文件?