FFMPEG图像+音乐=视频

时间:2017-09-20 17:20:14

标签: ffmpeg

从图像(1080p .png)+音乐(320Kb mp3)尝试使用youtube视频。

    ffmpeg -loop 1 -i image.png -i music.mp3 -c:a copy -c:v libx264 -crf 0 -preset veryslow -shortest output.mp4

但转换是缓慢的。 任何想法,它如何优化? E:_TEST>ffmpeg -loop 1 -i image0.png -i music0.mp3 -c:a aac -c:v libx264 -crf 0 -preset veryfast -shortest video0.mp4 ffmpeg version N-87306-g6743351 Copyright (c) 2000-2017 the FFmpeg developers built with gcc 7.2.0 (GCC) configuration: --enable-gpl --enable-version3 --enable-cuda --enable-cuvid --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib libavutil 55. 75.100 / 55. 75.100 libavcodec 57.106.101 / 57.106.101 libavformat 57. 82.100 / 57. 82.100 libavdevice 57. 8.101 / 57. 8.101 libavfilter 6.105.100 / 6.105.100 libswscale 4. 7.103 / 4. 7.103 libswresample 2. 8.100 / 2. 8.100 libpostproc 54. 6.100 / 54. 6.100 Input #0, png_pipe, from 'image0.png': Duration: N/A, bitrate: N/A Stream #0:0: Video: png, rgb24(pc), 1920x1080, 25 fps, 25 tbr, 25 tbn, 25 tbc Input #1, mp3, from 'music0.mp3': Metadata: encoder : Lavf57.56.101 Duration: 01:00:33.06, start: 0.025057, bitrate: 128 kb/s Stream #1:0: Audio: mp3, 44100 Hz, stereo, s16p, 128 kb/s Metadata: encoder : Lavc57.64 Stream mapping: Stream #0:0 -> #0:0 (png (native) -> h264 (libx264)) Stream #1:0 -> #0:1 (mp3 (native) -> aac (native)) Press [q] to stop, [?] for help [libx264 @ 0000000002d3f320] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX XOP FMA3 BMI1 [libx264 @ 0000000002d3f320] profile High 4:4:4 Predictive, level 4.0, 4:4:4 8-bit [libx264 @ 0000000002d3f320] 264 - core 152 r2851 ba24899 - H.264/MPEG-4 AVC codec - Copyleft 2003-2017 - http://www.videolan.org/x264.html - options: cabac=1 ref=1 deblock=1:0:0 analyse=0x1:0x111 me=hex subme=2 psy=0 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=0 chroma_qp_offset=0 threads=12 lookahead_threads=4 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=1 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc=cqp mbtree=0 qp=0 Output #0, mp4, to 'video0.mp4': Metadata: encoder : Lavf57.82.100 Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv444p(progressive), 1920x1080, q=-1--1, 25 fps, 12800 tbn, 25 tbc Metadata: encoder : Lavc57.106.101 libx264 Side data: cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1 Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s Metadata: encoder : Lavc57.106.101 aac frame= 107 fps= 40 q=-1.0 Lsize= 778kB time=00:00:04.24 bitrate=1503.5kbits/s speed=1.57x

2 个答案:

答案 0 :(得分:1)

ffmpeg -loop 1 -framerate 1 -i image.png -i music.mp3 -c:v libx264 -crf 0 -preset veryfast -tune stillimage -c:a copy -shortest output.mkv
  • 使用1的帧速率。
  • 只是复用音频并避免重新编码音频。
  • 使用Matroska输出格式代替MP4来处理几乎任何音频格式。

输出可能在某些播放器中不起作用,但在YouTube中可以正常使用。

答案 1 :(得分:0)

ffmpeg -loop 1 -i image.png -i music.mp3 -c:a aac -c:v libx264 -crf 0 -preset veryfast -shortest output.mp4

那会更快。