New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PNG files to MP4 #20

Open
tolstenko opened this Issue Aug 13, 2016 · 5 comments

Comments

Projects
None yet
3 participants
@tolstenko

tolstenko commented Aug 13, 2016

Hello!

I am trying to figure out how to create a video from PNGs. If I use the same console arguments it doesnt work with the ffmpeg-mp4.js. Could you please clarify me about how to include the PNG feature in the JS compilation? Do you have some workaround(convert to another supported image file)? Thanks.

I add the PNG data using the pngjs this way:

var blobs = [];
for(...){
var png = new Png({width:series.images[i].getCols(), height:series.images[i].getRows()});
png.data = rainbow;
var buff = Png.sync.write(png);
blobs.push({ name: "rainbow"+zeroPad(i,3)+".png", data: buff});
}

And I call the ffmpeg.js this way:

var result = ffmpeg({
  MEMFS: blobs,
  arguments: ["-i", "rainbow%03d.png", "-c:v", "libx264", "-pix_fmt", "yuv420p", "outputhsvh264_420.mp4"],
  stdin: function() {},
});

Here is the output differences between the js and the console version:

ffmpeg version n3.1.2 Copyright (c) 2000-2016 the FFmpeg developers
  built with emcc (Emscripten gcc/clang-like replacement) 1.36.0 (commit 07b87426f898d6e9c677db291d9088c839197291)
  configuration: --cc=emcc --enable-cross-compile --target-os=none --arch=x86 --disable-runtime-cpudetect --disable-asm --disable-fast-unaligned --disable-pthreads --disable-w32threads --disable-os2threads --disable-debug --disable-stripping --disable-all --enable-ffmpeg --enable-avcodec --enable-avformat --enable-avutil --enable-swresample --enable-swscale --enable-avfilter --disable-network --disable-d3d11va --disable-dxva2 --disable-vaapi --disable-vda --disable-vdpau --enable-decoder=vp8 --enable-decoder=vp9 --enable-decoder=theora --enable-decoder=mpeg2video --enable-decoder=mpeg4 --enable-decoder=h264 --enable-decoder=hevc --enable-decoder=png --enable-decoder=mjpeg --enable-decoder=vorbis --enable-decoder=opus --enable-decoder=mp3 --enable-decoder=ac3 --enable-decoder=aac --enable-decoder=ass --enable-decoder=ssa --enable-decoder=srt --enable-decoder=webvtt --enable-demuxer=matroska --enable-demuxer=ogg --enable-demuxer=avi --enable-demuxer=mov --enable-demuxer=flv --enable-demuxer=mpegps --enable-demuxer=image2 --enable-demuxer=mp3 --enable-demuxer=concat --enable-protocol=file --enable-filter=aresample --enable-filter=scale --enable-filter=crop --disable-bzlib --disable-iconv --disable-libxcb --disable-lzma --disable-sdl --disable-securetransport --disable-xlib --disable-zlib --enable-encoder=libx264 --enable-encoder=libmp3lame --enable-encoder=aac --enable-muxer=mp4 --enable-muxer=mp3 --enable-muxer=null --enable-gpl --enable-libmp3lame --enable-libx264 --extra-cflags=-I../lame/dist/include --extra-ldflags=-L../lame/dist/lib
  libavutil      55. 28.100 / 55. 28.100
  libavcodec     57. 48.101 / 57. 48.101
  libavformat    57. 41.100 / 57. 41.100
  libavfilter     6. 47.100 /  6. 47.100
  libswscale      4.  1.100 /  4.  1.100
  libswresample   2.  1.100 /  2.  1.100
[image2 @ 0x809250] Could not find codec parameters for stream 0 (Video: png, none): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Input #0, image2, from 'rainbow%03d.png':
  Duration: 00:00:19.56, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: png, none, 25 fps, 25 tbr, 25 tbn, 25 tbc
No decoder for stream #0:0, filtering impossible
Error opening filters!
Tolsta-i5-osx:out tolstenko$ time ffmpeg -i rainbow%03d.png -codec:v libx264 -pix_fmt yuv420p -b:v 5000k outputhsvh264_420.mp4
ffmpeg version N-81085-gdb8e8c9 Copyright (c) 2000-2016 the FFmpeg developers
  built with Apple LLVM version 7.3.0 (clang-703.0.29)
  configuration: --prefix=/usr/local --enable-gpl --enable-nonfree --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxvid --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-opencl --enable-libx264 --enable-libmp3lame --enable-libxvid --enable-libfreetype --enable-libvorbis --enable-libvpx --enable-libass --enable-ffplay --enable-libfdk-aac --enable-libopus --enable-libx265 --disable-lzma --enable-nonfree --enable-vda
  libavutil      55. 28.100 / 55. 28.100
  libavcodec     57. 50.100 / 57. 50.100
  libavformat    57. 44.100 / 57. 44.100
  libavdevice    57.  0.102 / 57.  0.102
  libavfilter     6. 47.100 /  6. 47.100
  libavresample   3.  0.  0 /  3.  0.  0
  libswscale      4.  1.100 /  4.  1.100
  libswresample   2.  1.100 /  2.  1.100
  libpostproc    54.  0.100 / 54.  0.100
Input #0, image2, from 'rainbow%03d.png':
  Duration: 00:00:19.56, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: png, rgba(pc), 512x512, 25 fps, 25 tbr, 25 tbn, 25 tbc
[libx264 @ 0x7fca0a811200] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
[libx264 @ 0x7fca0a811200] profile High, level 3.0
[libx264 @ 0x7fca0a811200] 264 - core 148 r2668 fd2c324 - H.264/MPEG-4 AVC codec - Copyleft 2003-2016 - http://www.videolan.org/x264.html - options: cabac=1 ref=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_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 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 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=abr mbtree=1 bitrate=5000 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
[mp4 @ 0x7fca0a810000] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
Output #0, mp4, to 'outputhsvh264_420.mp4':
  Metadata:
    encoder         : Lavf57.44.100
    Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 512x512, q=-1--1, 5000 kb/s, 25 fps, 12800 tbn, 25 tbc
    Metadata:
      encoder         : Lavc57.50.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/5000000 buffer size: 0 vbv_delay: -1
Stream mapping:
  Stream #0:0 -> #0:0 (png (native) -> h264 (libx264))
Press [q] to stop, [?] for help
frame=  489 fps=111 q=-1.0 Lsize=   12062kB time=00:00:19.44 bitrate=5082.8kbits/s speed= 4.4x    
video:12056kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.050887%
[libx264 @ 0x7fca0a811200] frame I:2     Avg QP:10.07  size: 69428
[libx264 @ 0x7fca0a811200] frame P:296   Avg QP:14.67  size: 33398
[libx264 @ 0x7fca0a811200] frame B:191   Avg QP:16.59  size: 12145
[libx264 @ 0x7fca0a811200] consecutive B-frames: 21.9% 78.1%  0.0%  0.0%
[libx264 @ 0x7fca0a811200] mb I  I16..4: 12.3% 49.7% 38.0%
[libx264 @ 0x7fca0a811200] mb P  I16..4:  0.4%  6.8%  2.1%  P16..4: 26.7% 25.8% 24.4%  0.0%  0.0%    skip:13.8%
[libx264 @ 0x7fca0a811200] mb B  I16..4:  0.1%  0.2%  0.1%  B16..8: 19.3%  5.9%  4.4%  direct:26.4%  skip:43.6%  L0:22.4% L1:39.7% BI:37.9%
[libx264 @ 0x7fca0a811200] final ratefactor: 14.10
[libx264 @ 0x7fca0a811200] 8x8 transform intra:71.2% inter:42.8%
[libx264 @ 0x7fca0a811200] coded y,uvDC,uvAC intra: 89.4% 74.7% 73.7% inter: 42.8% 44.3% 39.2%
[libx264 @ 0x7fca0a811200] i16 v,h,dc,p: 41% 21% 35%  2%
[libx264 @ 0x7fca0a811200] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu:  5% 11% 42%  5%  8%  5% 11%  4%  9%
[libx264 @ 0x7fca0a811200] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 10% 15% 15%  8% 12%  8% 14%  7% 12%
[libx264 @ 0x7fca0a811200] i8c dc,h,v,p: 70% 14%  7%  9%
[libx264 @ 0x7fca0a811200] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x7fca0a811200] ref P L0: 67.4% 11.2% 13.1%  8.3%
[libx264 @ 0x7fca0a811200] ref B L0: 93.3%  6.7%
[libx264 @ 0x7fca0a811200] kb/s:5048.76

real    0m12.635s
user    0m15.591s
sys 0m0.305s

Could you please share a working ffmpeg.js compiled with all supported codecs? I know it is bigger, but many of us devs just want to try out the functionalities and check your solution. When it will be need to improve, we will compile tuning as you brilliantly do.

Thanks again for you efforts.

@Kagami

This comment has been minimized.

Show comment
Hide comment
@Kagami

Kagami Aug 14, 2016

Owner

Could you please clarify me about how to include the PNG feature in the JS compilation?

I'm planning to include to PNG decoder but currently it's blocked by kripken/emscripten#4478 (Well not really, it's possible to workaround in varous ways, just haven't had enough time for this.)

Do you have some workaround(convert to another supported image file)?

JPEG decoding is supported, see #18.

Could you please share a working ffmpeg.js compiled with all supported codecs? I know it is bigger, but many of us devs just want to try out the functionalities and check your solution.

I will consider that, thanks.

Owner

Kagami commented Aug 14, 2016

Could you please clarify me about how to include the PNG feature in the JS compilation?

I'm planning to include to PNG decoder but currently it's blocked by kripken/emscripten#4478 (Well not really, it's possible to workaround in varous ways, just haven't had enough time for this.)

Do you have some workaround(convert to another supported image file)?

JPEG decoding is supported, see #18.

Could you please share a working ffmpeg.js compiled with all supported codecs? I know it is bigger, but many of us devs just want to try out the functionalities and check your solution.

I will consider that, thanks.

@tolstenko

This comment has been minimized.

Show comment
Hide comment
@tolstenko

tolstenko Aug 15, 2016

Thanks. I will use JPEG instead.

tolstenko commented Aug 15, 2016

Thanks. I will use JPEG instead.

@uqee

This comment has been minimized.

Show comment
Hide comment
@uqee

uqee Sep 28, 2017

Well not really, it's possible to workaround in varous ways, just haven't had enough time for this.

Please, share these ways with us. I'm ready to create a PR for that.

uqee commented Sep 28, 2017

Well not really, it's possible to workaround in varous ways, just haven't had enough time for this.

Please, share these ways with us. I'm ready to create a PR for that.

@Kagami

This comment has been minimized.

Show comment
Hide comment
@Kagami

Kagami Sep 28, 2017

Owner

Hm, I don't remember now.
Maybe it would be enough to fix ffmpeg configure script.

Owner

Kagami commented Sep 28, 2017

Hm, I don't remember now.
Maybe it would be enough to fix ffmpeg configure script.

@uqee

This comment has been minimized.

Show comment
Hide comment
@uqee

uqee Oct 2, 2017

A dirty hack to enable png support:
uqee@732d5e1

P.S. /root in my --extra-cflags is just a value of $HOME, but it doesn't work if specified that way, dunno why

uqee commented Oct 2, 2017

A dirty hack to enable png support:
uqee@732d5e1

P.S. /root in my --extra-cflags is just a value of $HOME, but it doesn't work if specified that way, dunno why

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment