Deconvolution layer FCN initialization - loss drops too fast - caffe

I'm training a small (10M weights on 12K images) FCN (see e.g. Long et al, 2015). The architecture is the following (it starts with FCN8s fc7 layer):
fc7->relu1->dropout->conv2048->conv1024->conv512->deconv1->deconv2->deconv3->deconv4->deconv5->crop->softmax_with_loss
When I initialized all deconv layers with Gaussian weights, I got some (though not always) reasonable result. Then I decided to do it the right way, and used the scripts provided by Shelhamer (e.g. https://github.com/zeakey/DeepSkeleton/blob/master/examples/DeepSkeleton/solve.py)
The Deconvolution layers look like this (first one):
layer {
name: "upscore2"
type: "Deconvolution"
bottom: "upsample"
top: "upscore2"
param {
lr_mult: 2
}
convolution_param {
# num output: number of channels, our cow+bgr
num_output: 2
kernel_size: 8
stride: 2
bias_term: false
}
}
The output I get is really weird: loss drop fast (1000 generations), and stays at around 1, but the model is entirely useless on the test set. Any suggestions? I reduced the learning rate, but nothing seems to be working.
net: "mcn-train_finetune11_slow_bilinear.prototxt"
solver_mode: GPU
# REDUCE LEARNING RATE
base_lr: 1e-8
lr_policy: "fixed"
iter_size: 1
max_iter: 100000
# REDUCE MOMENTUM TO 0.5
momentum: 0.5
weight_decay: 0.016
test_interval: 1000
test_iter: 125
display: 1000
average_loss: 1000
type: "Nesterov"
snapshot: 1000
snapshot_prefix: "mcn_finetune11_slow_bilinear"
debug_info: false
PS: a short printout of training
I0723 08:38:56.772249 29191 solver.cpp:272] Solving MyCoolNetwork, MCN
I0723 08:38:56.772260 29191 solver.cpp:273] Learning Rate Policy: fixed
I0723 08:38:56.775032 29191 solver.cpp:330] Iteration 0, Testing net (#0)
I0723 08:39:02.331010 29191 blocking_queue.cpp:49] Waiting for data
I0723 08:39:18.075814 29191 solver.cpp:397] Test net output #0: loss = 37.8394 (* 1 = 37.8394 loss)
I0723 08:39:18.799008 29191 solver.cpp:218] Iteration 0 (-2.90699e-35 iter/s, 22.0247s/1000 iters), loss = 42.4986
I0723 08:39:18.799057 29191 solver.cpp:237] Train net output #0: loss = 42.4986 (* 1 = 42.4986 loss)
I0723 08:39:18.799067 29191 sgd_solver.cpp:105] Iteration 0, lr = 1e-08
I0723 08:46:12.581365 29201 data_layer.cpp:73] Restarting data prefetching from start.
I0723 08:46:12.773717 29200 data_layer.cpp:73] Restarting data prefetching from start.
I0723 08:51:14.609473 29191 solver.cpp:447] Snapshotting to binary proto file mcn_finetune11_slow_bilinear_iter_1000.caffemodel
I0723 08:51:15.245028 29191 sgd_solver.cpp:273] Snapshotting solver state to binary proto file mcn_finetune11_slow_bilinear_iter_1000.solverstate
I0723 08:51:15.298612 29191 solver.cpp:330] Iteration 1000, Testing net (#0)
I0723 08:51:20.888267 29203 data_layer.cpp:73] Restarting data prefetching from start.
I0723 08:51:21.194495 29202 data_layer.cpp:73] Restarting data prefetching from start.
I0723 08:51:36.276700 29191 solver.cpp:397] Test net output #0: loss = 1.18519 (* 1 = 1.18519 loss)
I0723 08:51:36.886041 29191 solver.cpp:218] Iteration 1000 (1.35488 iter/s, 738.075s/1000 iters), loss = 3.89015
I0723 08:51:36.887783 29191 solver.cpp:237] Train net output #0: loss = 1.82311 (* 1 = 1.82311 loss)
I0723 08:51:36.887807 29191 sgd_solver.cpp:105] Iteration 1000, lr = 1e-08
I0723 08:53:34.997433 29201 data_layer.cpp:73] Restarting data prefetching from start.
I0723 08:53:35.040670 29200 data_layer.cpp:73] Restarting data prefetching from start.
I0723 09:00:35.779531 29201 data_layer.cpp:73] Restarting data prefetching from start.
I0723 09:00:35.791441 29200 data_layer.cpp:73] Restarting data prefetching from start.
I0723 09:03:31.710410 29191 solver.cpp:447] Snapshotting to binary proto file mcn_finetune11_slow_bilinear_iter_2000.caffemodel
I0723 09:03:32.383363 29191 sgd_solver.cpp:273] Snapshotting solver state to binary proto file mcn_finetune11_slow_bilinear_iter_2000.solverstate
I0723 09:03:32.09 29203 data_layer.cpp:73] Restarting data prefetching from start.
I0723 09:03:44.351140 29202 data_layer.cpp:73] Restarting data prefetching from start.
I0723 09:03:52.166584 29191 solver.cpp:397] Test net output #0: loss = 1.14507 (* 1 = 1.14507 loss)
I0723 09:03:52.777982 29191 solver.cpp:218] Iteration 2000 (1.35892 iter/s, 735.881s/1000 iters), loss = 2.60843
I0723 09:03:52.778029 29191 solver.cpp:237] Train net output #0: loss = 3.07199 (* 1 = 3.07199 loss)
I0723 09:03:52.778038 29191 sgd_solver.cpp:105] Iteration 2000, lr = 1e-08
I0723 09:07:57.400295 29201 data_layer.cpp:73] Restarting data prefetching from start.
I0723 09:07:57.448870 29200 data_layer.cpp:73] Restarting data prefetching from start.
I0723 09:14:58.070508 29201 data_layer.cpp:73] Restarting data prefetching from start.
I0723 09:14:58.100841 29200 data_layer.cpp:73] Restarting data prefetching from start.
I0723 09:15:48.708067 29191 solver.cpp:447] Snapshotting to binary proto file mcn_finetune11_slow_bilinear_iter_3000.caffemodel
I0723 09:15:49.358572 29191 sgd_solver.cpp:273] Snapshotting solver state to binary proto file mcn_finetune11_slow_bilinear_iter_3000.solverstate
I0723 09:15:49.411862 29191 solver.cpp:330] Iteration 3000, Testing net (#0)
I0723 09:16:05.268878 29203 data_layer.cpp:73] Restarting data prefetching from start.
I0723 09:16:05.502995 29202 data_layer.cpp:73] Restarting data prefetching from start.
I0723 09:16:08.177001 29191 solver.cpp:397] Test net output #0: loss = 1.115 (* 1 = 1.115 loss)
I0723 09:16:08.767503 29191 solver.cpp:218] Iteration 3000 (1.35874 iter/s, 735.979s/1000 iters), loss = 2.57038
I0723 09:16:08.768218 29191 solver.cpp:237] Train net output #0: loss = 2.33784 (* 1 = 2.33784 loss)
I0723 09:16:08.768534 29191 sgd_solver.cpp:105] Iteration 3000, lr = 1e-08
I0723 09:22:16.315538 29201 data_layer.cpp:73] Restarting data prefetching from start.
I0723 09:22:16.349555 29200 data_layer.cpp:73] Restarting data prefetching from start.

Related

FFmpeg eats all the memory and crash within a minute while recording chrome activity

I'm using ffmpeg to capture the activity of chrome (thanks to chrome driver) and record it into an mp4 file. However, the memory consumed by ffmpeg is quickly blowing up, and after a minute or so my 8GB of memory get saturated and I have to reboot the PC.
Unbuntu 16.0
ALSA loopback (installed by modprobe snd-aloop)
ffmpeg version 4.2.2-1ubuntu1~16.04.york0
This is the command line to ffmpeg:
ffmpeg -y -v info -f x11grab -draw_mouse 0 -r 30 -s 1280x720 -thread_queue_size 4096
-i :0.0+0,0 -f alsa -thread_queue_size 4096 -i plug:cloop -acodec aac -strict -2 -ar 44100
-c:v libx264 -preset veryfast -profile:v main -level 3.1 -pix_fmt yuv420p -r 30
-crf 25 -g 60 -tune zerolatency -f mp4 file.mp4
If I remove all the sound input (-i plug:cloop -acodec aac -strict -2 -ar 44100) then the memory is OK, stable, but the file generated can't be played with VLC or media player.
The logs from ffmpeg looks normal to me:
root$ ffmpeg -rtbufsize 15M -y -v info -f x11grab -draw_mouse 0 -r 30 -s 1280x720 -thread_queue_size 4096 -i :0.0+0,0 -f alsa -thread_queue_size 4096 -i hw:0 -acodec ac3_fixed -strict -2 -ar 44100 -c:v libx264 -preset veryfast -profile:v main -level 3.1 -pix_fmt yuv420p -r 30 -crf 25 -g 60 -tune zerolatency -f mp4 /tmp/recordings/stuff.mp4
ffmpeg version 2.8.15-0ubuntu0.16.04.1 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.10) 20160609
configuration: --prefix=/usr --extra-version=0ubuntu0.16.04.1 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-libx264 --enable-libopencv
libavutil 54. 31.100 / 54. 31.100
libavcodec 56. 60.100 / 56. 60.100
libavformat 56. 40.101 / 56. 40.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 40.101 / 5. 40.101
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.101 / 1. 2.101
libpostproc 53. 3.100 / 53. 3.100
Input #0, x11grab, from ':0.0+0,0':
Duration: N/A, start: 1587042601.295126, bitrate: N/A
Stream #0:0: Video: rawvideo (BGR[0] / 0x524742), bgr0, 1280x720, 30 fps, 30 tbr, 1000k tbn, 30 tbc
Guessed Channel Layout for Input Stream #1.0 : stereo
Input #1, alsa, from 'hw:0':
Duration: N/A, start: 1587042601.304179, bitrate: 1536 kb/s
Stream #1:0: Audio: pcm_s16le, 48000 Hz, 2 channels, s16, 1536 kb/s
[libx264 # 0x928ee0] using cpu capabilities: MMX2 SSE Cache64
[libx264 # 0x928ee0] profile Main, level 3.1
Output #0, mpegts, to '/tmp/recordings/stuff.ts':
Metadata:
encoder : Lavf56.40.101
Stream #0:0: Video: h264 (libx264), yuv420p, 1280x720, q=-1--1, 30 fps, 90k tbn, 30 tbc
Metadata:
encoder : Lavc56.60.100 libx264
Stream #0:1: Audio: ac3 (ac3_fixed), 44100 Hz, stereo, s16p, 192 kb/s
Metadata:
encoder : Lavc56.60.100 ac3_fixed
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264))
Stream #1:0 -> #0:1 (pcm_s16le (native) -> ac3 (ac3_fixed))
Press [q] to stop, [?] for help
frame= 7 fps=0.0 q=21.0 size= 5kB time=00:00:00.23 bitrate= 180.5kbits/s frame= 15 fps= 15 q=21.0 size= 15kB time=00:00:00.50 bitrate= 240.6kbits/s frame= 21 fps= 14 q=21.0 size= 21kB time=00:00:00.70 bitrate= 249.2kbits/s frame= 28 fps= 14 q=21.0 size= 28kB time=00:00:00.93 bitrate= 246.5kbits/s frame= 35 fps= 13 q=21.0 size= 35kB time=00:00:01.16 bitrate= 244.9kbits/s frame= 42 fps= 13 q=21.0 size= 44kB time=00:00:01.40 bitrate= 260.0kbits/s frame= 49 fps= 13 q=21.0 size= 51kB time=00:00:01.63 bitrate= 256.9kbits/s frame= 56 fps= 13 q=21.0 size= 58kB time=00:00:01.86 bitrate= 254.6kbits/s frame= 63 fps= 13 q=22.0 size= 66kB time=00:00:02.10 bitrate= 255.7kbits/s frame= 70 fps= 13 q=21.0 size= 75kB time=00:00:02.33 bitrate= 263.0kbits/s frame= 77 fps= 13 q=21.0 size= 82kB time=00:00:02.56 bitrate= 261.3kbits/s frame= 79 fps= 13 q=21.0 Lsize= 85kB time=00:00:02.63 bitrate= 264.4kbits/s
video:8kB audio:61kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 22.604090%
[libx264 # 0x928ee0] frame I:2 Avg QP: 5.10 size: 760
[libx264 # 0x928ee0] frame P:77 Avg QP: 6.78 size: 88
[libx264 # 0x928ee0] mb I I16..4: 99.9% 0.0% 0.1%
[libx264 # 0x928ee0] mb P I16..4: 0.0% 0.0% 0.0% P16..4: 0.0% 0.0% 0.0% 0.0% 0.0% skip:100.0%
[libx264 # 0x928ee0] coded y,uvDC,uvAC intra: 0.0% 0.1% 0.0% inter: 0.0% 0.0% 0.0%
[libx264 # 0x928ee0] i16 v,h,dc,p: 91% 0% 9% 0%
[libx264 # 0x928ee0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 0% 0% 100% 0% 0% 0% 0% 0% 0%
[libx264 # 0x928ee0] i8c dc,h,v,p: 98% 2% 0% 0%
[libx264 # 0x928ee0] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 # 0x928ee0] kb/s:25.23
Exiting normally, received signal 2.
This is my .asoundrc file.
# playback PCM device: using loopback subdevice 0,0
pcm.amix {
type dmix
ipc_key 219345
slave.pcm "hw:Loopback,0,0"
}
# capture PCM device: using loopback subdevice 0,1
pcm.asnoop {
type dsnoop
ipc_key 219346
slave.pcm "hw:Loopback,0,1"
}
# duplex device combining our PCM devices defined above
pcm.aduplex {
type asym
playback.pcm "amix"
capture.pcm "asnoop"
}
# ------------------------------------------------------
# for jack alsa_in and alsa_out: looped-back signal at other ends
pcm.ploop {
type plug
slave.pcm "hw:Loopback,1,1"
}
pcm.cloop {
type dsnoop
ipc_key 219348
slave.pcm "hw:Loopback,1,0"
}
# ------------------------------------------------------
# default device
pcm.!default {
type plug
slave.pcm "aduplex"
}
I'm not sure how to debug this kind of issue, any idea why the memory blow up so fast like that ?

How do I specify num_test_nets in restart?

I trained a GoogleNet model for a while, and now I'd like to restart from a checkpoint, adding a test phase. I have the test already in my train_val.prototxt file, and I added the proper parameters to my solver.prototxt ... but I get an error on the restart:
I0712 15:53:02.615947 47646 net.cpp:278] This network produces output loss2/loss1
I0712 15:53:02.615964 47646 net.cpp:278] This network produces output loss3/loss3
I0712 15:53:02.616109 47646 net.cpp:292] Network initialization done.
F0712 15:53:02.616665 47646 solver.cpp:128] Check failed: param_.test_iter_size() == num_test_nets (1 vs. 0) test_iter must be specified for each test network.
*** Check failure stack trace: ***
# 0x7f550cf70e6d (unknown)
# 0x7f550cf72ced (unknown)
# 0x7f550cf70a5c (unknown)
# 0x7f550cf7363e (unknown)
# 0x7f550d3b605b caffe::Solver<>::InitTestNets()
# 0x7f550d3b63ed caffe::Solver<>::Init()
# 0x7f550d3b6738 caffe::Solver<>::Solver()
# 0x7f550d4fa633 caffe::Creator_SGDSolver<>()
# 0x7f550da5bb76 caffe::SolverRegistry<>::CreateSolver()
# 0x7f550da548f4 train()
# 0x7f550da52316 main
# 0x7f5508f43b15 __libc_start_main
# 0x7f550da52d3d (unknown)
solver.prototxt
train_net: "<my_path>/train_val.prototxt"
test_iter: 1000
test_interval: 4000
test_initialization: false
display: 40
average_loss: 40
base_lr: 0.01
lr_policy: "step"
stepsize: 320000
gamma: 0.96
max_iter: 10000000
momentum: 0.9
weight_decay: 0.0002
snapshot: 40000
snapshot_prefix: "models/<my_path>"
solver_mode: CPU
train_val.prototxt train and test layers:
name: "GoogleNet"
layer {
name: "data"
type: "Data"
top: "data"
top: "label"
include {
phase: TRAIN
}
transform_param {
mirror: true
crop_size: 224
mean_value: 104
mean_value: 117
mean_value: 123
}
data_param {
source: "/<blah>/ilsvrc12_train_lmdb"
batch_size: 32
backend: LMDB
}
}
layer {
name: "data"
type: "Data"
top: "data"
top: "label"
include {
phase: TEST
}
transform_param {
mirror: true
crop_size: 224
mean_value: 104
mean_value: 117
mean_value: 123
}
data_param {
source: "/<blah>/ilsvrc12_val_lmdb"
batch_size: 32
backend: LMDB
}
}
You should modify one place in your solver.prototxt from
train_net: "/train_val.prototxt"
to
net: "/train_val.prototxt"
Because the Solver does not use value of "train_net" to initialize a test net, so the test phase you added was not founded by the solver.
In fact, the parameters "train_net" and "test_net" are separately used to initialize a train net and a test net only, while "net" is used for both.

Ffmpeg converted videos (longer than 30s) not playing in chrome

As the title says, I'm having issues with converted videos that are over 30s. They are not playing in chrome but they do work in all other browsers. The thing is, if the video is less than 30s than it plays fine in chrome too.
The input file is mpeg4 encoded and I'm trying to convert it using the h264 codec. The conversion is done on a linux server with the help of a drupal module which converts the video on upload automatically.
This is the command and output:
/opt/ffmpeg/ffmpeg -i '/var/www/html/website/videos/original/2016-02-02-16-52-44-758_1.mp4' -strict experimental -vcodec 'libx264' -pix_fmt 'yuv420p' -vprofile 'baseline' -an -pass '1' -passlogfile '/tmp/1454496233-56b1d9e99deb8-multipass' -y /tmp/1454496233-56b1d9e99dd6f.mp4
ffmpeg version N-61041-g52a2138 Copyright (c) 2000-2014 the FFmpeg developers
built on Mar 2 2014 05:45:04 with gcc 4.6 (Debian 4.6.3-1)
configuration: --prefix=/root/ffmpeg-static/64bit --extra-cflags='-I/root/ffmpeg-static/64bit/include -static' --extra-ldflags='-L/root/ffmpeg-static/64bit/lib -static' --extra-libs='-lxml2 -lexpat -lfreetype' --enable-static --disable-shared --disable-ffserver --disable-doc --enable-bzlib --enable-zlib --enable-postproc --enable-runtime-cpudetect --enable-libx264 --enable-gpl --enable-libtheora --enable-libvorbis --enable-libmp3lame --enable-gray --enable-libass --enable-libfreetype --enable-libopenjpeg --enable-libspeex --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-version3 --enable-libvpx
libavutil 52. 66.100 / 52. 66.100
libavcodec 55. 52.102 / 55. 52.102
libavformat 55. 33.100 / 55. 33.100
libavdevice 55. 10.100 / 55. 10.100
libavfilter 4. 2.100 / 4. 2.100
libswscale 2. 5.101 / 2. 5.101
libswresample 0. 18.100 / 0. 18.100
libpostproc 52. 3.100 / 52. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/var/www/html/website/videos/original/2016-02-02-16-52-44-758_1.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2mp41
encoder : Lavf56.40.101
Duration: 00:00:54.42, start: 0.000000, bitrate: 840 kb/s
Stream #0:0(und): Video: mpeg4 (Simple Profile) (mp4v / 0x7634706D), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 839 kb/s, 24 fps, 24 tbr, 12288 tbn, 24 tbc (default)
Metadata:
handler_name : VideoHandler
[libx264 # 0x38799c0] using SAR=1/1
[libx264 # 0x38799c0] using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.2
[libx264 # 0x38799c0] profile Constrained Baseline, level 3.1
[libx264 # 0x38799c0] 264 - core 129 r2230 1cffe9f - H.264/MPEG-4 AVC codec - Copyleft 2003-2012 - http://www.videolan.org/x264.html - options: cabac=0 ref=1 deblock=1:0:0 analyse=0x1:0 me=dia subme=2 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=250 keyint_min=24 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to '/tmp/1454496233-56b1d9e99dd6f.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2mp41
encoder : Lavf55.33.100
Stream #0:0(und): Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, pass 1, 12288 tbn, 24 tbc (default)
Metadata:
handler_name : VideoHandler
Stream mapping:
Stream #0:0 -> #0:0 (mpeg4 -> libx264)
Press [q] to stop, [?] for help
frame= 129 fps=0.0 q=28.0 size= 298kB time=00:00:03.41 bitrate= 715.2kbits/s
frame= 268 fps=267 q=28.0 size= 784kB time=00:00:09.20 bitrate= 697.3kbits/s
frame= 409 fps=271 q=28.0 size= 1313kB time=00:00:15.08 bitrate= 712.9kbits/s
frame= 547 fps=272 q=28.0 size= 1744kB time=00:00:20.83 bitrate= 685.8kbits/s
frame= 687 fps=274 q=28.0 size= 2275kB time=00:00:26.66 bitrate= 699.0kbits/s
frame= 827 fps=275 q=28.0 size= 2754kB time=00:00:32.50 bitrate= 694.1kbits/s
frame= 967 fps=275 q=28.0 size= 3273kB time=00:00:38.33 bitrate= 699.4kbits/s
frame= 1106 fps=275 q=28.0 size= 3826kB time=00:00:44.12 bitrate= 710.2kbits/s
frame= 1245 fps=276 q=28.0 size= 4366kB time=00:00:49.91 bitrate= 716.6kbits/s
frame= 1306 fps=268 q=-1.0 Lsize= 4762kB time=00:00:54.41 bitrate= 716.8kbits/s
video:4756kB audio:0kB subtitle:0 data:0 global headers:0kB muxing overhead 0.125035%
[libx264 # 0x38799c0] frame I:6 Avg QP:17.10 size: 43459
[libx264 # 0x38799c0] frame P:1300 Avg QP:20.34 size: 3545
[libx264 # 0x38799c0] mb I I16..4: 31.1% 0.0% 68.9%
[libx264 # 0x38799c0] mb P I16..4: 3.7% 0.0% 0.0% P16..4: 14.8% 0.0% 0.0% 0.0% 0.0% skip:81.5%
[libx264 # 0x38799c0] coded y,uvDC,uvAC intra: 29.2% 62.3% 14.8% inter: 3.4% 5.8% 0.4%
[libx264 # 0x38799c0] i16 v,h,dc,p: 58% 22% 17% 2%
[libx264 # 0x38799c0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 59% 24% 8% 1% 1% 1% 2% 1% 2%
[libx264 # 0x38799c0] i8c dc,h,v,p: 36% 14% 47% 3%
[libx264 # 0x38799c0] kb/s:715.83
I also tried with the latest version of ffmpeg but I have the same problem.
Does anyone have any ideas on why this is happening?
Note that this is a log from doing a two-pass encoding (it was the only way to get a log from drupal). The two-pass encoding works if I specify a bitrate in the ffmpeg command, but as I said, it doesn't work on chrome but works on all other browsers.
The solution was to add qt-faststart as a helper program in drupal's UI.
Go to Configuration>Media>Video, expand Helper Programs and put the path to qt-faststart there. It should be in your ffmpeg binary folder.

Flask API server slow response time

I created an API server with Flask, I use gunicorn with eventlet to run it. I noticed a long response time from Flask server when calling APIs. I did a profiling with my client, one ran from my laptop, one ran directly in Flask API server.
From my laptop:
302556 function calls (295712 primitive calls) in 5.594 seconds
Ordered by: internal time
ncalls tottime percall cumtime percall filename:lineno(function)
72 4.370 0.061 4.370 0.061 {method 'poll' of 'select.epoll' objects}
16 0.374 0.023 0.374 0.023 {method 'connect' of '_socket.socket' objects}
16 0.213 0.013 0.213 0.013 {method 'load_verify_locations' of '_ssl._SSLContext' objects}
16 0.053 0.003 0.058 0.004 httplib.py:798(close)
52 0.034 0.001 0.034 0.001 {method 'do_handshake' of '_ssl._SSLSocket' objects}
On server:
231449 function calls (225936 primitive calls) in 3.320 seconds
Ordered by: internal time
ncalls tottime percall cumtime percall filename:lineno(function)
12 2.132 0.178 2.132 0.178 {built-in method read}
13 0.286 0.022 0.286 0.022 {method 'poll' of 'select.epoll' objects}
12 0.119 0.010 0.119 0.010 {_ssl.sslwrap}
12 0.095 0.008 0.095 0.008 {built-in method do_handshake}
855/222 0.043 0.000 0.116 0.001 sre_parse.py:379(_parse)
1758/218 0.029 0.000 0.090 0.000 sre_compile.py:32(_compile)
1013 0.027 0.000 0.041 0.000 sre_compile.py:207(_optimize_charset)
12429 0.023 0.000 0.029 0.000 sre_parse.py:182(__next)
So, I saw my client took long time to wait from server response base on the profile result.
I used gunicorn with eventlet to serve Flask app, with the flowing configuration:
import multiprocessing
bind = ['0.0.0.0:8000']
backlog = 2048
workers = multiprocessing.cpu_count() * 2 + 1
worker_class = 'eventlet'
user = 'www-data'
group = 'www-data'
loglevel = 'info'
My client is an custom HTTP client using eventlet to patch httplib2 and create a pool to connect to server.
I stuck here with the troubleshooting. All server stats were normal. How can I detect the bottle neck of my API server?

How to Tuning Apache and Mysql

top - 12:24:22 up 1 day, 18:37, 2 users, load average: 1.19, 1.77, 1.59
Tasks: 166 total, 4 running, 162 sleeping, 0 stopped, 0 zombie
Cpu(s): 20.1%us, 5.8%sy, 0.0%ni, 62.4%id, 10.8%wa, 0.0%hi, 1.0%si, 0.0%st
Mem: 987780k total, 979052k used, 8728k free, 17240k buffers
Swap: 2104432k total, 106760k used, 1997672k free, 174100k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
4116 mysql 15 0 356m 105m 4176 S 12.0 11.0 139:58.69 mysqld
5722 apache 15 0 160m 17m 4224 S 10.0 1.8 0:00.78 httpd
5741 apache 15 0 161m 17m 4220 S 9.3 1.8 0:00.37 httpd
5840 apache 15 0 161m 17m 4148 S 8.3 1.8 0:00.52 httpd
5846 apache 15 0 161m 17m 4132 S 6.3 1.8 0:00.47 httpd
5744 apache 15 0 162m 18m 4224 S 2.0 1.9 0:00.37 httpd
5725 apache 15 0 161m 17m 4424 S 1.3 1.8 0:00.34 httpd
5755 apache 15 0 105m 14m 4248 R 1.3 1.5 0:00.17 httpd
5564 apache 15 0 163m 19m 4360 S 1.0 2.0 0:00.65 httpd
5322 apache 16 0 162m 19m 4456 S 0.7 2.0 0:02.26 httpd
5586 apache 15 0 161m 18m 4468 S 0.7 1.9 0:01.77 httpd
5852 apache 16 0 99.9m 11m 3424 S 0.7 1.2 0:00.02 httpd
5121 root 18 0 98.3m 10m 4320 S 0.3 1.1 0:00.07 httpd
5723 apache 15 0 161m 17m 4240 S 0.3 1.8 0:00.31 httpd
5833 apeadm 15 0 12740 1128 808 R 0.3 0.1 0:00.03 top
5834 apache 15 0 160m 16m 4172 S 0.3 1.7 0:00.20 httpd
5836 apache 15 0 98.5m 9388 2912 S 0.3 1.0 0:00.01 httpd
1 root 15 0 10348 592 560 S 0.0 0.1 0:00.72 init
2 root RT -5 0 0 0 S 0.0 0.0 0:00.01 migration/0
Server Spec:
CENTOS CPU:E5200 RAM:1G
Software: Zencart X 3, Piwik x1
Server always down,How to tuning apache and mysql?
Thanks a lot.
httpd.conf
<IfModule mpm_prefork_module>
StartServers 8
MinSpareServers 8
MaxSpareServers 15
ServerLimit 450
MaxClients 450
MaxRequestsPerChild 10000
</IfModule>
<IfModule mpm_worker_module>
StartServers 2
ServerLimit 450
MaxClients 450
MinSpareThreads 25
MaxSpareThreads 75
ThreadsPerChild 25
MaxRequestsPerChild 10000
</IfModule>
<IfModule mpm_beos_module>
StartThreads 10
MaxClients 50
MaxRequestsPerThread 10000
</IfModule>
<IfModule mpm_netware_module>
ThreadStackSize 65536
StartThreads 250
MinSpareThreads 25
MaxSpareThreads 250
MaxThreads 1000
MaxRequestsPerChild 10000
MaxMemFree 100
</IfModule>
<IfModule mpm_mpmt_os2_module>
StartServers 2
MinSpareThreads 5
MaxSpareThreads 10
MaxRequestsPerChild 10000
</IfModule>
my.cnf
[mysqld]
set-variable = query_cache_limit=1M
set-variable = query_cache_size=16M
set-variable = query_cache_type=1
set-variable = max_connections=400
set-variable = interactive_timeout=100
set-variable = wait_timeout=100
set-variable = connect_timeout=100
set-variable = thread_cache_size=16
#
# Set key_buffer to 5 - 50% of your RAM depending on how much
# you use MyISAM tables, but keep key_buffer_size + InnoDB
# buffer pool size < 80% of your RAM
set-variable = key_buffer=32M
set-variable = join_buffer=1M
set-variable = max_allowed_packet=8M
set-variable = table_cache=1024
set-variable = record_buffer=1M
set-variable = sort_buffer_size=2M
set-variable = read_buffer_size=2M
set-variable = max_connect_errors=10
set-variable = myisam_sort_buffer_size=16M
#Useful for SMP
set-variable = thread_concurrency=8
Server always down,How to tuning apache and mysql?
eh? If its always down how did you get those figures? Tuning isn't going to fix stability issues.
A short answer to how to tune Apache and mysql would fill a large book. Here's some links to books on MysQL: http://forums.mysql.com/read.php?24,92131,92131
And for Apache try searching on Amazon.
Also, you've not provded any information about what's running in between Apache and MySQL - understanding what's going on here is pretty critical too - as is understanding how to improve HTTP and browser performance (caching, keepalives, compression, javascript....).