Я использую ffmpeg для создания видео. Источником является набор изображений PNG (по одному на кадр) и mp3-файл. Я хочу создать MP4 со звуком.
Я делаю это в два этапа на данный момент. Шаг первый преобразует PNG в MP4:
%d%\ffmpeg -r 25 -i png\%1-%%06d.png -s 1280x720 -c:v libx264 -pix_fmt yuv420p -b:v 500k -profile:v baseline -movflags faststart temp.mp4
Шаг второй объединяет звук и временный mp4:
%d%\ffmpeg -i temp.mp4 -i %1\%1.mp3 %1.mp4
Это работает, но звук очень плохой. Я думаю, что это делает mp3 для AAC.
Итак, я попробовал это:
%d%\ffmpeg -i temp.mp4 -i %1\%1.mp3 -c copy -map 0:0 -map 1:0 %1.mp4
У меня нет звука. Я перепробовал много других опций, другие кодеки, изменил другие параметры звука, но у меня нет звука.
Кажется, что единственный способ получить звук - оставить звук по умолчанию, а это слишком низкое качество.
РЕДАКТИРОВАТЬ здесь вывод
C:\ffmpeg\bin\ffmpeg -r 25 -i png\scene2-%06d.png -s 1280x720 -c:v libx264 -pix_fmt yuv420p
-b:v 500k -profile:v baseline -movflags faststart temp.mp4
ffmpeg version N-57057-g024bf3a Copyright (c) 2000-2013 the FFmpeg developers
built on Oct 11 2013 18:01:59 with gcc 4.8.1 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-av
isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab
le-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetyp
e --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --ena
ble-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-l
ibopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libsp
eex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aa
cenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavp
ack --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
libavutil 52. 46.101 / 52. 46.101
libavcodec 55. 35.100 / 55. 35.100
libavformat 55. 19.100 / 55. 19.100
libavdevice 55. 4.100 / 55. 4.100
libavfilter 3. 88.101 / 3. 88.101
libswscale 2. 5.101 / 2. 5.101
libswresample 0. 17.103 / 0. 17.103
libpostproc 52. 3.100 / 52. 3.100
Input #0, image2, from 'png\scene2-%06d.png':
Duration: 00:00:13.00, start: 0.000000, bitrate: N/A
Stream #0:0: Video: png, rgba, 1280x720 [SAR 3779:3779 DAR 16:9], 25 fps, 25
tbr, 25 tbn, 25 tbc
[libx264 @ 003f36a0] using SAR=1/1
[libx264 @ 003f36a0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.1 Cache64
[libx264 @ 003f36a0] profile Constrained Baseline, level 3.1
[libx264 @ 003f36a0] 264 - core 138 r2358 9e941d1 - H.264/MPEG-4 AVC codec - Cop
yleft 2003-2013 - http://www.videolan.org/x264.html - options: cabac=0 ref=3 deb
lock=1:0:0 analyse=0x1:0x111 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 m
e_range=16 chroma_me=1 trellis=1 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chro
ma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 i
nterlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=250 k
eyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=abr mbtree=1 bitrate
=500 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'temp.mp4':
Metadata:
encoder : Lavf55.19.100
Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 1280x7
20 [SAR 1:1 DAR 16:9], q=-1--1, 500 kb/s, 12800 tbn, 25 tbc
Stream mapping:
Stream #0:0 -> #0:0 (png -> libx264)
Press [q] to stop, [?] for help
frame= 57 fps= 56 q=35.0 size= 16kB time=00:00:00.40 bitrate= 320.3kbits/
frame= 84 fps= 55 q=26.0 size= 39kB time=00:00:01.48 bitrate= 214.0kbits/
frame= 113 fps= 56 q=19.0 size= 60kB time=00:00:02.64 bitrate= 186.0kbits/
frame= 141 fps= 55 q=21.0 size= 152kB time=00:00:03.76 bitrate= 332.0kbits/
frame= 167 fps= 55 q=24.0 size= 268kB time=00:00:04.80 bitrate= 457.8kbits/
frame= 190 fps= 53 q=25.0 size= 353kB time=00:00:05.72 bitrate= 506.2kbits/
frame= 213 fps= 52 q=26.0 size= 412kB time=00:00:06.64 bitrate= 508.0kbits/
frame= 238 fps= 52 q=23.0 size= 419kB time=00:00:07.64 bitrate= 449.1kbits/
frame= 262 fps= 51 q=22.0 size= 454kB time=00:00:08.60 bitrate= 432.5kbits/
frame= 286 fps= 51 q=22.0 size= 523kB time=00:00:09.56 bitrate= 448.1kbits/
frame= 309 fps= 50 q=25.0 size= 660kB time=00:00:10.48 bitrate= 515.8kbits/
[mp4 @ 003f3160] Starting second pass: moving the moov atom to the beginning of
the file
frame= 325 fps= 47 q=-1.0 Lsize= 794kB time=00:00:13.00 bitrate= 500.5kbits
/s
video:792kB audio:0kB subtitle:0 global headers:0kB muxing overhead 0.256995%
[libx264 @ 003f36a0] frame I:2 Avg QP:13.55 size: 24853
[libx264 @ 003f36a0] frame P:323 Avg QP:15.10 size: 2356
[libx264 @ 003f36a0] mb I I16..4: 91.3% 0.0% 8.8%
[libx264 @ 003f36a0] mb P I16..4: 1.5% 0.0% 0.2% P16..4: 2.4% 1.0% 0.4%
0.0% 0.0% skip:94.5%
[libx264 @ 003f36a0] final ratefactor: 19.04
[libx264 @ 003f36a0] coded y,uvDC,uvAC intra: 6.3% 15.8% 12.8% inter: 1.3% 2.5%
1.4%
[libx264 @ 003f36a0] i16 v,h,dc,p: 82% 17% 2% 0%
[libx264 @ 003f36a0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 39% 18% 25% 3% 3% 4% 3%
2% 3%
[libx264 @ 003f36a0] i8c dc,h,v,p: 69% 23% 8% 1%
[libx264 @ 003f36a0] ref P L0: 75.5% 14.7% 9.8%
[libx264 @ 003f36a0] kb/s:498.84
C:\ffmpeg\bin\ffmpeg -i temp.mp4 -i scene2\scene2.mp3 -c copy -map 0:0 -map 1:0 scene2.mp4
ffmpeg version N-57057-g024bf3a Copyright (c) 2000-2013 the FFmpeg developers
built on Oct 11 2013 18:01:59 with gcc 4.8.1 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-av
isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab
le-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetyp
e --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --ena
ble-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-l
ibopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libsp
eex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aa
cenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavp
ack --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
libavutil 52. 46.101 / 52. 46.101
libavcodec 55. 35.100 / 55. 35.100
libavformat 55. 19.100 / 55. 19.100
libavdevice 55. 4.100 / 55. 4.100
libavfilter 3. 88.101 / 3. 88.101
libswscale 2. 5.101 / 2. 5.101
libswresample 0. 17.103 / 0. 17.103
libpostproc 52. 3.100 / 52. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'temp.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf55.19.100
Duration: 00:00:13.00, start: 0.000000, bitrate: 500 kb/s
Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yu
v420p, 1280x720 [SAR 1:1 DAR 16:9], 499 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc
(default)
Metadata:
handler_name : VideoHandler
Input #1, mp3, from 'scene2\scene2.mp3':
Metadata:
genre : Blues
Duration: 00:00:09.86, start: 0.000000, bitrate: 128 kb/s
Stream #1:0: Audio: mp3, 16000 Hz, mono, s16p, 128 kb/s
Output #0, mp4, to 'scene2.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf55.19.100
Stream #0:0(und): Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 1280x720 [S
AR 1:1 DAR 16:9], q=2-31, 499 kb/s, 25 fps, 12800 tbn, 12800 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1: Audio: mp3 (i[0][0][0] / 0x0069), 16000 Hz, mono, 128 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #1:0 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame= 325 fps=0.0 q=-1.0 Lsize= 951kB time=00:00:12.96 bitrate= 601.4kbits
/s
video:792kB audio:154kB subtitle:0 global headers:0kB muxing overhead 0.540095%
EDIT добавил вывод для -i scene2.mp4
C:\ffmpeg\bin\ffmpeg -i scene2.mp4
ffmpeg version N-57057-g024bf3a Copyright (c) 2000-2013 the FFmpeg developers
built on Oct 11 2013 18:01:59 with gcc 4.8.1 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-av
isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab
le-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetyp
e --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --ena
ble-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-l
ibopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libsp
eex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aa
cenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavp
ack --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
libavutil 52. 46.101 / 52. 46.101
libavcodec 55. 35.100 / 55. 35.100
libavformat 55. 19.100 / 55. 19.100
libavdevice 55. 4.100 / 55. 4.100
libavfilter 3. 88.101 / 3. 88.101
libswscale 2. 5.101 / 2. 5.101
libswresample 0. 17.103 / 0. 17.103
libpostproc 52. 3.100 / 52. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'scene2.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf55.19.100
Duration: 00:00:13.00, start: 0.000000, bitrate: 599 kb/s
Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yu
v420p, 1280x720 [SAR 1:1 DAR 16:9], 499 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc
(default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: mp3 (mp4a / 0x6134706D), 16000 Hz, mono, s16p, 128
kb/s (default)
Metadata:
handler_name : SoundHandler
At least one output file must be specified