
Recherche avancée
Médias (91)
-
Les Miserables
9 décembre 2019, par
Mis à jour : Décembre 2019
Langue : français
Type : Textuel
-
VideoHandle
8 novembre 2019, par
Mis à jour : Novembre 2019
Langue : français
Type : Video
-
Somos millones 1
21 juillet 2014, par
Mis à jour : Juin 2015
Langue : français
Type : Video
-
Un test - mauritanie
3 avril 2014, par
Mis à jour : Avril 2014
Langue : français
Type : Textuel
-
Pourquoi Obama lit il mes mails ?
4 février 2014, par
Mis à jour : Février 2014
Langue : français
-
IMG 0222
6 octobre 2013, par
Mis à jour : Octobre 2013
Langue : français
Type : Image
Autres articles (4)
-
Keeping control of your media in your hands
13 avril 2011, parThe vocabulary used on this site and around MediaSPIP in general, aims to avoid reference to Web 2.0 and the companies that profit from media-sharing.
While using MediaSPIP, you are invited to avoid using words like "Brand", "Cloud" and "Market".
MediaSPIP is designed to facilitate the sharing of creative media online, while allowing authors to retain complete control of their work.
MediaSPIP aims to be accessible to as many people as possible and development is based on expanding the (...) -
Other interesting software
13 avril 2011, parWe don’t claim to be the only ones doing what we do ... and especially not to assert claims to be the best either ... What we do, we just try to do it well and getting better ...
The following list represents softwares that tend to be more or less as MediaSPIP or that MediaSPIP tries more or less to do the same, whatever ...
We don’t know them, we didn’t try them, but you can take a peek.
Videopress
Website : http://videopress.com/
License : GNU/GPL v2
Source code : (...) -
D’autres logiciels intéressants
12 avril 2011, parOn ne revendique pas d’être les seuls à faire ce que l’on fait ... et on ne revendique surtout pas d’être les meilleurs non plus ... Ce que l’on fait, on essaie juste de le faire bien, et de mieux en mieux...
La liste suivante correspond à des logiciels qui tendent peu ou prou à faire comme MediaSPIP ou que MediaSPIP tente peu ou prou à faire pareil, peu importe ...
On ne les connais pas, on ne les a pas essayé, mais vous pouvez peut être y jeter un coup d’oeil.
Videopress
Site Internet : (...)
Sur d’autres sites (2688)
-
| NGINX | FFMPEG not creating DASH manifests or chunks in the designated DIR |
7 avril 2020, par Mathew KnightHopefully 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 



-
FFmpeg RTSP crash
19 septembre 2016, par bot1131357I am trying to rtsp stream between two consoles on my computer.
On console 1 I have :
ffmpeg -rtbufsize 100M -re -f dshow -s 320x240 -i video="BisonCam, NB Pro" -r 10 -an -f rtsp -rtsp_transport tcp rtsp://127.0.0.1:8554/demo
On console 2 I have :
ffplay -rtsp_flags listen -i rtsp://127.0.0.1:8554/demo
When I run execute both commands, my webcam LED lights up. But then immediately after ffmpeg crashes. Has anyone encountered the same thing ? I could really use some help here.
This is my ffmpeg configuration on a Windows 10 machine :
ffmpeg version N-81391-g2a3720b Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 5.4.0 (GCC)
configuration: --disable-static --enable-shared --enable-gpl --enable-version3 --disable-w32threads --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-libebur128 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-decklink --enable-zlib
libavutil 55. 29.100 / 55. 29.100
libavcodec 57. 54.100 / 57. 54.100
libavformat 57. 47.101 / 57. 47.101
libavdevice 57. 0.102 / 57. 0.102
libavfilter 6. 52.100 / 6. 52.100
libswscale 4. 1.100 / 4. 1.100
libswresample 2. 1.100 / 2. 1.100
libpostproc 54. 0.100 / 54. 0.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...
Use -h to get full help or, even better, run 'man ffmpeg'Update
I tried to stream from a video file, just to be sure that the issue is not related to the webcam.
#Console 1
ffmpeg -i out.mp4 -f rtsp -rtsp_transport tcp rtsp://localhost:8888/live.sdp
#Console 2
ffplay -rtsp_flags listen rtsp://localhost:8888/live.sdp?tcpThe output for both consoles are as follows :
Console 1 :
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'out.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.47.101
Duration: 00:01:02.57, start: 0.000000, bitrate: 172 kb/s
Stream #0:0(und): Video: h264 (High 4:2:2) (avc1 / 0x31637661), yuv422p, 320x240, 169 kb/s, 30 fps, 30 tbr, 10000k tbn, 60 tbc (default)
Metadata:
handler_name : VideoHandler
[rtsp @ 00000000024c1700] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
Output #0, rtsp, to 'rtsp://localhost:8888/live.sdp':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.47.101
Stream #0:0(und): Video: mpeg4, yuv420p, 320x240, q=2-31, 200 kb/s, 30 fps, 90k tbn, 30 tbc (default)
Metadata:
handler_name : VideoHandler
encoder : Lavc57.54.100 mpeg4
Side data:
cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> mpeg4 (native))
Press [q] to stop, [?] for helpConsole 2 :
[rtsp @ 00000000001ccde0] WARNING: Path /live.sdp differs from expected /live.sdp?tcp
Last message repeated 1 times
[rtsp @ 00000000001ccde0] Updating control URI to rtsp://localhost:8888/live.sdp
[rtsp @ 00000000001ccde0] Could not find codec parameters for stream 0 (Video: mpeg4 (Simple Profile), none, 320x240 [SAR 1:1 DAR 4:3]): unspecified pixel format
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Input #0, rtsp, from 'rtsp://localhost:8888/live.sdp?tcp':
Metadata:
title : No Name
Duration: N/A, bitrate: N/A
Stream #0:0: Video: mpeg4 (Simple Profile), none, 320x240 [SAR 1:1 DAR 4:3], 30 tbr, 90k tbn, 30 tbc
nan M-V: nan fd= 0 aq= 0KB vq= 0KB sq= 0B f=0/0The same crash happened with ffmpeg.exe, and ffplay continued waiting for data. I tried the same commands on a Linux virtual machine, and it worked fine.
Any ideas ?
Update
Here’s what I’ve got from gdb :
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'out.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.47.101
Duration: 00:01:02.57, start: 0.000000, bitrate: 172 kb/s
Stream #0:0(und): Video: h264 (High 4:2:2) (avc1 / 0x31637661), yuv422p, 320x240, 169 kb/s, 30 fps, 30 tbr, 10000k tbn, 60 tbc (default)
Metadata:
handler_name : VideoHandler
[New Thread 15408.0x3f28]
[New Thread 15408.0x86c]
[New Thread 15408.0x23c8]
[New Thread 15408.0xf48]
[New Thread 15408.0x354c]
[New Thread 15408.0xf24]
[New Thread 15408.0x1e4c]
[New Thread 15408.0x257c]
[New Thread 15408.0x22a4]
[New Thread 15408.0xc88]
[New Thread 15408.0x40bc]
[New Thread 15408.0x1520]
[New Thread 15408.0x2584]
[New Thread 15408.0x1a64]
[New Thread 15408.0x3934]
[New Thread 15408.0x4010]
[New Thread 15408.0x3d28]
[New Thread 15408.0x288c]
[New Thread 15408.0x1e50]
[New Thread 15408.0x630]
[New Thread 15408.0x4128]
[New Thread 15408.0x3fa0]
[New Thread 15408.0x20ec]
[New Thread 15408.0x4bcc]
[New Thread 15408.0x17b4]
[New Thread 15408.0x1204]
[New Thread 15408.0x2dc8]
[rtsp @ 0000000000e458e0] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
[New Thread 15408.0x1d14]
Output #0, rtsp, to 'rtsp://localhost:8888/live.sdp':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.47.101
Stream #0:0(und): Video: mpeg4, yuv420p, 320x240, q=2-31, 200 kb/s, 30 fps, 90k tbn, 30 tbc (default)
Metadata:
handler_name : VideoHandler
encoder : Lavc57.54.100 mpeg4
Side data:
cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> mpeg4 (native))
Press [q] to stop, [?] for help
Program received signal SIGSEGV, Segmentation fault.
0x00007ff82d95292f in avpriv_mpegts_parse_close () from E:\Dev\Library\ffmpeg-20160819-2a3720b-win64-shared\bin\avformat-57.dllAnd the backtrace :
(gdb) bt
#0 0x00007ff82d95292f in avpriv_mpegts_parse_close () from E:\Dev\Library\ffmpeg-20160819-2a3720b-win64-shared\bin\avformat-57.dll
#1 0x00007ff82d956a1b in avformat-57!av_get_output_timestamp () from E:\Dev\Library\ffmpeg-20160819-2a3720b-win64-shared\bin\avformat-57.dll
#2 0x00007ff82d9a5dbe in ff_rtsp_parse_line () from E:\Dev\Library\ffmpeg-20160819-2a3720b-win64-shared\bin\avformat-57.dll
#3 0x00007ff82d955e6d in avformat-57!av_interleaved_write_frame () from E:\Dev\Library\ffmpeg-20160819-2a3720b-win64-shared\bin\avformat-57.dll
#4 0x000000014001af78 in ?? ()
#5 0x000000014001bda9 in ?? ()
#6 0x000000014001e642 in ?? ()
#7 0x00000001400201f1 in ?? ()
#8 0x000000014004bd47 in ?? ()
#9 0x00000001400013ed in ?? ()
#10 0x000000014000152b in ?? ()
#11 0x00007ff85e2b8102 in KERNEL32!BaseThreadInitThunk () from C:\Windows\system32\kernel32.dll
#12 0x00007ff85edac264 in ntdll!RtlUserThreadStart () from C:\Windows\SYSTEM32\ntdll.dll
#13 0x0000000000000000 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
(gdb)Update 2
Here’s using ffmpeg_g.exe
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'out.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.47.101
Duration: 00:01:02.57, start: 0.000000, bitrate: 172 kb/s
Stream #0:0(und): Video: h264 (High 4:2:2) (avc1 / 0x31637661), yuv422p, 320x240, 169 kb/s, 30 fps, 30 tbr, 10000k tbn, 60 tbc (default)
Metadata:
handler_name : VideoHandler
[New Thread 14052.0x3560]
[New Thread 14052.0x24b4]
[New Thread 14052.0x3554]
[New Thread 14052.0x1a3c]
[New Thread 14052.0x2e64]
[New Thread 14052.0xd0c]
[New Thread 14052.0x29e4]
[New Thread 14052.0x3724]
[New Thread 14052.0x36f8]
[New Thread 14052.0x36f0]
[New Thread 14052.0x78]
[New Thread 14052.0x1578]
[New Thread 14052.0x36a0]
[New Thread 14052.0x3688]
[New Thread 14052.0x369c]
[New Thread 14052.0x1f84]
[New Thread 14052.0x2094]
[New Thread 14052.0x2f14]
[New Thread 14052.0x2c54]
[New Thread 14052.0x3624]
[New Thread 14052.0x2d44]
[New Thread 14052.0x3424]
[New Thread 14052.0x1dd4]
[New Thread 14052.0x20c4]
[New Thread 14052.0x34d8]
[New Thread 14052.0x34e4]
[New Thread 14052.0x3528]
[rtsp @ 0000000000f75a80] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
[New Thread 14052.0x3564]
Output #0, rtsp, to 'rtsp://localhost:8888/live.sdp':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.47.101
Stream #0:0(und): Video: mpeg4, yuv420p, 320x240, q=2-31, 200 kb/s, 30 fps, 90k tbn, 30 tbc (default)
Metadata:
handler_name : VideoHandler
encoder : Lavc57.54.100 mpeg4
Side data:
cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> mpeg4 (native))
Press [q] to stop, [?] for help
Program received signal SIGSEGV, Segmentation fault.
0x00007ffeecd8292f in avpriv_mpegts_parse_close ()
from E:\Dev\Library\ffmpeg-20160819-2a3720b-win64-shared\bin\avformat-57.dll
(gdb) bt
#0 0x00007ffeecd8292f in avpriv_mpegts_parse_close ()
from E:\Dev\Library\ffmpeg-20160819-2a3720b-win64-shared\bin\avformat-57.dll
#1 0x00007ffeecd86a1b in avformat-57!av_get_output_timestamp ()
from E:\Dev\Library\ffmpeg-20160819-2a3720b-win64-shared\bin\avformat-57.dll
#2 0x00007ffeecdd5dbe in ff_rtsp_parse_line ()
from E:\Dev\Library\ffmpeg-20160819-2a3720b-win64-shared\bin\avformat-57.dll
#3 0x00007ffeecd85e6d in avformat-57!av_interleaved_write_frame
()
from E:\Dev\Library\ffmpeg-20160819-2a3720b-win64-shared\bin\avformat-57.dll
#4 0x000000014001af78 in ?? ()
#5 0x000000014001bda9 in ?? ()
#6 0x000000014001e642 in ?? ()
#7 0x00000001400201f1 in ?? ()
#8 0x000000014004bd47 in ?? ()
#9 0x00000001400013ed in ?? ()
---Type <return> to continue, or q <return> to quit---
</return></return>Update 3
After building my own ffmpeg using the
--enable-debug
flag, I’m back at it again. Still getting the same error though. Any ideas ? At this point, it seems like there’s something wrong with my computer settings.ffmpeg version N-81392-ga453bbb Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 5.3.1 (GCC) 20160211
configuration: --prefix=/home/ytan/Dev/build-mingw/ffmpeg/ --enable-cross-compile --cross-prefix=x86_64-w64-mingw32- --arch=x86_64 --target-os=mingw64 --pkg-config-flags=--static --enable-shared --disable-static --enable-libvpx --enable-libvorbis --enable-libmp3lame --enable-openssl --enable-pic --enable-debug --extra-ldlibflags='-static -pthread'
libavutil 55. 29.100 / 55. 29.100
libavcodec 57. 54.100 / 57. 54.100
libavformat 57. 47.101 / 57. 47.101
libavdevice 57. 0.102 / 57. 0.102
libavfilter 6. 52.100 / 6. 52.100
libswscale 4. 1.100 / 4. 1.100
libswresample 2. 1.100 / 2. 1.100
[New Thread 6352.0x1e6c]
[New Thread 6352.0x12fc]
[New Thread 6352.0x1f70]
[New Thread 6352.0x17b0]
[New Thread 6352.0xdac]
Input #0, dshow, from 'video=BisonCam, NB Pro':
Duration: N/A, start: 377578.440000, bitrate: N/A
Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 320x240, 30 fps, 30 tbr, 10000k tbn, 10000k tbc
[New Thread 6352.0x544]
[New Thread 6352.0x1d00]
[New Thread 6352.0x1f14]
[New Thread 6352.0x1bb0]
[New Thread 6352.0xf08]
[New Thread 6352.0x7c8]
[New Thread 6352.0x12d0]
[New Thread 6352.0x504]
[New Thread 6352.0x1a74]
[libvpx @ 0000000002f0dc40] v1.6.0-384-g4a25b59
[rtsp @ 0000000002f0aac0] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
[New Thread 6352.0x11dc]
Output #0, rtsp, to 'rtsp://127.0.0.1:8554/demo':
Metadata:
encoder : Lavf57.47.101
Stream #0:0: Video: vp8 (libvpx), yuv420p, 320x240, q=-1--1, 100 kb/s, 10 fps, 90k tbn, 10 tbc
Metadata:
encoder : Lavc57.54.100 libvpx
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> vp8 (libvpx))
Press [q] to stop, [?] for help
Program received signal SIGSEGV, Segmentation fault.
0x00007ff894fd08af in avpriv_mpegts_parse_close () from E:\Dev\Library\ffmpeg\bin\avformat-57.dll
(gdb) bt
#0 0x00007ff894fd08af in avpriv_mpegts_parse_close () from E:\Dev\Library\ffmpeg\bin\avformat-57.dll
#1 0x00007ff894fd499b in avformat-57!av_get_output_timestamp () from E:\Dev\Library\ffmpeg\bin\avformat-57.dll
#2 0x00007ff89502dbae in ff_rtsp_parse_line () from E:\Dev\Library\ffmpeg\bin\avformat-57.dll
#3 0x00007ff894fd3ded in avformat-57!av_interleaved_write_frame () from E:\Dev\Library\ffmpeg\bin\avformat-57.dll
#4 0x000000014001ab18 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
(gdb) thread apply all bt
Thread 19 (Thread 6352.0x11dc):
#0 0x00007ff8c4804e74 in ntdll!ZwRemoveIoCompletion () from C:\Windows\SYSTEM32\ntdll.dll
#1 0x00007ff8c0663e49 in Tcpip4_WSHStringToAddress () from C:\Windows\system32\mswsock.dll
#2 0x00007ff8c3e58102 in KERNEL32!BaseThreadInitThunk () from C:\Windows\system32\kernel32.dll
#3 0x00007ff8c47bc264 in ntdll!RtlUserThreadStart () from C:\Windows\SYSTEM32\ntdll.dll
#4 0x0000000000000000 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
Thread 18 (Thread 6352.0x1a74):
#0 0x00007ff8c4808404 in ntdll!ZwWaitForAlertByThreadId () from C:\Windows\SYSTEM32\ntdll.dll
#1 0x00007ff8c47c7810 in ntdll!RtlSleepConditionVariableCS () from C:\Windows\SYSTEM32\ntdll.dll
#2 0x00007ff8c0e2bb47 in SleepConditionVariableCS () from C:\Windows\system32\KernelBase.dll
#3 0x00007ff896f59420 in avfilter_graph_parse_ptr () from E:\Dev\Library\ffmpeg\bin\avfilter-6.dll
#4 0x00007ff896f5935f in avfilter_graph_parse_ptr () from E:\Dev\Library\ffmpeg\bin\avfilter-6.dll
#5 0x00007ff8c38ab097 in msvcrt!_beginthreadex () from C:\Windows\system32\msvcrt.dll
#6 0x00007ff8c38ab16c in msvcrt!_endthreadex () from C:\Windows\system32\msvcrt.dll
#7 0x00007ff8c3e58102 in KERNEL32!BaseThreadInitThunk () from C:\Windows\system32\kernel32.dll
#8 0x00007ff8c47bc264 in ntdll!RtlUserThreadStart () from C:\Windows\SYSTEM32\ntdll.dll
#9 0x0000000000000000 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
Thread 17 (Thread 6352.0x504):
#0 0x00007ff8c4808404 in ntdll!ZwWaitForAlertByThreadId () from C:\Windows\SYSTEM32\ntdll.dll
#1 0x00007ff8c47c7810 in ntdll!RtlSleepConditionVariableCS () from C:\Windows\SYSTEM32\ntdll.dll
#2 0x00007ff8c0e2bb47 in SleepConditionVariableCS () from C:\Windows\system32\KernelBase.dll
#3 0x00007ff896f59420 in avfilter_graph_parse_ptr () from E:\Dev\Library\ffmpeg\bin\avfilter-6.dll
#4 0x00007ff896f5935f in avfilter_graph_parse_ptr () from E:\Dev\Library\ffmpeg\bin\avfilter-6.dll
#5 0x00007ff8c38ab097 in msvcrt!_beginthreadex () from C:\Windows\system32\msvcrt.dll
---Type <return> to continue, or q <return> to quit---
#6 0x00007ff8c38ab16c in msvcrt!_endthreadex () from C:\Windows\system32\msvcrt.dll
#7 0x00007ff8c3e58102 in KERNEL32!BaseThreadInitThunk () from C:\Windows\system32\kernel32.dll
#8 0x00007ff8c47bc264 in ntdll!RtlUserThreadStart () from C:\Windows\SYSTEM32\ntdll.dll
#9 0x0000000000000000 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
Thread 16 (Thread 6352.0x12d0):
#0 0x00007ff8c4808404 in ntdll!ZwWaitForAlertByThreadId () from C:\Windows\SYSTEM32\ntdll.dll
#1 0x00007ff8c47c7810 in ntdll!RtlSleepConditionVariableCS () from C:\Windows\SYSTEM32\ntdll.dll
#2 0x00007ff8c0e2bb47 in SleepConditionVariableCS () from C:\Windows\system32\KernelBase.dll
#3 0x00007ff896f59420 in avfilter_graph_parse_ptr () from E:\Dev\Library\ffmpeg\bin\avfilter-6.dll
#4 0x00007ff896f5935f in avfilter_graph_parse_ptr () from E:\Dev\Library\ffmpeg\bin\avfilter-6.dll
#5 0x00007ff8c38ab097 in msvcrt!_beginthreadex () from C:\Windows\system32\msvcrt.dll
#6 0x00007ff8c38ab16c in msvcrt!_endthreadex () from C:\Windows\system32\msvcrt.dll
#7 0x00007ff8c3e58102 in KERNEL32!BaseThreadInitThunk () from C:\Windows\system32\kernel32.dll
#8 0x00007ff8c47bc264 in ntdll!RtlUserThreadStart () from C:\Windows\SYSTEM32\ntdll.dll
#9 0x0000000000000000 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
Thread 15 (Thread 6352.0x7c8):
#0 0x00007ff8c4808404 in ntdll!ZwWaitForAlertByThreadId () from C:\Windows\SYSTEM32\ntdll.dll
#1 0x00007ff8c47c7810 in ntdll!RtlSleepConditionVariableCS () from C:\Windows\SYSTEM32\ntdll.dll
#2 0x00007ff8c0e2bb47 in SleepConditionVariableCS () from C:\Windows\system32\KernelBase.dll
#3 0x00007ff896f59420 in avfilter_graph_parse_ptr () from E:\Dev\Library\ffmpeg\bin\avfilter-6.dll
#4 0x00007ff896f5935f in avfilter_graph_parse_ptr () from E:\Dev\Library\ffmpeg\bin\avfilter-6.dll
#5 0x00007ff8c38ab097 in msvcrt!_beginthreadex () from C:\Windows\system32\msvcrt.dll
#6 0x00007ff8c38ab16c in msvcrt!_endthreadex () from C:\Windows\system32\msvcrt.dll
#7 0x00007ff8c3e58102 in KERNEL32!BaseThreadInitThunk () from C:\Windows\system32\kernel32.dll
#8 0x00007ff8c47bc264 in ntdll!RtlUserThreadStart () from C:\Windows\SYSTEM32\ntdll.dll
---Type <return> to continue, or q <return> to quit---
#9 0x0000000000000000 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
Thread 14 (Thread 6352.0xf08):
#0 0x00007ff8c4808404 in ntdll!ZwWaitForAlertByThreadId () from C:\Windows\SYSTEM32\ntdll.dll
#1 0x00007ff8c47c7810 in ntdll!RtlSleepConditionVariableCS () from C:\Windows\SYSTEM32\ntdll.dll
#2 0x00007ff8c0e2bb47 in SleepConditionVariableCS () from C:\Windows\system32\KernelBase.dll
#3 0x00007ff896f59420 in avfilter_graph_parse_ptr () from E:\Dev\Library\ffmpeg\bin\avfilter-6.dll
#4 0x00007ff896f5935f in avfilter_graph_parse_ptr () from E:\Dev\Library\ffmpeg\bin\avfilter-6.dll
#5 0x00007ff8c38ab097 in msvcrt!_beginthreadex () from C:\Windows\system32\msvcrt.dll
#6 0x00007ff8c38ab16c in msvcrt!_endthreadex () from C:\Windows\system32\msvcrt.dll
#7 0x00007ff8c3e58102 in KERNEL32!BaseThreadInitThunk () from C:\Windows\system32\kernel32.dll
#8 0x00007ff8c47bc264 in ntdll!RtlUserThreadStart () from C:\Windows\SYSTEM32\ntdll.dll
#9 0x0000000000000000 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
Thread 13 (Thread 6352.0x1bb0):
#0 0x00007ff8c4808404 in ntdll!ZwWaitForAlertByThreadId () from C:\Windows\SYSTEM32\ntdll.dll
#1 0x00007ff8c47c7810 in ntdll!RtlSleepConditionVariableCS () from C:\Windows\SYSTEM32\ntdll.dll
#2 0x00007ff8c0e2bb47 in SleepConditionVariableCS () from C:\Windows\system32\KernelBase.dll
#3 0x00007ff896f59420 in avfilter_graph_parse_ptr () from E:\Dev\Library\ffmpeg\bin\avfilter-6.dll
#4 0x00007ff896f5935f in avfilter_graph_parse_ptr () from E:\Dev\Library\ffmpeg\bin\avfilter-6.dll
#5 0x00007ff8c38ab097 in msvcrt!_beginthreadex () from C:\Windows\system32\msvcrt.dll
#6 0x00007ff8c38ab16c in msvcrt!_endthreadex () from C:\Windows\system32\msvcrt.dll
#7 0x00007ff8c3e58102 in KERNEL32!BaseThreadInitThunk () from C:\Windows\system32\kernel32.dll
#8 0x00007ff8c47bc264 in ntdll!RtlUserThreadStart () from C:\Windows\SYSTEM32\ntdll.dll
#9 0x0000000000000000 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
---Type <return> to continue, or q <return> to quit---
Thread 12 (Thread 6352.0x1f14):
#0 0x00007ff8c4808404 in ntdll!ZwWaitForAlertByThreadId () from C:\Windows\SYSTEM32\ntdll.dll
#1 0x00007ff8c47c7810 in ntdll!RtlSleepConditionVariableCS () from C:\Windows\SYSTEM32\ntdll.dll
#2 0x00007ff8c0e2bb47 in SleepConditionVariableCS () from C:\Windows\system32\KernelBase.dll
#3 0x00007ff896f59420 in avfilter_graph_parse_ptr () from E:\Dev\Library\ffmpeg\bin\avfilter-6.dll
#4 0x00007ff896f5935f in avfilter_graph_parse_ptr () from E:\Dev\Library\ffmpeg\bin\avfilter-6.dll
#5 0x00007ff8c38ab097 in msvcrt!_beginthreadex () from C:\Windows\system32\msvcrt.dll
#6 0x00007ff8c38ab16c in msvcrt!_endthreadex () from C:\Windows\system32\msvcrt.dll
#7 0x00007ff8c3e58102 in KERNEL32!BaseThreadInitThunk () from C:\Windows\system32\kernel32.dll
#8 0x00007ff8c47bc264 in ntdll!RtlUserThreadStart () from C:\Windows\SYSTEM32\ntdll.dll
#9 0x0000000000000000 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
Thread 11 (Thread 6352.0x1d00):
#0 0x00007ff8c4808404 in ntdll!ZwWaitForAlertByThreadId () from C:\Windows\SYSTEM32\ntdll.dll
#1 0x00007ff8c47c7810 in ntdll!RtlSleepConditionVariableCS () from C:\Windows\SYSTEM32\ntdll.dll
#2 0x00007ff8c0e2bb47 in SleepConditionVariableCS () from C:\Windows\system32\KernelBase.dll
#3 0x00007ff896f59420 in avfilter_graph_parse_ptr () from E:\Dev\Library\ffmpeg\bin\avfilter-6.dll
#4 0x00007ff896f5935f in avfilter_graph_parse_ptr () from E:\Dev\Library\ffmpeg\bin\avfilter-6.dll
#5 0x00007ff8c38ab097 in msvcrt!_beginthreadex () from C:\Windows\system32\msvcrt.dll
#6 0x00007ff8c38ab16c in msvcrt!_endthreadex () from C:\Windows\system32\msvcrt.dll
#7 0x00007ff8c3e58102 in KERNEL32!BaseThreadInitThunk () from C:\Windows\system32\kernel32.dll
#8 0x00007ff8c47bc264 in ntdll!RtlUserThreadStart () from C:\Windows\SYSTEM32\ntdll.dll
#9 0x0000000000000000 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
Thread 10 (Thread 6352.0x544):
#0 0x00007ff8c4808404 in ntdll!ZwWaitForAlertByThreadId () from C:\Windows\SYSTEM32\ntdll.dll
#1 0x00007ff8c47c7810 in ntdll!RtlSleepConditionVariableCS () from C:\Windows\SYSTEM32\ntdll.dll
---Type <return> to continue, or q <return> to quit---
#2 0x00007ff8c0e2bb47 in SleepConditionVariableCS () from C:\Windows\system32\KernelBase.dll
#3 0x00007ff896f59420 in avfilter_graph_parse_ptr () from E:\Dev\Library\ffmpeg\bin\avfilter-6.dll
#4 0x00007ff896f5935f in avfilter_graph_parse_ptr () from E:\Dev\Library\ffmpeg\bin\avfilter-6.dll
#5 0x00007ff8c38ab097 in msvcrt!_beginthreadex () from C:\Windows\system32\msvcrt.dll
#6 0x00007ff8c38ab16c in msvcrt!_endthreadex () from C:\Windows\system32\msvcrt.dll
#7 0x00007ff8c3e58102 in KERNEL32!BaseThreadInitThunk () from C:\Windows\system32\kernel32.dll
#8 0x00007ff8c47bc264 in ntdll!RtlUserThreadStart () from C:\Windows\SYSTEM32\ntdll.dll
#9 0x0000000000000000 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
Thread 9 (Thread 6352.0xdac):
#0 0x00007ff8c48058a4 in ntdll!ZwWaitForMultipleObjects () from C:\Windows\SYSTEM32\ntdll.dll
#1 0x00007ff8c0e53b2f in WaitForMultipleObjectsEx () from C:\Windows\system32\KernelBase.dll
#2 0x00007ff8a2d4428b in ksproxy!DllUnregisterServer () from C:\Windows\System32\ksproxy.ax
#3 0x00007ff8c3e58102 in KERNEL32!BaseThreadInitThunk () from C:\Windows\system32\kernel32.dll
#4 0x00007ff8c47bc264 in ntdll!RtlUserThreadStart () from C:\Windows\SYSTEM32\ntdll.dll
#5 0x0000000000000000 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
Thread 8 (Thread 6352.0x17b0):
#0 0x00007ff8c4804dd4 in ntdll!ZwWaitForSingleObject () from C:\Windows\SYSTEM32\ntdll.dll
#1 0x00007ff8c0e2aadf in WaitForSingleObjectEx () from C:\Windows\system32\KernelBase.dll
#2 0x00007ff8a2d5a8bb in ksproxy!KsResolveRequiredAttributes () from C:\Windows\System32\ksproxy.ax
#3 0x00007ff8c3e58102 in KERNEL32!BaseThreadInitThunk () from C:\Windows\system32\kernel32.dll
#4 0x00007ff8c47bc264 in ntdll!RtlUserThreadStart () from C:\Windows\SYSTEM32\ntdll.dll
#5 0x0000000000000000 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
Thread 7 (Thread 6352.0x1f70):
---Type <return> to continue, or q <return> to quit---
#0 0x00007ff8c4804dd4 in ntdll!ZwWaitForSingleObject () from C:\Windows\SYSTEM32\ntdll.dll
#1 0x00007ff8c0e2aadf in WaitForSingleObjectEx () from C:\Windows\system32\KernelBase.dll
#2 0x00007ff896241b63 in ?? () from C:\Windows\System32\quartz.dll
#3 0x00007ff8c3e58102 in KERNEL32!BaseThreadInitThunk () from C:\Windows\system32\kernel32.dll
#4 0x00007ff8c47bc264 in ntdll!RtlUserThreadStart () from C:\Windows\SYSTEM32\ntdll.dll
#5 0x0000000000000000 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
Thread 6 (Thread 6352.0x12fc):
#0 0x00007ff8c48058a4 in ntdll!ZwWaitForMultipleObjects () from C:\Windows\SYSTEM32\ntdll.dll
#1 0x00007ff8c0e53b2f in WaitForMultipleObjectsEx () from C:\Windows\system32\KernelBase.dll
#2 0x00007ff8c0e53a2e in WaitForMultipleObjects () from C:\Windows\system32\KernelBase.dll
#3 0x00007ff8a2d5b312 in ksproxy!KsResolveRequiredAttributes () from C:\Windows\System32\ksproxy.ax
#4 0x00007ff8c3e58102 in KERNEL32!BaseThreadInitThunk () from C:\Windows\system32\kernel32.dll
#5 0x00007ff8c47bc264 in ntdll!RtlUserThreadStart () from C:\Windows\SYSTEM32\ntdll.dll
#6 0x0000000000000000 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
Thread 5 (Thread 6352.0x1e6c):
#0 0x00007ff8c32a1f74 in USER32!InvalidateRect () from C:\Windows\system32\user32.dll
#1 0x00007ff8c3292e15 in USER32!GetMessageW () from C:\Windows\system32\user32.dll
#2 0x00007ff89628ac1d in QUARTZ!AMGetErrorTextW () from C:\Windows\System32\quartz.dll
#3 0x00007ff8c3e58102 in KERNEL32!BaseThreadInitThunk () from C:\Windows\system32\kernel32.dll
#4 0x00007ff8c47bc264 in ntdll!RtlUserThreadStart () from C:\Windows\SYSTEM32\ntdll.dll
#5 0x0000000000000000 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
Thread 4 (Thread 6352.0x1a7c):
#0 0x00007ff8c4808464 in ntdll!ZwWaitForWorkViaWorkerFactory () from C:\Windows\SYSTEM32\ntdll.dll
---Type <return> to continue, or q <return> to quit---
#1 0x00007ff8c478b2e8 in ntdll!RtlAcquireSRWLockShared () from C:\Windows\SYSTEM32\ntdll.dll
#2 0x00007ff8c3e58102 in KERNEL32!BaseThreadInitThunk () from C:\Windows\system32\kernel32.dll
#3 0x00007ff8c47bc264 in ntdll!RtlUserThreadStart () from C:\Windows\SYSTEM32\ntdll.dll
#4 0x0000000000000000 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
Thread 3 (Thread 6352.0x13b0):
#0 0x00007ff8c4808464 in ntdll!ZwWaitForWorkViaWorkerFactory () from C:\Windows\SYSTEM32\ntdll.dll
#1 0x00007ff8c478b2e8 in ntdll!RtlAcquireSRWLockShared () from C:\Windows\SYSTEM32\ntdll.dll
#2 0x00007ff8c3e58102 in KERNEL32!BaseThreadInitThunk () from C:\Windows\system32\kernel32.dll
#3 0x00007ff8c47bc264 in ntdll!RtlUserThreadStart () from C:\Windows\SYSTEM32\ntdll.dll
#4 0x0000000000000000 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
Thread 2 (Thread 6352.0x214c):
#0 0x00007ff8c4808464 in ntdll!ZwWaitForWorkViaWorkerFactory () from C:\Windows\SYSTEM32\ntdll.dll
#1 0x00007ff8c478b2e8 in ntdll!RtlAcquireSRWLockShared () from C:\Windows\SYSTEM32\ntdll.dll
#2 0x00007ff8c3e58102 in KERNEL32!BaseThreadInitThunk () from C:\Windows\system32\kernel32.dll
#3 0x00007ff8c47bc264 in ntdll!RtlUserThreadStart () from C:\Windows\SYSTEM32\ntdll.dll
#4 0x0000000000000000 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
Thread 1 (Thread 6352.0xc70):
#0 0x00007ff894fd08af in avpriv_mpegts_parse_close () from E:\Dev\Library\ffmpeg\bin\avformat-57.dll
#1 0x00007ff894fd499b in avformat-57!av_get_output_timestamp () from E:\Dev\Library\ffmpeg\bin\avformat-57.dll
#2 0x00007ff89502dbae in ff_rtsp_parse_line () from E:\Dev\Library\ffmpeg\bin\avformat-57.dll
#3 0x00007ff894fd3ded in avformat-57!av_interleaved_write_frame () from E:\Dev\Library\ffmpeg\bin\avformat-57.dll
#4 0x000000014001ab18 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
</return></return></return></return></return></return></return></return></return></return></return></return> -
FFmpeg WASM writeFile Stalls and Doesn't Complete in React App with Ant Design
26 février, par raiyan khanI'm using FFmpeg WebAssembly (WASM) in a React app to process and convert a video file before uploading it. The goal is to resize the video to 720p using FFmpeg before sending it to the backend.


Problem :


Everything works up to fetching the file and confirming it's loaded into memory, but FFmpeg hangs at ffmpeg.writeFile() and does not proceed further. No errors are thrown.


Code Snippet :


- 

-
Loading FFmpeg


const loadFFmpeg = async () => {
 if (loaded) return; // Avoid reloading if 
 already loaded

 const baseURL = 'https://unpkg.com/@ffmpeg/core@0.12.6/dist/umd';
 const ffmpeg = ffmpegRef.current;
 ffmpeg.on('log', ({ message }) => {
 messageRef.current.innerHTML = message;
 console.log(message);
 });
 await ffmpeg.load({
 coreURL: await toBlobURL(`${baseURL}/ffmpeg-core.js`, 'text/javascript'),
 wasmURL: await toBlobURL(`${baseURL}/ffmpeg-core.wasm`, 'application/wasm'),
 });
 setLoaded(true);
 };

 useEffect(() => {
 loadFFmpeg()
 }, [])



-
Fetching and Writing File


const convertVideoTo720p = async (videoFile) => {
 console.log("Starting video 
 conversion...");



 const { height } = await getVideoMetadata(videoFile);
 console.log(`Video height: ${height}`);

 if (height <= 720) {
 console.log("No conversion needed.");
 return videoFile;
 }

 const ffmpeg = ffmpegRef.current;
 console.log("FFmpeg instance loaded. Writing file to memory...");

 const fetchedFile = await fetchFile(videoFile);
 console.log("File fetched successfully:", fetchedFile);

 console.log("Checking FFmpeg memory before writing...");
 console.log(`File size: ${fetchedFile.length} bytes (~${(fetchedFile.length / 1024 / 1024).toFixed(2)} MB)`);

 if (!ffmpeg.isLoaded()) {
 console.error("FFmpeg is not fully loaded yet!");
 return;
 }

 console.log("Memory seems okay. Writing file to FFmpeg...");
 await ffmpeg.writeFile('input.mp4', fetchedFile); // ❌ This line hangs, nothing after runs
 console.log("File successfully written to FFmpeg memory.");
 };









Debugging Steps I've Tried :


- 

- Ensured FFmpeg is fully loaded before calling
writeFile()

✅ffmpeg.isLoaded()
returnstrue
. - Checked file fetch process :
✅
fetchFile(videoFile)
successfully returns aUint8Array
. - Tried renaming the file to prevent caching issues
✅ Used a unique file name like
video_${Date.now()}.mp4
, but no change - Checked browser console for errors :
❌ No errors are displayed.
- Tried skipping FFmpeg and uploading the raw file instead :
✅ Upload works fine without FFmpeg, so the issue is specific to FFmpeg.












Expected Behavior


- 

ffmpeg.writeFile('input.mp4', fetchedFile);
should complete and allow FFmpeg to process the video.




Actual Behavior


- 

- Execution stops at
writeFile
, and no errors are thrown.




Environment :


- 

- React : 18.x
- FFmpeg WASM Version : @ffmpeg/ffmpeg@0.12.15
- Browser : Chrome 121, Edge 120
- Operating System : Windows 11










Question :
Why is FFmpeg's
writeFile()
stalling and never completing ?
How can I fix or further debug this issue ?

Here is my full code :




import { useNavigate } from "react-router-dom";
import { useEffect, useRef, useState } from 'react';
import { Form, Input, Button, Select, Space } from 'antd';
const { Option } = Select;
import { FaAngleLeft } from "react-icons/fa6";
import { message, Upload } from 'antd';
import { CiCamera } from "react-icons/ci";
import { IoVideocamOutline } from "react-icons/io5";
import { useCreateWorkoutVideoMutation } from "../../../redux/features/workoutVideo/workoutVideoApi";
import { convertVideoTo720p } from "../../../utils/ffmpegHelper";
import { FFmpeg } from '@ffmpeg/ffmpeg';
import { fetchFile, toBlobURL } from '@ffmpeg/util';


const AddWorkoutVideo = () => {
 const [videoFile, setVideoFile] = useState(null);
 const [imageFile, setImageFile] = useState(null);
 const [loaded, setLoaded] = useState(false);
 const ffmpegRef = useRef(new FFmpeg());
 const videoRef = useRef(null);
 const messageRef = useRef(null);
 const [form] = Form.useForm();
 const [createWorkoutVideo, { isLoading }] = useCreateWorkoutVideoMutation()
 const navigate = useNavigate();

 const videoFileRef = useRef(null); // Use a ref instead of state


 // Handle Video Upload
 const handleVideoChange = ({ file }) => {
 setVideoFile(file.originFileObj);
 };

 // Handle Image Upload
 const handleImageChange = ({ file }) => {
 setImageFile(file.originFileObj);
 };

 // Load FFmpeg core if needed (optional if you want to preload)
 const loadFFmpeg = async () => {
 if (loaded) return; // Avoid reloading if already loaded

 const baseURL = 'https://unpkg.com/@ffmpeg/core@0.12.6/dist/umd';
 const ffmpeg = ffmpegRef.current;
 ffmpeg.on('log', ({ message }) => {
 messageRef.current.innerHTML = message;
 console.log(message);
 });
 await ffmpeg.load({
 coreURL: await toBlobURL(`${baseURL}/ffmpeg-core.js`, 'text/javascript'),
 wasmURL: await toBlobURL(`${baseURL}/ffmpeg-core.wasm`, 'application/wasm'),
 });
 setLoaded(true);
 };

 useEffect(() => {
 loadFFmpeg()
 }, [])

 // Helper: Get video metadata (width and height)
 const getVideoMetadata = (file) => {
 return new Promise((resolve, reject) => {
 const video = document.createElement('video');
 video.preload = 'metadata';
 video.onloadedmetadata = () => {
 resolve({ width: video.videoWidth, height: video.videoHeight });
 };
 video.onerror = () => reject(new Error('Could not load video metadata'));
 video.src = URL.createObjectURL(file);
 });
 };

 // Inline conversion helper function
 // const convertVideoTo720p = async (videoFile) => {
 // // Check the video resolution first
 // const { height } = await getVideoMetadata(videoFile);
 // if (height <= 720) {
 // // No conversion needed
 // return videoFile;
 // }
 // const ffmpeg = ffmpegRef.current;
 // // Load ffmpeg if not already loaded
 // // await ffmpeg.load({
 // // coreURL: await toBlobURL(`${baseURL}/ffmpeg-core.js`, 'text/javascript'),
 // // wasmURL: await toBlobURL(`${baseURL}/ffmpeg-core.wasm`, 'application/wasm'),
 // // });
 // // Write the input file to the ffmpeg virtual FS
 // await ffmpeg.writeFile('input.mp4', await fetchFile(videoFile));
 // // Convert video to 720p (scale filter maintains aspect ratio)
 // await ffmpeg.exec(['-i', 'input.mp4', '-vf', 'scale=-1:720', 'output.mp4']);
 // // Read the output file
 // const data = await ffmpeg.readFile('output.mp4');
 // console.log(data, 'data from convertVideoTo720p');
 // const videoBlob = new Blob([data.buffer], { type: 'video/mp4' });
 // return new File([videoBlob], 'output.mp4', { type: 'video/mp4' });
 // };
 const convertVideoTo720p = async (videoFile) => {
 console.log("Starting video conversion...");

 // Check the video resolution first
 const { height } = await getVideoMetadata(videoFile);
 console.log(`Video height: ${height}`);

 if (height <= 720) {
 console.log("No conversion needed. Returning original file.");
 return videoFile;
 }

 const ffmpeg = ffmpegRef.current;
 console.log("FFmpeg instance loaded. Writing file to memory...");

 // await ffmpeg.writeFile('input.mp4', await fetchFile(videoFile));
 // console.log("File written. Starting conversion...");
 console.log("Fetching file for FFmpeg:", videoFile);
 const fetchedFile = await fetchFile(videoFile);
 console.log("File fetched successfully:", fetchedFile);
 console.log("Checking FFmpeg memory before writing...");
 console.log(`File size: ${fetchedFile.length} bytes (~${(fetchedFile.length / 1024 / 1024).toFixed(2)} MB)`);

 if (fetchedFile.length > 50 * 1024 * 1024) { // 50MB limit
 console.error("File is too large for FFmpeg WebAssembly!");
 message.error("File too large. Try a smaller video.");
 return;
 }

 console.log("Memory seems okay. Writing file to FFmpeg...");
 const fileName = `video_${Date.now()}.mp4`; // Generate a unique name
 console.log(`Using filename: ${fileName}`);

 await ffmpeg.writeFile(fileName, fetchedFile);
 console.log(`File successfully written to FFmpeg memory as ${fileName}.`);

 await ffmpeg.exec(['-i', 'input.mp4', '-vf', 'scale=-1:720', 'output.mp4']);
 console.log("Conversion completed. Reading output file...");

 const data = await ffmpeg.readFile('output.mp4');
 console.log("File read successful. Creating new File object.");

 const videoBlob = new Blob([data.buffer], { type: 'video/mp4' });
 const convertedFile = new File([videoBlob], 'output.mp4', { type: 'video/mp4' });

 console.log(convertedFile, "converted video from convertVideoTo720p");

 return convertedFile;
 };


 const onFinish = async (values) => {
 // Ensure a video is selected
 if (!videoFileRef.current) {
 message.error("Please select a video file.");
 return;
 }

 // Create FormData
 const formData = new FormData();
 if (imageFile) {
 formData.append("image", imageFile);
 }

 try {
 message.info("Processing video. Please wait...");

 // Convert the video to 720p only if needed
 const convertedVideo = await convertVideoTo720p(videoFileRef.current);
 console.log(convertedVideo, 'convertedVideo from onFinish');

 formData.append("media", videoFileRef.current);

 formData.append("data", JSON.stringify(values));

 // Upload manually to the backend
 const response = await createWorkoutVideo(formData).unwrap();
 console.log(response, 'response from add video');

 message.success("Video added successfully!");
 form.resetFields(); // Reset form
 setVideoFile(null); // Clear file

 } catch (error) {
 message.error(error.data?.message || "Failed to add video.");
 }

 // if (videoFile) {
 // message.info("Processing video. Please wait...");
 // try {
 // // Convert the video to 720p only if needed
 // const convertedVideo = await convertVideoTo720p(videoFile);
 // formData.append("media", convertedVideo);
 // } catch (conversionError) {
 // message.error("Video conversion failed.");
 // return;
 // }
 // }
 // formData.append("data", JSON.stringify(values)); // Convert text fields to JSON

 // try {
 // const response = await createWorkoutVideo(formData).unwrap();
 // console.log(response, 'response from add video');

 // message.success("Video added successfully!");
 // form.resetFields(); // Reset form
 // setFile(null); // Clear file
 // } catch (error) {
 // message.error(error.data?.message || "Failed to add video.");
 // }
 };

 const handleBackButtonClick = () => {
 navigate(-1); // This takes the user back to the previous page
 };

 const videoUploadProps = {
 name: 'video',
 // action: 'https://660d2bd96ddfa2943b33731c.mockapi.io/api/upload',
 // headers: {
 // authorization: 'authorization-text',
 // },
 // beforeUpload: (file) => {
 // const isVideo = file.type.startsWith('video/');
 // if (!isVideo) {
 // message.error('You can only upload video files!');
 // }
 // return isVideo;
 // },
 // onChange(info) {
 // if (info.file.status === 'done') {
 // message.success(`${info.file.name} video uploaded successfully`);
 // } else if (info.file.status === 'error') {
 // message.error(`${info.file.name} video upload failed.`);
 // }
 // },
 beforeUpload: (file) => {
 const isVideo = file.type.startsWith('video/');
 if (!isVideo) {
 message.error('You can only upload video files!');
 return Upload.LIST_IGNORE; // Prevents the file from being added to the list
 }
 videoFileRef.current = file; // Store file in ref
 // setVideoFile(file); // Store the file in state instead of uploading it automatically
 return false; // Prevent auto-upload
 },
 };

 const imageUploadProps = {
 name: 'image',
 action: 'https://660d2bd96ddfa2943b33731c.mockapi.io/api/upload',
 headers: {
 authorization: 'authorization-text',
 },
 beforeUpload: (file) => {
 const isImage = file.type.startsWith('image/');
 if (!isImage) {
 message.error('You can only upload image files!');
 }
 return isImage;
 },
 onChange(info) {
 if (info.file.status === 'done') {
 message.success(`${info.file.name} image uploaded successfully`);
 } else if (info.file.status === 'error') {
 message.error(`${info.file.name} image upload failed.`);
 }
 },
 };
 return (
 <>
 <div classname="flex items-center gap-2 text-xl cursor-pointer">
 <faangleleft></faangleleft>
 <h1 classname="font-semibold">Add Video</h1>
 </div>
 <div classname="rounded-lg py-4 border-[#79CDFF] border-2 shadow-lg mt-8 bg-white">
 <div classname="space-y-[24px] min-h-[83vh] bg-light-gray rounded-2xl">
 <h3 classname="text-2xl text-[#174C6B] mb-4 border-b border-[#79CDFF]/50 pb-3 pl-16 font-semibold">
 Adding Video
 </h3>
 <div classname="w-full px-16">
 / style={{ maxWidth: 600, margin: '0 auto' }}
 >
 {/* Section 1 */}
 {/* <space direction="vertical" style="{{"> */}
 {/* <space size="large" direction="horizontal" classname="responsive-space"> */}
 <div classname="grid grid-cols-2 gap-8 mt-8">
 <div>
 <space size="large" direction="horizontal" classname="responsive-space-section-2">

 {/* Video */}
 Upload Video}
 name="media"
 className="responsive-form-item"
 // rules={[{ required: true, message: 'Please enter the package amount!' }]}
 >
 <upload maxcount="{1}">
 <button style="{{" solid="solid">
 <span style="{{" 600="600">Select a video</span>
 <iovideocamoutline size="{20}" color="#174C6B"></iovideocamoutline>
 </button>
 </upload>
 

 {/* Thumbnail */}
 Upload Image}
 name="image"
 className="responsive-form-item"
 // rules={[{ required: true, message: 'Please enter the package amount!' }]}
 >
 <upload maxcount="{1}">
 <button style="{{" solid="solid">
 <span style="{{" 600="600">Select an image</span>
 <cicamera size="{25}" color="#174C6B"></cicamera>
 </button>
 </upload>
 

 {/* Title */}
 Video Title}
 name="name"
 className="responsive-form-item-section-2"
 >
 <input type="text" placeholder="Enter video title" style="{{&#xA;" solid="solid" />
 
 </space>
 </div>
 </div>

 {/* </space> */}
 {/* </space> */}


 {/* Submit Button */}
 
 <div classname="p-4 mt-10 text-center mx-auto flex items-center justify-center">
 
 <span classname="text-white font-semibold">{isLoading ? 'Uploading...' : 'Upload'}</span>
 
 </div>
 
 
 </div>
 </div>
 </div>
 >
 )
}

export default AddWorkoutVideo







Would appreciate any insights or suggestions. Thanks !


-