Kagami / webm.js

JavaScript WebM converter
https://kagami.github.io/webm.js/
Creative Commons Zero v1.0 Universal
456 stars 33 forks source link

No intermediate status lines in Edge #1

Closed bvibber closed 9 years ago

bvibber commented 9 years ago

Video thread log shows:

$ ffmpeg -ss 0 -hide_banner -i in.webm -c:v libvpx -b:v 885k -speed 4 -auto-alt-ref 1 -lag-in-frames 25 -sn -c:a libopus -b:a 64k -ac 2 -an -pass 1 -f null -t 17 -
[vp8 @ 0x72b3a0] Warning: not compiled with thread support, using thread emulation
[vorbis @ 0x72bac0] Warning: not compiled with thread support, using thread emulation
Input #0, matroska,webm, from 'in.webm':
  Metadata:
    encoder         : Lavf56.40.100
  Duration: 00:01:09.00, start: 0.000000, bitrate: 1683 kb/s
    Stream #0:0: Video: vp8, yuv420p, 853x480, SAR 1:1 DAR 853:480, 24 fps, 24 tbr, 1k tbn, 1k tbc (default)
    Stream #0:1: Audio: vorbis, 48000 Hz, stereo, fltp (default)
[libvpx @ 0x73a450] Warning: not compiled with thread support, using thread emulation
[libvpx @ 0x73a450] v1.4.0
[vp8 @ 0x72da60] Warning: not compiled with thread support, using thread emulation
Output #0, null, to 'pipe:':
  Metadata:
    encoder         : Lavf56.36.100
    Stream #0:0: Video: vp8 (libvpx), yuv420p, 853x480 [SAR 1:1 DAR 853:480], q=-1--1, pass 1, 885 kb/s, 24 fps, 24 tbn, 24 tbc (default)
    Metadata:
      encoder         : Lavc56.41.100 libvpx
Stream mapping:
  Stream #0:0 -> #0:0 (vp8 (native) -> vp8 (libvpx))
Press [q] to stop, [?] for help

and it just stops there (no CPU usage ongoing either), whereas on Firefox it continues running and displays output about frame size/speed/etc.

bvibber commented 9 years ago

Hmmm, no wait it is using the CPU -- just no output.

bvibber commented 9 years ago

Ok at the end it dumps out:


frame=  408 fps=0.0 q=0.0 Lsize=    1827kB time=00:00:16.99 bitrate= 880.3kbits/s    
video:1823kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.195890%

$ ffmpeg -ss 17 -hide_banner -i in.webm -c:v libvpx -b:v 885k -speed 4 -auto-alt-ref 1 -lag-in-frames 25 -sn -c:a libopus -b:a 64k -ac 2 -an -pass 1 -f null -t 17 -
[vp8 @ 0x72b3a0] Warning: not compiled with thread support, using thread emulation
[vorbis @ 0x72bac0] Warning: not compiled with thread support, using thread emulation
Input #0, matroska,webm, from 'in.webm':
  Metadata:
    encoder         : Lavf56.40.100
  Duration: 00:01:09.00, start: 0.000000, bitrate: 1683 kb/s
    Stream #0:0: Video: vp8, yuv420p, 853x480, SAR 1:1 DAR 853:480, 24 fps, 24 tbr, 1k tbn, 1k tbc (default)
    Stream #0:1: Audio: vorbis, 48000 Hz, stereo, fltp (default)
[libvpx @ 0x73a450] Warning: not compiled with thread support, using thread emulation
[libvpx @ 0x73a450] v1.4.0
[vp8 @ 0x72da60] Warning: not compiled with thread support, using thread emulation
Output #0, null, to 'pipe:':
  Metadata:
    encoder         : Lavf56.36.100
    Stream #0:0: Video: vp8 (libvpx), yuv420p, 853x480 [SAR 1:1 DAR 853:480], q=-1--1, pass 1, 885 kb/s, 24 fps, 24 tbn, 24 tbc (default)
    Metadata:
      encoder         : Lavc56.41.100 libvpx
Stream mapping:
  Stream #0:0 -> #0:0 (vp8 (native) -> vp8 (libvpx))
Press [q] to stop, [?] for help
frame=  408 fps=0.0 q=0.0 Lsize=N/A time=00:00:00.00 bitrate=N/A    
video:0kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Output file is empty, nothing was encoded 
$ ffmpeg -ss 17 -hide_banner -i in.webm -c:v libvpx -b:v 885k -speed 1 -auto-alt-ref 1 -lag-in-frames 25 -sn -c:a libopus -b:a 64k -ac 2 -an -pass 2 -t 17 2.webm
[vp8 @ 0x72b370] Warning: not compiled with thread support, using thread emulation
[vorbis @ 0x72ba90] Warning: not compiled with thread support, using thread emulation
Input #0, matroska,webm, from 'in.webm':
  Metadata:
    encoder         : Lavf56.40.100
  Duration: 00:01:09.00, start: 0.000000, bitrate: 1683 kb/s
    Stream #0:0: Video: vp8, yuv420p, 853x480, SAR 1:1 DAR 853:480, 24 fps, 24 tbr, 1k tbn, 1k tbc (default)
    Stream #0:1: Audio: vorbis, 48000 Hz, stereo, fltp (default)
[libvpx @ 0x73a800] Warning: not compiled with thread support, using thread emulation
[libvpx @ 0x73a800] v1.4.0
[vp8 @ 0x72da30] Warning: not compiled with thread support, using thread emulation
Output #0, webm, to '2.webm':
  Metadata:
    encoder         : Lavf56.36.100
    Stream #0:0: Video: vp8 (libvpx), yuv420p, 853x480 [SAR 1:1 DAR 853:480], q=-1--1, pass 2, 885 kb/s, 24 fps, 1k tbn, 24 tbc (default)
    Metadata:
      encoder         : Lavc56.41.100 libvpx
Stream mapping:
  Stream #0:0 -> #0:0 (vp8 (native) -> vp8 (libvpx))
Press [q] to stop, [?] for help
frame=  408 fps=0.0 q=0.0 Lsize=    1836kB time=00:00:16.99 bitrate= 884.6kbits/s    
video:1832kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.195141%

$ ffmpeg -ss 34 -hide_banner -i in.webm -c:v libvpx -b:v 885k -speed 4 -auto-alt-ref 1 -lag-in-frames 25 -sn -c:a libopus -b:a 64k -ac 2 -an -pass 1 -f null -t 17 -
[vp8 @ 0x72b3a0] Warning: not compiled with thread support, using thread emulation
[vorbis @ 0x72bac0] Warning: not compiled with thread support, using thread emulation
Input #0, matroska,webm, from 'in.webm':
  Metadata:
    encoder         : Lavf56.40.100
  Duration: 00:01:09.00, start: 0.000000, bitrate: 1683 kb/s
    Stream #0:0: Video: vp8, yuv420p, 853x480, SAR 1:1 DAR 853:480, 24 fps, 24 tbr, 1k tbn, 1k tbc (default)
    Stream #0:1: Audio: vorbis, 48000 Hz, stereo, fltp (default)
[libvpx @ 0x73a450] Warning: not compiled with thread support, using thread emulation
[libvpx @ 0x73a450] v1.4.0
[vp8 @ 0x72da60] Warning: not compiled with thread support, using thread emulation
Output #0, null, to 'pipe:':
  Metadata:
    encoder         : Lavf56.36.100
    Stream #0:0: Video: vp8 (libvpx), yuv420p, 853x480 [SAR 1:1 DAR 853:480], q=-1--1, pass 1, 885 kb/s, 24 fps, 24 tbn, 24 tbc (default)
    Metadata:
      encoder         : Lavc56.41.100 libvpx
Stream mapping:
  Stream #0:0 -> #0:0 (vp8 (native) -> vp8 (libvpx))
Press [q] to stop, [?] for help
frame=  408 fps=0.0 q=0.0 Lsize=N/A time=00:00:00.00 bitrate=N/A    
video:0kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Output file is empty, nothing was encoded 
$ ffmpeg -ss 34 -hide_banner -i in.webm -c:v libvpx -b:v 885k -speed 1 -auto-alt-ref 1 -lag-in-frames 25 -sn -c:a libopus -b:a 64k -ac 2 -an -pass 2 -t 17 3.webm
[vp8 @ 0x72b370] Warning: not compiled with thread support, using thread emulation
[vorbis @ 0x72ba90] Warning: not compiled with thread support, using thread emulation
Input #0, matroska,webm, from 'in.webm':
  Metadata:
    encoder         : Lavf56.40.100
  Duration: 00:01:09.00, start: 0.000000, bitrate: 1683 kb/s
    Stream #0:0: Video: vp8, yuv420p, 853x480, SAR 1:1 DAR 853:480, 24 fps, 24 tbr, 1k tbn, 1k tbc (default)
    Stream #0:1: Audio: vorbis, 48000 Hz, stereo, fltp (default)
[libvpx @ 0x73a800] Warning: not compiled with thread support, using thread emulation
[libvpx @ 0x73a800] v1.4.0
[vp8 @ 0x72da30] Warning: not compiled with thread support, using thread emulation
Output #0, webm, to '3.webm':
  Metadata:
    encoder         : Lavf56.36.100
    Stream #0:0: Video: vp8 (libvpx), yuv420p, 853x480 [SAR 1:1 DAR 853:480], q=-1--1, pass 2, 885 kb/s, 24 fps, 1k tbn, 24 tbc (default)
    Metadata:
      encoder         : Lavc56.41.100 libvpx
Stream mapping:
  Stream #0:0 -> #0:0 (vp8 (native) -> vp8 (libvpx))
Press [q] to stop, [?] for help
frame=  408 fps=0.0 q=0.0 Lsize=    1843kB time=00:00:17.00 bitrate= 887.9kbits/s    
video:1839kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.196056%

$ ffmpeg -ss 51 -hide_banner -i in.webm -c:v libvpx -b:v 885k -speed 4 -auto-alt-ref 1 -lag-in-frames 25 -sn -c:a libopus -b:a 64k -ac 2 -an -pass 1 -f null -
[vp8 @ 0x72b370] Warning: not compiled with thread support, using thread emulation
[vorbis @ 0x72ba90] Warning: not compiled with thread support, using thread emulation
Input #0, matroska,webm, from 'in.webm':
  Metadata:
    encoder         : Lavf56.40.100
  Duration: 00:01:09.00, start: 0.000000, bitrate: 1683 kb/s
    Stream #0:0: Video: vp8, yuv420p, 853x480, SAR 1:1 DAR 853:480, 24 fps, 24 tbr, 1k tbn, 1k tbc (default)
    Stream #0:1: Audio: vorbis, 48000 Hz, stereo, fltp (default)
[libvpx @ 0x73a420] Warning: not compiled with thread support, using thread emulation
[libvpx @ 0x73a420] v1.4.0
[vp8 @ 0x72da30] Warning: not compiled with thread support, using thread emulation
Output #0, null, to 'pipe:':
  Metadata:
    encoder         : Lavf56.36.100
    Stream #0:0: Video: vp8 (libvpx), yuv420p, 853x480 [SAR 1:1 DAR 853:480], q=-1--1, pass 1, 885 kb/s, 24 fps, 24 tbn, 24 tbc (default)
    Metadata:
      encoder         : Lavc56.41.100 libvpx
Stream mapping:
  Stream #0:0 -> #0:0 (vp8 (native) -> vp8 (libvpx))
Press [q] to stop, [?] for help
frame=  432 fps=0.0 q=0.0 Lsize=N/A time=00:00:00.00 bitrate=N/A    
video:0kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Output file is empty, nothing was encoded 
$ ffmpeg -ss 51 -hide_banner -i in.webm -c:v libvpx -b:v 885k -speed 1 -auto-alt-ref 1 -lag-in-frames 25 -sn -c:a libopus -b:a 64k -ac 2 -an -pass 2 4.webm
[vp8 @ 0x72b2f0] Warning: not compiled with thread support, using thread emulation
[vorbis @ 0x72ba10] Warning: not compiled with thread support, using thread emulation
Input #0, matroska,webm, from 'in.webm':
  Metadata:
    encoder         : Lavf56.40.100
  Duration: 00:01:09.00, start: 0.000000, bitrate: 1683 kb/s
    Stream #0:0: Video: vp8, yuv420p, 853x480, SAR 1:1 DAR 853:480, 24 fps, 24 tbr, 1k tbn, 1k tbc (default)
    Stream #0:1: Audio: vorbis, 48000 Hz, stereo, fltp (default)
[libvpx @ 0x731250] Warning: not compiled with thread support, using thread emulation
[libvpx @ 0x731250] v1.4.0
[vp8 @ 0x72cee0] Warning: not compiled with thread support, using thread emulation
Output #0, webm, to '4.webm':
  Metadata:
    encoder         : Lavf56.36.100
    Stream #0:0: Video: vp8 (libvpx), yuv420p, 853x480 [SAR 1:1 DAR 853:480], q=-1--1, pass 2, 885 kb/s, 24 fps, 1k tbn, 24 tbc (default)
    Metadata:
      encoder         : Lavc56.41.100 libvpx
Stream mapping:
  Stream #0:0 -> #0:0 (vp8 (native) -> vp8 (libvpx))
Press [q] to stop, [?] for help
frame=  432 fps=0.0 q=0.0 Lsize=    1940kB time=00:00:18.00 bitrate= 883.1kbits/s    
video:1937kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.193688%

$ ffmpeg -hide_banner -i in.webm -c:v libvpx -b:v 885k -sn -c:a libopus -b:a 64k -ac 2 -vn audio.webm
[vp8 @ 0x72b1a0] Warning: not compiled with thread support, using thread emulation
[vorbis @ 0x72b8c0] Warning: not compiled with thread support, using thread emulation
Input #0, matroska,webm, from 'in.webm':
  Metadata:
    encoder         : Lavf56.40.100
  Duration: 00:01:09.00, start: 0.000000, bitrate: 1683 kb/s
    Stream #0:0: Video: vp8, yuv420p, 853x480, SAR 1:1 DAR 853:480, 24 fps, 24 tbr, 1k tbn, 1k tbc (default)
    Stream #0:1: Audio: vorbis, 48000 Hz, stereo, fltp (default)
[libopus @ 0x72ddc0] Warning: not compiled with thread support, using thread emulation
[vorbis @ 0x7c4070] Warning: not compiled with thread support, using thread emulation
Output #0, webm, to 'audio.webm':
  Metadata:
    encoder         : Lavf56.36.100
    Stream #0:0: Audio: opus (libopus), 48000 Hz, stereo, flt, 64 kb/s (default)
    Metadata:
      encoder         : Lavc56.41.100 libopus
Stream mapping:
  Stream #0:1 -> #0:0 (vorbis (native) -> opus (libopus))
Press [q] to stop, [?] for help
size=     546kB time=00:01:09.01 bitrate=  64.8kbits/s    
video:0kB audio:522kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 4.631801%

$ ffmpeg -hide_banner -f concat -i list.txt -i audio.webm -c copy out.webm
[vp8 @ 0x732800] Warning: not compiled with thread support, using thread emulation
[vp8 @ 0x732ef0] Warning: not compiled with thread support, using thread emulation
Input #0, concat, from 'list.txt':
  Duration: N/A, start: 0.000000, bitrate: N/A

'Preview' button gives a broken video player (expected), but Download does nothing.

So, no console update during the run, and no download after finished.

otherwise seems to run :D

Kagami commented 9 years ago

Thanks for report!

So we have several problems here (unfortunately I don't have IE to test it by myself, but will do my best to fix it).

First one should be somewhere around this line: https://github.com/Kagami/ffmpeg.js/blob/master/build/post-worker.js#L8 Code seems to be generic, but maybe Emscripten handles stdout on IE in different way. Are there some errors in console? I will publish version with some debug enabled to check what's going on.

Second one seems to be expected - IE doesn't support download attribute at all. Huh. But luckily it supports non-standard msSaveBlob! Will use it on IE instead.

Kagami commented 9 years ago

There are some problems with downloading on Safari as well. FileSaver.js points location to Blob URL and it seems to be working: https://github.com/eligrey/FileSaver.js/blob/master/FileSaver.js#L102

Kagami commented 9 years ago

So I pushed fix for IE/Safari and add also some debug to makeOutHandler (console.log(String.fromCharCode(arguments[0]), arguments[1]);).

Test version is available here: https://kagami.github.io/webm.js/test/ Could you please try it? Make sure to set some small encode duration like 0.1 because it will print a lot to console.

Kagami commented 9 years ago

Also there was error in makeOutHandler function, it didn't handle UTF-8 in the ffmpeg's output correctly. I pushed all fixes to the product version (https://kagami.github.io/webm.js/), could you please try it too?

bvibber commented 9 years ago

Hmm, the version at https://kagami.github.io/webm.js/ still doesn't update the log windows in Edge... it also seems to really be heavy on the main thread; tab is very sluggish while it's running.

Kagami commented 9 years ago

Have you been able to download the result? Can you play it? Are there something in browser console in test version during the run? (Beware that it might print a lot.)

it also seems to really be heavy on the main thread

It shouldn't be related to the problem, I'm experiencing the same on Firefox while encoding is in progress. Probably it's just the result of heavy CPU load in workers so main UI thread doesn't get enough CPU time, though I haven't profiled it yet.

bvibber commented 9 years ago

Didn't let it go to completion... Heavy CPU load in workers should normally have no affect on the UI thread whatsoever; is something sending many messages between the worker and UI thread perhaps?

bvibber commented 9 years ago

Ok, did a quick profile in Firefox... every time a message comes through from a worker thread, it takes a solid chunk of 100-200ms to update some sort of JS-framework widgets on the UI thread. Call stacks are dozens deep. These happen constantly, as in as soon as one's done another one comes through and gets processed too.

graph-of-doom
bvibber commented 9 years ago

I'm pretty sure I did not see this slowdown in Firefox a few days ago; UI thread seemed to be clear (at least the browser remained responsive, I didn't profile it then.) Seems to be a serious regression?

Kagami commented 9 years ago

Thanks for the investigation. It could be React component rendering (you can check it by expanding the DOM events and looking at stack at the right), though it doesn't cause that major slowdown in my tests. I will look whether I can optimize it further of course. Are you by chance using test version? I have ~45fps avg with Firefox 40, sample video and default settings on a normal version.

Kagami commented 9 years ago

Downloading is now fixed in Edge (not yet released). Looking into log/slowness issues. At least encoding with duration=0.1 works and it's possible to download result.

Kagami commented 9 years ago

It seems to be the only remaining issue is slowness. Best result that I was able to get so far with Edge:

[16:17:26] Spawning jobs:
[16:17:26]   1 video thread
[16:17:26]   1 audio thread
[16:17:26] Video 1 started first pass
[16:17:26] Audio started
[16:20:19] Audio finished (00:02:52.2)
[16:20:37] Video 1 finished first pass (00:03:10.4)
[16:20:40] Video 1 started second pass
[16:21:26] Video 1 finished second pass (00:00:49.3)
[16:21:27] Muxer started
[16:21:52] Muxer finished (00:00:25)
==================================================
All is done in 00:04:28.5
Output duration: 00:00:00.1
Output file size: 1516 B, 1.48 KiB
Output video bitrate: 655296k
Output audio bitrate: 64k

Firefox/Chrome encode same 0.1 in 3 seconds. I have no idea why Edge can't optimize asm.js: they claim that it should work fast and I also have asm.js enabled in settings.

@brion do you have any experience with asm.js in Edge? I can't google any docs/hings related to that. Maybe it doesn't like something in my compiled ffmpeg build and deoptimize it...

Kagami commented 9 years ago

It turned out slowness was the result of nonoptimal VM settings. Now I can encode 0.1 in ~15 seconds which is fast enough.

And the bug with the lack of intermediate log lines still persists. I added debug to stdout handler and can say that nothing is being passed to that function. It might be nasty Emscripten or Edge bug.

Kagami commented 9 years ago

Hah, it should be some nasty bug indeed. I added debug before this line and I got negative/wrong values in Edge and correct in FF.

Kagami commented 9 years ago

The problem was in CLOCK_MONOTONIC - Edge doesn't support that. I published new version, everything should work now.