NGINX keeps file descriptors open for deleted files - nginx

I have a server running nginx proxying to a python API, a user will request an mp4 file which will be generated and written to /tmp/cache and served with nginx. Some time later (~ 20 seconds) the file will be deleted by the python process but that file remains held by nginx meaning the space is unusable and eventually the user runs out of cache space causing the entire application to fail.
Relevant parts of nginx config:
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /dev/stdout main;
# send headers in one piece, it is better than sending them one by one
tcp_nopush on;
sendfile on;
keepalive_timeout 65;
gzip on;
gzip_comp_level 6;
gzip_types text/plain text/css application/json application/x-javascript application/javascript text/javascript image/svg+xml image/x-icon image/bmp image/png image/gif image/jpeg image/jpg;
gzip_proxied no-cache no-store private expired auth;
gzip_vary on;
server {
listen 5000;
location /cache/ {
internal; # This tells nginx it's not accessible from the outside
alias /tmp/cache/;
}
location /api/ {
add_header Cache-Control "no-store";
expires off;
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS';
proxy_pass http://frigate_api/;
proxy_pass_request_headers on;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
}
relevant python api code:
#bp.route("/<camera_name>/start/<float:start_ts>/end/<float:end_ts>/clip.mp4")
def recording_clip(camera_name, start_ts, end_ts):
download = request.args.get("download", type=bool)
...
file_name = f"clip_{camera_name}_{start_ts}-{end_ts}.mp4"
path = f"/tmp/cache/{file_name}"
response = make_response()
response.headers["Content-Description"] = "File Transfer"
response.headers["Cache-Control"] = "no-cache"
response.headers["Content-Type"] = "video/mp4"
if download:
response.headers["Content-Disposition"] = "attachment; filename=%s" % file_name
response.headers["Content-Length"] = os.path.getsize(path)
response.headers[
"X-Accel-Redirect"
] = f"/cache/{file_name}" # nginx: http://wiki.nginx.org/NginxXSendfile
return response
we can see that after the file has been deleted by python, nginx keeps the file open meaning the space is still being used
# lsof -n | grep /tmp |grep deleted
nginx 130 root 27r REG 0,122 561200658 60 /tmp/cache/clip_front_doorbell_cam_1674691364.607239-1674692415.428497.mp4 (deleted)
nginx 130 152 nginx root 27r REG 0,122 561200658 60 /tmp/cache/clip_front_doorbell_cam_1674691364.607239-1674692415.428497.mp4 (deleted)
nginx 130 156 nginx root 27r REG 0,122 561200658 60 /tmp/cache/clip_front_doorbell_cam_1674691364.607239-1674692415.428497.mp4 (deleted)
nginx 130 159 nginx root 27r REG 0,122 561200658 60 /tmp/cache/clip_front_doorbell_cam_1674691364.607239-1674692415.428497.mp4 (deleted)
nginx 130 163 nginx root 27r REG 0,122 561200658 60 /tmp/cache/clip_front_doorbell_cam_1674691364.607239-1674692415.428497.mp4 (deleted)
nginx 130 166 nginx root 27r REG 0,122 561200658 60 /tmp/cache/clip_front_doorbell_cam_1674691364.607239-1674692415.428497.mp4 (deleted)
nginx 130 169 nginx root 27r REG 0,122 561200658 60 /tmp/cache/clip_front_doorbell_cam_1674691364.607239-1674692415.428497.mp4 (deleted)
nginx 130 173 nginx root 27r REG 0,122 561200658 60 /tmp/cache/clip_front_doorbell_cam_1674691364.607239-1674692415.428497.mp4 (deleted)
nginx 130 177 nginx root 27r REG 0,122 561200658 60 /tmp/cache/clip_front_doorbell_cam_1674691364.607239-1674692415.428497.mp4 (deleted)
nginx 130 181 nginx root 27r REG 0,122 561200658 60 /tmp/cache/clip_front_doorbell_cam_1674691364.607239-1674692415.428497.mp4 (deleted)
nginx 130 185 nginx root 27r REG 0,122 561200658 60 /tmp/cache/clip_front_doorbell_cam_1674691364.607239-1674692415.428497.mp4 (deleted)
nginx 130 189 nginx root 27r REG 0,122 561200658 60 /tmp/cache/clip_front_doorbell_cam_1674691364.607239-1674692415.428497.mp4 (deleted)
nginx 130 194 nginx root 27r REG 0,122 561200658 60 /tmp/cache/clip_front_doorbell_cam_1674691364.607239-1674692415.428497.mp4 (deleted)
nginx 130 197 nginx root 27r REG 0,122 561200658 60 /tmp/cache/clip_front_doorbell_cam_1674691364.607239-1674692415.428497.mp4 (deleted)
nginx 130 203 nginx root 27r REG 0,122 561200658 60 /tmp/cache/clip_front_doorbell_cam_1674691364.607239-1674692415.428497.mp4 (deleted)
nginx 130 211 nginx root 27r REG 0,122 561200658 60 /tmp/cache/clip_front_doorbell_cam_1674691364.607239-1674692415.428497.mp4 (deleted)
nginx 130 216 nginx root 27r REG 0,122 561200658 60 /tmp/cache/clip_front_doorbell_cam_1674691364.607239-1674692415.428497.mp4 (deleted)
nginx 130 221 nginx root 27r REG 0,122 561200658 60 /tmp/cache/clip_front_doorbell_cam_1674691364.607239-1674692415.428497.mp4 (deleted)
nginx 130 225 nginx root 27r REG 0,122 561200658 60 /tmp/cache/clip_front_doorbell_cam_1674691364.607239-1674692415.428497.mp4 (deleted)
nginx 130 230 nginx root 27r REG 0,122 561200658 60 /tmp/cache/clip_front_doorbell_cam_1674691364.607239-1674692415.428497.mp4 (deleted)
nginx 130 235 nginx root 27r REG 0,122 561200658 60 /tmp/cache/clip_front_doorbell_cam_1674691364.607239-1674692415.428497.mp4 (deleted)
nginx 130 240 nginx root 27r REG 0,122 561200658 60 /tmp/cache/clip_front_doorbell_cam_1674691364.607239-1674692415.428497.mp4 (deleted)
nginx 130 244 nginx root 27r REG 0,122 561200658 60 /tmp/cache/clip_front_doorbell_cam_1674691364.607239-1674692415.428497.mp4 (deleted)
nginx 130 247 nginx root 27r REG 0,122 561200658 60 /tmp/cache/clip_front_doorbell_cam_1674691364.607239-1674692415.428497.mp4 (deleted)
nginx 130 251 nginx root 27r REG 0,122 561200658 60 /tmp/cache/clip_front_doorbell_cam_1674691364.607239-1674692415.428497.mp4 (deleted)
nginx 130 254 nginx root 27r REG 0,122 561200658 60 /tmp/cache/clip_front_doorbell_cam_1674691364.607239-1674692415.428497.mp4 (deleted)
nginx 130 257 nginx root 27r REG 0,122 561200658 60 /tmp/cache/clip_front_doorbell_cam_1674691364.607239-1674692415.428497.mp4 (deleted)
nginx 130 261 nginx root 27r REG 0,122 561200658 60 /tmp/cache/clip_front_doorbell_cam_1674691364.607239-1674692415.428497.mp4 (deleted)
nginx 130 263 nginx root 27r REG 0,122 561200658 60 /tmp/cache/clip_front_doorbell_cam_1674691364.607239-1674692415.428497.mp4 (deleted)
nginx 130 266 nginx root 27r REG 0,122 561200658 60 /tmp/cache/clip_front_doorbell_cam_1674691364.607239-1674692415.428497.mp4 (deleted)
nginx 130 269 nginx root 27r REG 0,122 561200658 60 /tmp/cache/clip_front_doorbell_cam_1674691364.607239-1674692415.428497.mp4 (deleted)
nginx 130 272 nginx root 27r REG 0,122 561200658 60 /tmp/cache/clip_front_doorbell_cam_1674691364.607239-1674692415.428497.mp4 (deleted)
nginx 130 276 nginx root 27r REG 0,122 561200658 60 /tmp/cache/clip_front_doorbell_cam_1674691364.607239-1674692415.428497.mp4 (deleted)
is there any way to disable this behavior?

Related

| NGINX | FFMPEG not creating DASH manifests or chunks in the designated DIR |

Hopefully someone can help here, I have a setup that takes two input RTMP streams from two separate machines into my server. From here I am trying to serve some MPEG DASH manifests and chunks to an experimental spatial audio/360 web (.js) player.
My issue is that while i can see the FFMPEG processes running and creating the Chunks the files themselves are not appearing in the specified folder and so the media player will not read the content.
Is there something obvious that i am not doing that is preventing these files being written?
Any help with this would be amazing!!!
Here is my config:
#user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
rtmp {
server {
listen 1935;
chunk_size 4096;
application live {
live on;
record off;
interleave off;
wait_key on;
meta on;
wait_video off;
idle_streams off;
sync 300ms;
session_relay on;
#allow publish 127.0.0.1;
#allow publish 192.168.2.0/24;
allow publish all;
#deny publish all;
allow play all;
dash on;
dash_nested on;
dash_path /tmp/dash;
dash_fragment 3;
dash_playlist_length 120;
dash_cleanup on;
#dash_clock_compensation http_head;
#dash_clock_helper_uri https://localhost/time;
#dash_variant _low bandwidth="500000" width="640" height="360";
#dash_variant _med bandwidth="1500000" width="1280" height="720";
#dash_variant _high bandwidth="5000000" width="1920" height="1080" max;
# EDIT THESE SO THE LIVESTREAM_KEY IS REPLACED BY YOUR PERSONAL KEY THAT YOU CAN LOOK UP ON THE SITE OF THE PLATFORM
# push rtmp://live-ams.twitch.tv/app/LIVESTREAM_KEY;
# push rtmp://a.rtmp.youtube.com/live2/LIVESTREAM_KEY;
# push rtmp://ingest-ams.mixer.com:1935/beam/LIVESTREAM_KEY;
exec_push ffmpeg -re -an -i 'rtmp://localhost:1935/live/stream' -c:v libx264 -preset veryfast -s 1920x1080 -bufsize 15000k -b:v 15000k -keyint_min 150 -g 150 -tile-columns 4 -frame-parallel 1 -an -f dash -init_seg_name 'init-stream$RepresentationID$_video.webm' -media_seg_name 'chunk-stream$RepresentationID$_video-$Number%05d$.webm' 'http://localhost:1935/dash/video.mpd' 2>>/var/log/nginx/ffmpegvideo.log;
}
application dash {
#TRANSCODED VIDEO/AUDIO FROM FFMPEG COMES HERE?????
live on;
meta copy;
record all;
record_path /rec;
}
}
server {
listen 1936;
chunk_size 4096;
application live {
live on;
record off;
interleave off;
wait_key on;
meta on;
wait_video off;
idle_streams off;
sync 300ms;
session_relay on;
#allow publish 127.0.0.1;
#allow publish 192.168.2.0/24;
allow publish all;
#deny publish all;
allow play all;
# EDIT THESE SO THE LIVESTREAM_KEY IS REPLACED BY YOUR PERSONAL KEY THAT YOU CAN LOOK UP ON THE SITE OF THE PLATFORM
# push rtmp://live-ams.twitch.tv/app/LIVESTREAM_KEY;
# push rtmp://a.rtmp.youtube.com/live2/LIVESTREAM_KEY;
# push rtmp://ingest-ams.mixer.com:1935/beam/LIVESTREAM_KEY;
exec_push ffmpeg -re -i 'rtmp://localhost:1936/live/stream' -filter 'channelmap=0|1|2|3|4|5|6|7:' -c:a libopus -b:a 512k -vn -f dash -init_seg_name 'init-stream$RepresentationID$_audio_01-08ch.webm' -media_seg_name 'chunk-stream$RepresentationID$_audio_01-08ch-$Number%05d$.webm' 'http://localhost:1936/dash/audio_01-08ch.mpd' -filter 'channelmap=8|9|10|11|12|13|14|15:' -c:a libopus -b:a 512k -vn -f dash -init_seg_name 'init-stream$RepresentationID$_audio_09-16ch.webm' -media_seg_name 'chunk-stream$RepresentationID$_audio_09-16ch-$Number%05d$.webm' 'http://localhost:1936/dash/audio_09-16ch.mpd' 2>>/var/log/nginx/ffmpegaudio.log;
}
application dash {
#TRANSCODED AUDIO FROM FFMPEG COMES HERE?????
live on;
meta copy;
}
}
}
and here is the output from my FFMPEG logs:
AUDIO:
ffmpeg version 3.4.6-0ubuntu0.18.04.1 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 7 (Ubuntu 7.3.0-16ubuntu3)
configuration: --prefix=/usr --extra-version=0ubuntu0.18.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --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-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --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-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
libavutil 55. 78.100 / 55. 78.100
libavcodec 57.107.100 / 57.107.100
libavformat 57. 83.100 / 57. 83.100
libavdevice 57. 10.100 / 57. 10.100
libavfilter 6.107.100 / 6.107.100
libavresample 3. 7. 0 / 3. 7. 0
libswscale 4. 8.100 / 4. 8.100
libswresample 2. 9.100 / 2. 9.100
libpostproc 54. 7.100 / 54. 7.100
[aac # 0x55bfeaaafc60] Channel layout 'stereo' with 2 channels does not match specified number of channels 16: ignoring specified channel layout
Guessed Channel Layout for Input Stream #0.0 : hexadecagonal
Input #0, flv, from 'rtmp://localhost:1936/live/stream':
Metadata:
Server : NGINX RTMP (github.com/arut/nginx-rtmp-module)
displayWidth : 0
displayHeight : 0
fps : 0
profile :
level :
Duration: 00:00:00.00, start: 0.042000, bitrate: N/A
Stream #0:0: Audio: aac (LC), 48000 Hz, hexadecagonal, fltp, 512 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (aac (native) -> opus (libopus))
Stream #0:0 -> #1:0 (aac (native) -> opus (libopus))
Press [q] to stop, [?] for help
[dash # 0x55bfeaab43e0] Opening 'http://localhost:1936/dash/init-stream_audio_01-08ch.webm' for writing
Output #0, dash, to 'http://localhost:1936/dash/audio_01-08ch.mpd':
Metadata:
Server : NGINX RTMP (github.com/arut/nginx-rtmp-module)
displayWidth : 0
displayHeight : 0
fps : 0
profile :
level :
encoder : Lavf57.83.100
Stream #0:0: Audio: opus (libopus), 48000 Hz, 7.1, flt, 512 kb/s
Metadata:
encoder : Lavc57.107.100 libopus
[dash # 0x55bfeaab43e0] Cannot use rename on non file protocol, this may lead to races and temporary partial files
[dash # 0x55bfeaaecb00] Opening 'http://localhost:1936/dash/init-stream_audio_09-16ch.webm' for writing
Output #1, dash, to 'http://localhost:1936/dash/audio_09-16ch.mpd':
Metadata:
Server : NGINX RTMP (github.com/arut/nginx-rtmp-module)
displayWidth : 0
displayHeight : 0
fps : 0
profile :
level :
encoder : Lavf57.83.100
Stream #1:0: Audio: opus (libopus), 48000 Hz, 7.1, flt, 512 kb/s
Metadata:
encoder : Lavc57.107.100 libopus
size=N/A time=00:00:00.49 bitrate=N/A speed=0.986x
size=N/A time=00:00:01.01 bitrate=N/A speed=1.01x
size=N/A time=00:00:01.49 bitrate=N/A speed=0.993x
size=N/A time=00:00:02.01 bitrate=N/A speed= 1x
size=N/A time=00:00:02.49 bitrate=N/A speed=0.995x
size=N/A time=00:00:03.01 bitrate=N/A speed= 1x
size=N/A time=00:00:03.53 bitrate=N/A speed= 1x
size=N/A time=00:00:04.01 bitrate=N/A speed=0.998x
size=N/A time=00:00:04.53 bitrate=N/A speed= 1x
[dash # 0x55bfeaab43e0] Opening 'http://localhost:1936/dash/chunk-stream_audio_01-08ch-%05d.webm' for writing
[dash # 0x55bfeaaecb00] Opening 'http://localhost:1936/dash/chunk-stream_audio_09-16ch-%05d.webm' for writing
size=N/A time=00:00:05.01 bitrate=N/A speed=0.997x
size=N/A time=00:00:05.53 bitrate=N/A speed= 1x
size=N/A time=00:00:06.03 bitrate=N/A speed=0.999x
size=N/A time=00:00:06.55 bitrate=N/A speed= 1x
size=N/A time=00:00:07.05 bitrate=N/A speed=0.999x
size=N/A time=00:00:07.55 bitrate=N/A speed=0.999x
size=N/A time=00:00:08.07 bitrate=N/A speed= 1x
size=N/A time=00:00:08.57 bitrate=N/A speed= 1x
size=N/A time=00:00:09.09 bitrate=N/A speed= 1x
size=N/A time=00:00:09.59 bitrate=N/A speed= 1x
[dash # 0x55bfeaab43e0] Opening 'http://localhost:1936/dash/chunk-stream_audio_01-08ch-%05d.webm' for writing
[dash # 0x55bfeaaecb00] Opening 'http://localhost:1936/dash/chunk-stream_audio_09-16ch-%05d.webm' for writing
size=N/A time=00:00:10.09 bitrate=N/A speed=0.999x
size=N/A time=00:00:10.61 bitrate=N/A speed= 1x
size=N/A time=00:00:11.09 bitrate=N/A speed=0.999x
size=N/A time=00:00:11.61 bitrate=N/A speed= 1x
size=N/A time=00:00:12.11 bitrate=N/A speed=0.999x
size=N/A time=00:00:12.63 bitrate=N/A speed= 1x
size=N/A time=00:00:13.13 bitrate=N/A speed= 1x
size=N/A time=00:00:13.63 bitrate=N/A speed=0.999x
size=N/A time=00:00:14.15 bitrate=N/A speed= 1x
size=N/A time=00:00:14.63 bitrate=N/A speed=0.999x
[dash # 0x55bfeaab43e0] Opening 'http://localhost:1936/dash/chunk-stream_audio_01-08ch-%05d.webm' for writing
[dash # 0x55bfeaaecb00] Opening 'http://localhost:1936/dash/chunk-stream_audio_09-16ch-%05d.webm' for writing
size=N/A time=00:00:15.15 bitrate=N/A speed= 1x
size=N/A time=00:00:15.67 bitrate=N/A speed= 1x
size=N/A time=00:00:16.15 bitrate=N/A speed=0.999x
size=N/A time=00:00:16.67 bitrate=N/A speed= 1x
size=N/A time=00:00:17.15 bitrate=N/A speed=0.999x
size=N/A time=00:00:17.67 bitrate=N/A speed= 1x
size=N/A time=00:00:18.17 bitrate=N/A speed= 1x
size=N/A time=00:00:18.67 bitrate=N/A speed=0.999x
size=N/A time=00:00:19.19 bitrate=N/A speed= 1x
size=N/A time=00:00:19.69 bitrate=N/A speed= 1x
[dash # 0x55bfeaab43e0] Opening 'http://localhost:1936/dash/chunk-stream_audio_01-08ch-%05d.webm' for writing
[dash # 0x55bfeaaecb00] Opening 'http://localhost:1936/dash/chunk-stream_audio_09-16ch-%05d.webm' for writing
VIDEO:
ffmpeg version 3.4.6-0ubuntu0.18.04.1 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 7 (Ubuntu 7.3.0-16ubuntu3)
configuration: --prefix=/usr --extra-version=0ubuntu0.18.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --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-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --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-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
libavutil 55. 78.100 / 55. 78.100
libavcodec 57.107.100 / 57.107.100
libavformat 57. 83.100 / 57. 83.100
libavdevice 57. 10.100 / 57. 10.100
libavfilter 6.107.100 / 6.107.100
libavresample 3. 7. 0 / 3. 7. 0
libswscale 4. 8.100 / 4. 8.100
libswresample 2. 9.100 / 2. 9.100
libpostproc 54. 7.100 / 54. 7.100
Input #0, flv, from 'rtmp://localhost:1935/live/stream':
Metadata:
Server : NGINX RTMP (github.com/arut/nginx-rtmp-module)
displayWidth : 3840
displayHeight : 1920
fps : 30
profile :
level :
Duration: 00:00:00.00, start: 0.033000, bitrate: N/A
Stream #0:0: Video: h264 (High), yuv420p(tv, bt470bg/bt709/bt709, progressive), 3840x1920 [SAR 1:1 DAR 2:1], 15360 kb/s, 30 fps, 30 tbr, 1k tbn, 60 tbc
Stream #0:1: Audio: aac (LC), 48000 Hz, 7.1, fltp, 327 kb/s
Codec AVOption tile-columns (Number of tile columns to use, log2) specified for output file #0 (http://localhost:1935/dash/video.mpd) has not been used for any stream. The most likely reason is either wrong type (e.g. a video option with no video streams) or that it is a private option of some encoder which was not actually used for any stream.
Codec AVOption frame-parallel (Enable frame parallel decodability features) specified for output file #0 (http://localhost:1935/dash/video.mpd) has not been used for any stream. The most likely reason is either wrong type (e.g. a video option with no video streams) or that it is a private option of some encoder which was not actually used for any stream.
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[libx264 # 0x55e24ea47f40] VBV maxrate unspecified, assuming CBR
[libx264 # 0x55e24ea47f40] using SAR=9/8
[libx264 # 0x55e24ea47f40] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 # 0x55e24ea47f40] profile High, level 4.0
[libx264 # 0x55e24ea47f40] 264 - core 152 r2854 e9a5903 - 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=0x3:0x113 me=hex subme=2 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=6 lookahead_threads=2 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=1 keyint=150 keyint_min=76 scenecut=40 intra_refresh=0 rc_lookahead=10 rc=cbr mbtree=1 bitrate=15000 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 vbv_maxrate=15000 vbv_bufsize=15000 nal_hrd=none filler=0 ip_ratio=1.40 aq=1:1.00
[dash # 0x55e24ea4b640] Opening 'http://localhost:1935/dash/init-stream_video.webm' for writing
Output #0, dash, to 'http://localhost:1935/dash/video.mpd':
Metadata:
Server : NGINX RTMP (github.com/arut/nginx-rtmp-module)
displayWidth : 3840
displayHeight : 1920
fps : 30
profile :
level :
encoder : Lavf57.83.100
Stream #0:0: Video: h264 (libx264), yuv420p, 1920x1080 [SAR 9:8 DAR 2:1], q=-1--1, 15000 kb/s, 30 fps, 15360 tbn, 30 tbc
Metadata:
encoder : Lavc57.107.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/15000000 buffer size: 15000000 vbv_delay: -1
frame= 11 fps=0.0 q=0.0 size=N/A time=00:00:00.00 bitrate=N/A speed= 0x
[dash # 0x55e24ea4b640] Cannot use rename on non file protocol, this may lead to races and temporary partial files
frame= 26 fps= 26 q=19.0 size=N/A time=00:00:00.10 bitrate=N/A speed=0.0997x
frame= 42 fps= 28 q=17.0 size=N/A time=00:00:00.63 bitrate=N/A speed=0.421x
frame= 57 fps= 28 q=14.0 size=N/A time=00:00:01.13 bitrate=N/A speed=0.565x
frame= 72 fps= 29 q=15.0 size=N/A time=00:00:01.63 bitrate=N/A speed=0.65x
frame= 87 fps= 29 q=14.0 size=N/A time=00:00:02.13 bitrate=N/A speed=0.706x
frame= 102 fps= 29 q=16.0 size=N/A time=00:00:02.63 bitrate=N/A speed=0.746x
frame= 118 fps= 29 q=16.0 size=N/A time=00:00:03.16 bitrate=N/A speed=0.785x
frame= 133 fps= 29 q=17.0 size=N/A time=00:00:03.66 bitrate=N/A speed=0.807x
frame= 148 fps= 29 q=15.0 size=N/A time=00:00:04.16 bitrate=N/A speed=0.826x
frame= 163 fps= 29 q=18.0 size=N/A time=00:00:04.66 bitrate=N/A speed=0.841x
[dash # 0x55e24ea4b640] Opening 'http://localhost:1935/dash/chunk-stream_video-%05d.webm' for writing
frame= 178 fps= 29 q=17.0 size=N/A time=00:00:05.16 bitrate=N/A speed=0.854x
frame= 193 fps= 29 q=18.0 size=N/A time=00:00:05.66 bitrate=N/A speed=0.864x
frame= 208 fps= 29 q=15.0 size=N/A time=00:00:06.16 bitrate=N/A speed=0.873x
frame= 224 fps= 30 q=15.0 size=N/A time=00:00:06.70 bitrate=N/A speed=0.885x
frame= 239 fps= 30 q=16.0 size=N/A time=00:00:07.20 bitrate=N/A speed=0.892x
frame= 254 fps= 30 q=15.0 size=N/A time=00:00:07.70 bitrate=N/A speed=0.898x
frame= 269 fps= 30 q=17.0 size=N/A time=00:00:08.20 bitrate=N/A speed=0.903x
frame= 284 fps= 30 q=16.0 size=N/A time=00:00:08.70 bitrate=N/A speed=0.908x
frame= 299 fps= 30 q=16.0 size=N/A time=00:00:09.20 bitrate=N/A speed=0.912x
frame= 314 fps= 30 q=18.0 size=N/A time=00:00:09.70 bitrate=N/A speed=0.916x
[dash # 0x55e24ea4b640] Opening 'http://localhost:1935/dash/chunk-stream_video-%05d.webm' for writing
frame= 330 fps= 30 q=17.0 size=N/A time=00:00:10.23 bitrate=N/A speed=0.922x
frame= 345 fps= 30 q=17.0 size=N/A time=00:00:10.73 bitrate=N/A speed=0.925x
frame= 360 fps= 30 q=15.0 size=N/A time=00:00:11.23 bitrate=N/A speed=0.928x
frame= 375 fps= 30 q=15.0 size=N/A time=00:00:11.73 bitrate=N/A speed=0.931x
frame= 390 fps= 30 q=16.0 size=N/A time=00:00:12.23 bitrate=N/A speed=0.933x
frame= 405 fps= 30 q=17.0 size=N/A time=00:00:12.73 bitrate=N/A speed=0.935x
frame= 420 fps= 30 q=14.0 size=N/A time=00:00:13.23 bitrate=N/A speed=0.937x
frame= 435 fps= 30 q=16.0 size=N/A time=00:00:13.73 bitrate=N/A speed=0.94x
frame= 450 fps= 30 q=16.0 size=N/A time=00:00:14.23 bitrate=N/A speed=0.941x
frame= 465 fps= 30 q=18.0 size=N/A time=00:00:14.73 bitrate=N/A speed=0.943x
[dash # 0x55e24ea4b640] Opening 'http://localhost:1935/dash/chunk-stream_video-%05d.webm' for writing
frame= 481 fps= 30 q=16.0 size=N/A time=00:00:15.26 bitrate=N/A speed=0.946x
frame= 496 fps= 30 q=17.0 size=N/A time=00:00:15.76 bitrate=N/A speed=0.947x
frame= 511 fps= 30 q=16.0 size=N/A time=00:00:16.26 bitrate=N/A speed=0.949x
frame= 526 fps= 30 q=16.0 size=N/A time=00:00:16.76 bitrate=N/A speed=0.95x
frame= 541 fps= 30 q=16.0 size=N/A time=00:00:17.26 bitrate=N/A speed=0.951x
frame= 557 fps= 30 q=16.0 size=N/A time=00:00:17.80 bitrate=N/A speed=0.953x
frame= 572 fps= 30 q=15.0 size=N/A time=00:00:18.30 bitrate=N/A speed=0.954x
frame= 587 fps= 30 q=16.0 size=N/A time=00:00:18.80 bitrate=N/A speed=0.955x
frame= 602 fps= 30 q=16.0 size=N/A time=00:00:19.30 bitrate=N/A speed=0.956x
frame= 618 fps= 30 q=18.0 size=N/A time=00:00:19.83 bitrate=N/A speed=0.958x
[dash # 0x55e24ea4b640] Opening 'http://localhost:1935/dash/chunk-stream_video-%05d.webm' for writing
frame= 633 fps= 30 q=17.0 size=N/A time=00:00:20.33 bitrate=N/A speed=0.959x
frame= 648 fps= 30 q=16.0 size=N/A time=00:00:20.83 bitrate=N/A speed=0.96x
frame= 663 fps= 30 q=16.0 size=N/A time=00:00:21.33 bitrate=N/A speed=0.961x
frame= 678 fps= 30 q=16.0 size=N/A time=00:00:21.83 bitrate=N/A speed=0.961x
frame= 693 fps= 30 q=16.0 size=N/A time=00:00:22.33 bitrate=N/A speed=0.962x
frame= 708 fps= 30 q=16.0 size=N/A time=00:00:22.83 bitrate=N/A speed=0.962x
frame= 723 fps= 30 q=17.0 size=N/A time=00:00:23.33 bitrate=N/A speed=0.963x
frame= 739 fps= 30 q=17.0 size=N/A time=00:00:23.86 bitrate=N/A speed=0.965x
frame= 754 fps= 30 q=16.0 size=N/A time=00:00:24.36 bitrate=N/A speed=0.965x
frame= 769 fps= 30 q=18.0 size=N/A time=00:00:24.86 bitrate=N/A speed=0.966x
[dash # 0x55e24ea4b640] Opening 'http://localhost:1935/dash/chunk-stream_video-%05d.webm' for writing
frame= 784 fps= 30 q=15.0 size=N/A time=00:00:25.36 bitrate=N/A speed=0.966x
frame= 799 fps= 30 q=15.0 size=N/A time=00:00:25.86 bitrate=N/A speed=0.967x
frame= 814 fps= 30 q=15.0 size=N/A time=00:00:26.36 bitrate=N/A speed=0.967x
frame= 829 fps= 30 q=16.0 size=N/A time=00:00:26.86 bitrate=N/A speed=0.968x
frame= 844 fps= 30 q=15.0 size=N/A time=00:00:27.36 bitrate=N/A speed=0.968x
frame= 860 fps= 30 q=15.0 size=N/A time=00:00:27.90 bitrate=N/A speed=0.97x
frame= 875 fps= 30 q=15.0 size=N/A time=00:00:28.40 bitrate=N/A speed=0.97x
frame= 890 fps= 30 q=15.0 size=N/A time=00:00:28.90 bitrate=N/A speed=0.971x
frame= 905 fps= 30 q=16.0 size=N/A time=00:00:29.40 bitrate=N/A speed=0.971x
frame= 920 fps= 30 q=18.0 size=N/A time=00:00:29.90 bitrate=N/A speed=0.971x
[dash # 0x55e24ea4b640] Opening 'http://localhost:1935/dash/chunk-stream_video-%05d.webm' for writing
frame= 935 fps= 30 q=16.0 size=N/A time=00:00:30.40 bitrate=N/A speed=0.971x
frame= 950 fps= 30 q=16.0 size=N/A time=00:00:30.90 bitrate=N/A speed=0.972x
frame= 966 fps= 30 q=15.0 size=N/A time=00:00:31.43 bitrate=N/A speed=0.973x
frame= 981 fps= 30 q=15.0 size=N/A time=00:00:31.93 bitrate=N/A speed=0.973x
frame= 996 fps= 30 q=16.0 size=N/A time=00:00:32.43 bitrate=N/A speed=0.974x
frame= 1011 fps= 30 q=15.0 size=N/A time=00:00:32.93 bitrate=N/A speed=0.974x
frame= 1026 fps= 30 q=16.0 size=N/A time=00:00:33.43 bitrate=N/A speed=0.974x
frame= 1041 fps= 30 q=16.0 size=N/A time=00:00:33.93 bitrate=N/A speed=0.974x
frame= 1057 fps= 30 q=16.0 size=N/A time=00:00:34.46 bitrate=N/A speed=0.975x
[dash # 0x55e24ea4b640] Opening 'http://localhost:1935/dash/chunk-stream_video-%05d.webm' for writing
frame= 1072 fps= 30 q=18.0 size=N/A time=00:00:34.96 bitrate=N/A speed=0.976x
frame= 1087 fps= 30 q=18.0 size=N/A time=00:00:35.46 bitrate=N/A speed=0.976x
frame= 1102 fps= 30 q=15.0 size=N/A time=00:00:35.96 bitrate=N/A speed=0.976x
frame= 1117 fps= 30 q=15.0 size=N/A time=00:00:36.46 bitrate=N/A speed=0.976x
frame= 1132 fps= 30 q=16.0 size=N/A time=00:00:36.96 bitrate=N/A speed=0.976x
frame= 1148 fps= 30 q=16.0 size=N/A time=00:00:37.50 bitrate=N/A speed=0.977x
frame= 1163 fps= 30 q=17.0 size=N/A time=00:00:38.00 bitrate=N/A speed=0.978x
frame= 1178 fps= 30 q=15.0 size=N/A time=00:00:38.50 bitrate=N/A speed=0.978x
frame= 1193 fps= 30 q=15.0 size=N/A time=00:00:39.00 bitrate=N/A speed=0.978x
frame= 1208 fps= 30 q=18.0 size=N/A time=00:00:39.50 bitrate=N/A speed=0.978x
[dash # 0x55e24ea4b640] Opening 'http://localhost:1935/dash/chunk-stream_video-%05d.webm' for writing

Combine data split by factor using "by' function back into one

I have a data frame final which looks like this
TrackIndex Time x_position y_position
1 1 0.1034 425 171
2 1 0.1379 425 169
3 1 0.1724 427 166
.........
125 25 1.1030 462 397
126 25 1.1380 462 397
127 25 1.1720 462 397
128 25 1.2070 462 397
129 25 1.2410 461 398
130 25 1.2760 462 399
131 25 1.3100 461 399
132 25 1.3450 461 399
133 25 1.3790 460 399
134 25 1.4140 460 399
.....
268 41 1.8280 302 280
269 41 1.8620 303 279
270 41 1.8970 302 280
271 41 1.9310 302 280
272 41 1.9660 302 281
273 41 2.0000 302 281
274 41 2.0340 302 281
275 41 2.0690 302 282
276 41 2.1030 302 282
277 41 2.1380 302 282
278 41 2.1720 302 283
........
I sorted this data frame by factor "TrackIndex", and selected only the first 5 rows for each unique TrackIndex using "by" function.
finalbyfactor<-by(data = final, INDICES = final$TrackIndex, FUN = function(x) head(x, 5))
This gave me the following results
> finalbyfactor
final$TrackIndex: 1
TrackIndex Time x_position y_position
1 1 0.1034 425 171
2 1 0.1379 425 169
3 1 0.1724 427 166
4 1 0.2069 427 167
5 1 0.2414 427 167
-----------------------------------------------------------------------------
final$TrackIndex: 25
TrackIndex Time x_position y_position
125 25 1.103 462 397
126 25 1.138 462 397
127 25 1.172 462 397
128 25 1.207 462 397
129 25 1.241 461 398
-----------------------------------------------------------------------------
final$TrackIndex: 41
TrackIndex Time x_position y_position
268 41 1.828 302 280
269 41 1.862 303 279
270 41 1.897 302 280
271 41 1.931 302 280
272 41 1.966 302 281
Now I want to recombine the selected rows into one data frame as the initial one. How can I do it?
I tried rbind and merge, both did not work.

Create SpatialLinesDataFrame from point coordinates

I am doing a animal tracking project. My data "finaltrimmed" looks like this
TrackIndex Time x_position y_position
1 1 0.1034 425 171
2 1 0.1379 425 169
3 1 0.1724 427 166
.........
125 25 1.1030 462 397
126 25 1.1380 462 397
127 25 1.1720 462 397
128 25 1.2070 462 397
129 25 1.2410 461 398
130 25 1.2760 462 399
131 25 1.3100 461 399
132 25 1.3450 461 399
133 25 1.3790 460 399
134 25 1.4140 460 399
.....
268 41 1.8280 302 280
269 41 1.8620 303 279
270 41 1.8970 302 280
271 41 1.9310 302 280
272 41 1.9660 302 281
273 41 2.0000 302 281
274 41 2.0340 302 281
275 41 2.0690 302 282
276 41 2.1030 302 282
277 41 2.1380 302 282
278 41 2.1720 302 283
........
I wish to create a line for each unique TrackIndex, which basically tracks how each individual insect move over time. And from there I want create a SpatialLinesDataFrame based on TrackIndex. Eventually, I want to use “buffer”function in “adehabitatMA” package to create a buffer area around each line.
I was able to create a SpatialPointsDataFrame using the following command.
xy<-cbind(finaltrimmed$x_position,finaltrimmed$y_position)
MatrixofPoints<-matrix(xy,ncol=2)
points<-SpatialPoints(MatrixofPoints)
dataframe=data.frame(finaltrimmed$TrackIndex)
df.points<-SpatialPointsDataFrame(points,dataframe)
However, I was not able to create a SpatialLinesDataFrame in a similar way.
My idea is to split the data frame “final trimmed” first with “split” function.
splitfinal<-split(finaltrimmed,finaltrimmed$TrackIndex)
which gives me the following data structure
$1
TrackIndex Time x_position y_position newindex
1: 1246 347.0 316 214 1
2: 1246 347.0 316 214 2
......
57: 1246 348.9 325 201 57
58: 1246 349.0 330 201 58
TrackIndex Time x_position y_position newindex
$25
TrackIndex Time x_position y_position newindex
1: 1318 363.6 375 422 1
2: 1318 363.7 375 422 2
.....
57: 1318 365.6 399 406 57
58: 1318 365.6 400 406 58
From there, I can cbind the x and y positions in “splitfinal” (this step didn’t work out because “splitfinal” is a list of lists). I am also not sure how to create a Lines-class, which is required to create a SpatialLinesDataFrame.
I am been stuck for many days and could not figure a way.
Can anyone help?
Here is an approach that should work:
Example data:
finaltrimmed <- read.table(text="TrackIndex Time x_position y_position
1 1 0.1034 425 171
2 1 0.1379 425 169
3 1 0.1724 427 166
130 25 1.2760 462 399
131 25 1.3100 461 399
132 25 1.3450 461 399
133 25 1.3790 460 399
134 25 1.4140 460 399
274 41 2.0340 302 281
275 41 2.0690 302 282
276 41 2.1030 302 282
277 41 2.1380 302 282
278 41 2.1720 302 283")
Solution:
library(raster)
ft <- split(finaltrimmed, finaltrimmed$TrackIndex)
z <- lapply(ft, function(i) spLines(as.matrix(i[, c('x_position', 'y_position')]), attr=data.frame(TrackIndex=i$TrackIndex[1])))
names(z) <- NULL
zz <- do.call(bind, z)

Creating Bin Lengths in R

I have a database with surf clam lengths that I want to create bin lengths for. These clam lengths range from 20 cm all the way to 180 cm. I want to bin these lengths together in 3 cm increments. For example, lengths of 1, 2 or 3 will have a bin length of 3, lengths 4, 5 and 6 will be a bin length of 6, and 7, 8, 9 will all be bin length of 9 and so on.
The bin categories I want are 3 6 9 12 15 18 21 24 27 30 33 36 39 42 45 48 51 54 57 60 63 66 69 72 75 78 81 84 87 90 93 96 99 102 105 108 111 114 117 120 123 126 129 132 135 138 141 144 147 150 153 156 159 162 165 168 171 174 177 180.
I also need to add the FREQ together with the lengths that are being binned together. For example, if I have lengths of 58 cm (FREQ = 2), 59 cm (FREQ = 1), and 60 cm (FREQ = 5), the end result should be 60 cm with a frequency of 8.
STA DATE SPP LENG FREQ
5002 06/12/85 403 82 1
5002 06/12/85 403 90 1
5002 06/12/85 403 94 2
5002 06/12/85 403 98 1
5002 06/12/85 403 99 1
5002 06/12/85 403 102 1
5002 06/12/85 403 105 1
5002 06/12/85 403 106 1
5002 06/12/85 403 107 1
5002 06/12/85 403 111 1
5003 06/12/85 403 75 1
5003 06/12/85 403 76 1
5003 06/12/85 403 92 1
5003 06/12/85 403 93 1
5003 06/12/85 403 95 1
5003 06/12/85 403 151 1
5004 06/12/85 403 130 1
5004 06/12/85 403 140 1
5004 06/12/85 403 143 1
5004 06/12/85 403 144 1
5004 06/12/85 406 145 1
5004 06/12/85 403 146 1
5004 06/12/85 406 147 1
5004 06/12/85 403 153 1
I'm fairly new to R so I'm not sure how to go about doing this. Please help!
I believe this answers your question --
dat$bins<-ceiling(dat$LENG/3)*3
ndat<-aggregate(dat[,c('FREQ')],by=list(dat$STA,dat$DATE,dat$SPP,dat$bins),FUN=sum)
The cut() function turns numerics into binned factors.
cutoff_lengths <- seq(0, 180, by = 3)
df$BIN <- cut(df$LENG, cutoff_lengths, labels = cutoff_lengths[-1])
table(df$BIN)
cutoff_lengths[-1] means the labels are all but the first value of cutoff_lengths. Because each bin is between two of the cut points, there's one less bin than there are cut points. And you want to round up, so the lowest cut point isn't used as a label.

Analysis of DEXSeq count table

I am using a platform "Bcbio" for processing RNASeq fastqs. At the end of the process, it generates a number of files like counttables, sailfish raw data and so on. There is also a file called "combined.dexseq" which looks like;
id Control_rep1_1 Control_rep1_2 50ng_1 50ng_2 250ng_1 250ng_2
ENSG00000000003:001 458 495 688 643 619 622
ENSG00000000003:002 143 140 204 153 166 163
ENSG00000000003:003 93 65 117 101 80 112
ENSG00000000003:004 50 47 68 73 54 89
ENSG00000000003:005 66 62 85 109 71 104
ENSG00000000003:006 97 93 152 163 131 153
I want to run a DEXSeq analysis following the vignette but the problem is vignette generates the data form that I have at the very end when featureCounts() function is used.
Can anyone help me with estimating exon fold changes and using other important functions for analysis with using the file format that I have?

Resources