
Recherche avancée
Autres articles (7)
-
Emballe médias : à quoi cela sert ?
4 février 2011, parCe plugin vise à gérer des sites de mise en ligne de documents de tous types.
Il crée des "médias", à savoir : un "média" est un article au sens SPIP créé automatiquement lors du téléversement d’un document qu’il soit audio, vidéo, image ou textuel ; un seul document ne peut être lié à un article dit "média" ; -
Déploiements possibles
31 janvier 2010, parDeux types de déploiements sont envisageable dépendant de deux aspects : La méthode d’installation envisagée (en standalone ou en ferme) ; Le nombre d’encodages journaliers et la fréquentation envisagés ;
L’encodage de vidéos est un processus lourd consommant énormément de ressources système (CPU et RAM), il est nécessaire de prendre tout cela en considération. Ce système n’est donc possible que sur un ou plusieurs serveurs dédiés.
Version mono serveur
La version mono serveur consiste à n’utiliser qu’une (...) -
Menus personnalisés
14 novembre 2010, parMediaSPIP utilise le plugin Menus pour gérer plusieurs menus configurables pour la navigation.
Cela permet de laisser aux administrateurs de canaux la possibilité de configurer finement ces menus.
Menus créés à l’initialisation du site
Par défaut trois menus sont créés automatiquement à l’initialisation du site : Le menu principal ; Identifiant : barrenav ; Ce menu s’insère en général en haut de la page après le bloc d’entête, son identifiant le rend compatible avec les squelettes basés sur Zpip ; (...)
Sur d’autres sites (3768)
-
av_interleaved_write_frame() : Connection reset by peer - Using ffmpeg connected to local nginx
10 avril 2019, par haxporI have a local nginx web server installed with nginx-rtmp-module.
I have 2 RTMP sources that are fed into local network at
rtmp://127.0.0.1/live-video
, andrtmp://127.0.0.1/live-audio
. Then these twos will be combined and fed intortmp://127.0.0.1/live
again. The latter one will be the one that I will be using.The reason I did just that is I want to do noise reduction via
sox
.The setup is as follows
-
rtmp://127.0.0.1/live-video
- it usesffmpeg
to capture only screen (video) then output to such URL with commandffmpeg -analyzeduration 0 -video_size 1280x1080 -framerate 25 -f x11grab -i :0.0 -vcodec libx264 -flags +global_header -preset ultrafast -minrate 7200 -maxrate 8k -vsync 1 -f flv -metadata streamName=ZombieHeroLiveStream rtmp://127.0.0.1/live-video
-
rtmp://127.0.0.1/live-audio
- it usessox
to do noise reduction then usesffmpeg
to feed into such URL with commandffmpeg -f alsa -ac 1 -i default -preset ultrafast -f flac - | sox - -p noisered /tmp/noise.prof 0.21 | ffmpeg -analyzeduration 0 -thread_queue_size 2 -i - -f flv -preset ultrafast rtmp://127.0.0.1/live-audio
-
rtmp://127.0.0.1/live
- it usesffmpeg
to combine the above two sources then output into such URL, this is the one I tested viewing via VLC (which is works fine) with commandffmpeg -analyzeduration 0 -thread_queue_size 512 -rtmp_live live -flags +global_header -i "rtmp://127.0.0.1/live-video" -analyzeduration 0 -thread_queue_size 512 -rtmp_live live -flags +global_header -i "rtmp://127.0.0.1/live-audio" -c:v copy -c:a copy -map 0:v -map 1:a -async 1 -vsync 1 -video_size 1280x1080 -fflags +genpts -framerate 30 -preset ultrafast -minrate 7200 -maxrate 8k -flags +global_header -segment_list_flags +live -rtmp_live live -f flv -metadata streamName=ZombieHeroLiveStream "rtmp://127.0.0.1/live"
The setup works fine, I tested and confirmed viewing via VLC targeting to URL of 3. The problem is that for some times after all threes above up and running, 1. will exit and thus make the whole encoding stop. The error shown is
av_interleaved_write_frame(): Connection reset by peer29.88 bitrate=2021.8kbits/s dup=1791 drop=0 speed=0.998x
Last message repeated 2 times
...
Error writing trailer of rtmp://127.0.0.1/live-video: Connection reset by peerNo matter how I change and modify command line’s flags/options, it will end up like error above. Please note, I’ve modified flags quite a lot thus a certain flags might be possibly not needed.
Full error log from 1. is here.
Configuration of nginx server is here. It’s pretty much basic, but I will further use it to relay to multiple target RTMP servers later.
I’m on Ubuntu 18.04, 4.18.0-17-generic with 8 GB of RAM, 4 CPU Cores with ffmpeg
ffmpeg version 3.4.4-0ubuntu0.18.04.1 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 7 (Ubuntu 7.3.0-16ubuntu3), and with Nginx
nginx version: nginx/1.14.2
built by gcc 7.3.0 (Ubuntu 7.3.0-27ubuntu1~18.04)
built with OpenSSL 1.1.0g 2 Nov 2017 (running with OpenSSL 1.1.1b 26 Feb 2019)
TLS SNI support enabled
configure arguments: --with-http_ssl_module --add-module=../nginx-rtmp-module-1.2.1So again the question is how can I fix such issue ?
Any suggestion would be appreciated.Important edit : I just found out I entered a wrong duplicated command for 3. Now it has been corrected ! Sorry about that.
Update : I’m able to record audio with ffmpeg then do noise filter with sox, then stream to target rtmp with ffmpeg. But noise reduction doesn’t satisfy me yet. See above at 2. for its updated command. And according to this, sox has problem in understand a few bytes so I use flac format in piping instead. Still my question remained as this update is for improvement for command in 2.
-
-
make ffmpeg chose Nvidia CUDA over Intel QSV (Windows 10 with two video adapters)
3 avril 2024, par Bart LedermanI just set up a 'new' PC with built-in Intel video and an Nvida card : mostly to speed up video processing with ffmpeg and other programs. At first the built-in Intel was disabled, running only the Nvidia card. ffmpeg worked as expected, the CPU could be used for decoding and encoding.


However : VirtualDub, a program I use frequently, has a problem with Nvidia cards (at least on Windows 10). The display gets screwed up, previews don't work, and all sorts of other problems occur. I tried all of the various discussion boards, and nobody has a good solution. (The problem is apparently split between VirtualDub and Nvidia, as all other programs such as VideoLan, Avidemux, HandBrake, OBS studio, etc, all appear to work fine.)


So I re-enabled the on-board Intel adapter, and made that my primary and only video with a monitor. The Nvidia card is still there, but with no monitor attached. I really only need it for hardware acceleration.


HandBrake and OBS Studio found the card and used it with no problem.


However, my batch file that specified cuda for both decoding and encoding failed to run. The ffmpeg command that includes -hwaccel cuda resulted in :


[h264 @ 000002783beaa700] Hardware is lacking required capabilities 
[h264 @ 000002783beaa700] Failed setup for format cuda: hwaccel initialisation returned error.



I also tried -hwaccel nvenc, which is rejected. It's apparently not a synonym in this version of ffmpeg :


ffmpeg version 4.3.1-2021-01-01-full_build-www.gyan.dev Copyright (c) 2000-2021 the FFmpeg developers built with gcc 10.2.0 (Rev5, Built by MSYS2 project) configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-lzma --enable-libsnappy --enable-zlib --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libdav1d --enable-libzvbi --enable-librav1e --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint libavutil 56. 51.100 / 56. 51.100 libavcodec 58. 91.100 / 58. 91.100 libavformat 58. 45.100 / 58. 45.100 libavdevice 58. 10.100 / 58. 10.100 libavfilter 7. 85.100 / 7. 85.100 libswscale 5. 7.100 / 5. 7.100 libswresample 3. 7.100 / 3. 7.100 libpostproc 55. 7.100 / 55. 7.100



When I use QSV acceleration on my other PC I have to do this :


-init_hw_device qsv=qsv -hwaccel qsv



so I tried


-init_hw_device cuda=cuda -hwaccel cuda



but that didn't work either.


I've seen comments about the ability to select the GPU if there is more than one board installed, using the -gpu option. However, when I try to use -gpu 0 or -gpu 1 I get :


Codec AVOption gpu (Selects which NVENC capable GPU to use. First GPU is 0, second is 1, and so on.) specified for input file #0 (xxx.avi) is not a decoding option.


I looked at :


https://github.com/FFmpeg/FFmpeg/commit/527a1e213167123d24d014bc0b956ef43d9d6542


to get more information on -init_hw_device, but I'm sorry to say that what's on that page makes no sense to me at all. There are no examples, and no explanation of how to actually select a device.


I looked at :


https://docs.nvidia.com/video-technologies/video-codec-sdk/ffmpeg-with-nvidia-gpu/


which has an 'example' of -init_hw_device, and I did a cut and paste of what they had there to my batch file, but it was rejected.


I also looked at :


How to to burn subtitles based image on video using ’overlay_cuda’, ffmpeg video filter


which has two examples of how to initialize a cuda device, and they don't work for me either. -init_hw_device cuda=cuda is accepted without error, but then -hwaccel cuda still fails. Trying to use the hw accelerated filter scale_cuda also fails.


So how do I get the Nvidia card to decode video when it's not the only graphics adapter ? I was able to decode video when only the Nvidia card was active, there "must" be a way to get to it now. I just need to know how to tell ffmpeg to use the card that is there. Since it has no problem finding the card for encoding, shouldn't it also still be able to find the card for decoding and filters ? Or am I really the first person ever to have both Intel and Nvidia graphics adapters working on my system and trying to use ffmpeg with hardware acceleration ?


=====================


Latest update.


I had tried the examples on the Nvidia FFmpeg transcoding guide web page, and as mentioned previously I still got errors. I did a cut and paste from that web page to my command window, and ffmpeg still did not find the correct graphics adapter.


However, I do have a work-around. I don't particularly like it, but it works.


First : Windows (10) does not understand the concept of a graphics adapter that doesn't have a monitor attached to it. Even though graphics processors (specifically Nvidia) are available without the actual video output and are used in supercomputers and elsewhere to do high speed stream processing, Windows will not let you access the card settings if there is no monitor attached. The Nvidia control center also will not allow you to access any of the card's settings, and you can't set processor affinity.


So I connected a second monitor, and set up the Nvidia card as the primary.


Now ffmpeg -hwaccel cuda works the first time. The command I was using before :


ffmpeg -hide_banner -hwaccel cuda -i "input.avi" -c:a copy -ac 1 -c:v h264_nvenc -preset hq -movflags faststart -qp 30 "output.mp4"



Was failing because it couldn't find the Nvidia adapter. This command now works correctly the first time and uses hardware acceleration for both decode and encode. (The audio portion is irrelevant, if I also re-encode the audio the results are the same.)


With scaling, the command was like this :


ffmpeg -hide_banner -hwaccel cuda -i "input.avi" -c:a copy -ac 1 -c:v h264_nvenc -preset hq -vf "scale=640:480" -movflags faststart -qp 30 "output.mp4"



This works. However :


ffmpeg -hide_banner -hwaccel cuda -i "input.avi" -c:a copy -ac 1 -c:v h264_nvenc -preset hq -vf "scale_cuda=640:480" -movflags faststart -qp 30 "output.mp4



Fails with


Impossible to convert between the formats supported by the filter 'graph 0 input from stream 0:0' and the filter 'auto_scaler_0'
Error reinitializing filters!
Failed to inject frame into filter network: Function not implemented
Error while processing the decoded data for stream #0:0



I was able to get around this, by rearranging things in what seems to be to be an unnecessarily convoluted syntax.


ffmpeg -hide_banner -hwaccel cuvid -hwaccel_output_format cuda -i "input.avi" -c:a aac -b:a 192k -ar 48000 -vf "scale_cuda=856:480" -c:v h264_nvenc -preset hq -movflags faststart -qp 26 "output.mp4"



Having to specify the output format twice seems weird, but Task Manager shows near 100% Video Decode activity, and the time it takes to do this indicates to me that the scale_cuda filter is being used.


I don't particularly like having to use a second monitor (If VirtualDub worked properly I probably wouldn't have to), but I'm willing to live with it. It appears that if you have two different video cards and you want to use hardware acceleration on one of them it has to be the primary.


I haven't tested if Intel QSV is still accessible, nor have I tried switching the order of the graphics adapters back to completely verify the source of the problem, and I'm not really planning to do so (unless some of you think that would be useful). I get the definite impression that few people, if any, have tried to get both an Nvidia and an Intel adapter to provide hardware video acceleration on the same system. I will try to access QSV to see if using both accelerators is an improvement.


I can live with the weird command line to get the cuda filters to work, but if anyone knows a better way to do it I think it would be helpful to post it here for future reference if anyone else runs into a similar problem. None of the examples of using cuda accelerated filters that I've found on any of the many web sites I've read worked exactly as given.


==================


The good news :


It's possible to use both Nvidia and QSV hardware in at least some cases.


This command works :


ffmpeg -hide_banner -hwaccel dxva2 -i "input.avi" -c:a copy ^
 -c:v h264_qsv -vf "crop=1920:1044:0:0" -preset veryfast -profile:v high -level 4.1 -qp 22 "output.mp4"



Task Manager says Nvidia is decoding the input, and GPU-Z says Intel is also active, so it must be doing the encoding.


The bad news : I can't figure out a way to use both a CUDA filter and a standard filter in the same process.


This does not work :


ffmpeg -hide_banner -hwaccel cuvid -hwaccel_output_format cuda -i "input.avi" -c:a aac -b:a 192k -ar 48000 -vf "scale_cuda=856:480,crop=1280:696:0:24" -c:v h264_nvenc -preset hq -movflags faststart -qp 30 "output.mp4"



Reversing the order of scale_cuda and crop (with appropriate adjustments to the numbers) also does not work. There are errors about not being able to transfer the processing stream.


I will try the changes in the latest comment, but I think I may have tried it before and something didn't work. But I will check again.


In my web searches I have not found an example of 'mixed' filters.


I did see "-crop" and "-resize" on the Nvidia ffmpeg trancode web page similar to this :


–crop 0x36x0x0 –resize 1280x696



Once again, I did a cut and paste from the Nvidia web page to my command window and it didn't work. If there is a way to invoke the Nvidia command for these options that has been tested and found to actually work I would really like to see it.


-
Can FFmpeg crop gif image under 1 second ?
5 septembre 2021, par jeongbalmountainI am developing an iOS application about gif.


But I have a problem with gif cropping. Cropping gif spends so many times with FFmpeg.


(updated code)


These are the ffmpeg codes I've tried.


cropped images -> gif


ffmpeg -f image2 -i %d.jpg -vf 'scale=450:-1' output.gif



using concat command (cropped images -> gif)


ffmpeg -f concat -i tmp.txt output.gif



using crop filter


ffmpeg -i in.gif -filter:v "crop=out_w:out_h:x:y" out.gif



These codes are so slow when converting images to gif
or gif to cropped gif.


Is there a way to reduce the time to crop gif less than 1 second ?


(updated2)

ffmpeg -i in.gif -filter:v "crop=out_w:out_h:x:y" out.gif




ffmpeg version 4.4 Copyright (c) 2000-2021 the FFmpeg developers

built with Apple clang version 12.0.5 (clang-1205.0.22.9)

configuration : —prefix=/usr/local/Cellar/ffmpeg/4.4_2 —enable-shared





—enable-pthreads —enable-version3 —cc=clang —host-cflags= —host-ldflags= —enable-ffplay —enable-gnutls —enable-gpl —enable-libaom —enable-libbluray —enable-libdav1d —enable-libmp3lame —enable-libopus —enable-librav1e —enable-librubberband —enable-libsnappy —enable-libsrt —enable-libtesseract —enable-libtheora —enable-libvidstab —enable-libvorbis —enable-libvpx —enable-libwebp —enable-libx264 —enable-libx265 —enable-libxml2 —enable-libxvid —enable-lzma —enable-libfontconfig —enable-libfreetype —enable-frei0r —enable-libass —enable-libopencore-amrnb —enable-libopencore-amrwb —enable-libopenjpeg —enable-libspeex —enable-libsoxr —enable-libzmq —enable-libzimg —disable-libjack —disable-indev=jack —enable-avresample —enable-videotoolbox libavutil 56. 70.100 / 56. 70.100 libavcodec 58.134.100 /
58.134.100 libavformat 58. 76.100 / 58. 76.100 libavdevice 58. 13.100 / 58. 13.100 libavfilter 7.110.100 / 7.110.100 libavresample 4. 0. 0 / 4. 0. 0 libswscale 5. 9.100 /
5. 9.100 libswresample 3. 9.100 / 3. 9.100 libpostproc 55. 9.100 / 55. 9.100 Input #0, gif, from './test.gif' : Duration : 00:00:18.27, start : 0.000000, bitrate : 70098 kb/s Stream #0:0 :
Video : gif, bgra, 1080x1920, 15 fps, 14.99 tbr, 100 tbn, 100 tbc
Stream mapping : Stream #0:0 -> #0:0 (gif (native) -> gif (native))
Press [q] to stop, [?] for help Output #0, gif, to './crop.gif' :

Metadata :
encoder : Lavf58.76.100 Stream #0:0 : Video : gif, bgr8(pc, progressive), 1080x1198, q=2-31, 200 kb/s, 14.99 fps, 100 tbn
Metadata :
encoder : Lavc58.134.100 gif frame= 1 fps=0.0 q=-0.0 size= 0kB time=00:00:00.01 bitrate= 0.0kbits/s speed=5e+03x





frame= 11 fps=0.0 q=-0.0 size= 4096kB time=00:00:00.68
bitrate=49344.8kbits/s speed=1.31x frame= 22 fps= 21 q=-0.0
size= 8192kB time=00:00:01.41 bitrate=47594.9kbits/s speed=1.32x

frame= 32 fps= 20 q=-0.0 size= 12288kB time=00:00:02.08
bitrate=48395.8kbits/s speed=1.32x frame= 43 fps= 20 q=-0.0
size= 16384kB time=00:00:02.81 bitrate=47764.3kbits/s speed=1.33x

frame= 54 fps= 20 q=-0.0 size= 20992kB time=00:00:03.55
bitrate=48441.3kbits/s speed=1.33x frame= 65 fps= 20 q=-0.0
size= 24832kB time=00:00:04.28 bitrate=47528.9kbits/s speed=1.35x

frame= 77 fps= 21 q=-0.0 size= 28928kB time=00:00:05.08
bitrate=46649.2kbits/s speed=1.36x frame= 87 fps= 21 q=-0.0
size= 32768kB time=00:00:05.75 bitrate=46684.4kbits/s speed=1.36x

frame= 98 fps= 21 q=-0.0 size= 36608kB time=00:00:06.48
bitrate=46279.7kbits/s speed=1.36x frame= 109 fps= 21 q=-0.0
size= 40704kB time=00:00:07.22 bitrate=46183.8kbits/s speed=1.37x

frame= 120 fps= 21 q=-0.0 size= 44800kB time=00:00:07.95
bitrate=46163.7kbits/s speed=1.37x frame= 131 fps= 21 q=-0.0
size= 49152kB time=00:00:08.69 bitrate=46335.2kbits/s speed=1.38x

frame= 142 fps= 21 q=-0.0 size= 53504kB time=00:00:09.42
bitrate=46529.2kbits/s speed=1.37x frame= 153 fps= 21 q=-0.0
size= 57344kB time=00:00:10.15 bitrate=46282.0kbits/s speed=1.38x

frame= 164 fps= 21 q=-0.0 size= 61184kB time=00:00:10.89
bitrate=46025.6kbits/s speed=1.38x frame= 174 fps= 21 q=-0.0
size= 65280kB time=00:00:11.55 bitrate=46300.8kbits/s speed=1.37x

frame= 185 fps= 21 q=-0.0 size= 69376kB time=00:00:12.29
bitrate=46243.1kbits/s speed=1.38x frame= 196 fps= 21 q=-0.0
size= 72960kB time=00:00:13.02 bitrate=45905.4kbits/s speed=1.38x

frame= 207 fps= 21 q=-0.0 size= 76544kB time=00:00:13.76
bitrate=45570.4kbits/s speed=1.38x frame= 218 fps= 21 q=-0.0
size= 80640kB time=00:00:14.49 bitrate=45590.3kbits/s speed=1.38x

frame= 229 fps= 21 q=-0.0 size= 84224kB time=00:00:15.23
bitrate=45302.9kbits/s speed=1.39x frame= 240 fps= 21 q=-0.0
size= 88064kB time=00:00:15.96 bitrate=45201.8kbits/s speed=1.39x

frame= 250 fps= 21 q=-0.0 size= 91648kB time=00:00:16.63
bitrate=45146.1kbits/s speed=1.39x frame= 261 fps= 21 q=-0.0
size= 96000kB time=00:00:17.36 bitrate=45301.4kbits/s speed=1.38x

frame= 271 fps= 21 q=-0.0 size= 99840kB time=00:00:18.03
bitrate=45362.7kbits/s speed=1.38x frame= 274 fps= 21 q=-0.0
Lsize= 101552kB time=00:00:18.23 bitrate=45634.2kbits/s speed=1.37x

video:101552kB audio:0kB subtitle:0kB other streams:0kB global
headers:0kB muxing overhead : 0.000019%



it takes 12 seconds