
Recherche avancée
Autres articles (69)
-
Le profil des utilisateurs
12 avril 2011, parChaque utilisateur dispose d’une page de profil lui permettant de modifier ses informations personnelle. Dans le menu de haut de page par défaut, un élément de menu est automatiquement créé à l’initialisation de MediaSPIP, visible uniquement si le visiteur est identifié sur le site.
L’utilisateur a accès à la modification de profil depuis sa page auteur, un lien dans la navigation "Modifier votre profil" est (...) -
Configurer la prise en compte des langues
15 novembre 2010, parAccéder à la configuration et ajouter des langues prises en compte
Afin de configurer la prise en compte de nouvelles langues, il est nécessaire de se rendre dans la partie "Administrer" du site.
De là, dans le menu de navigation, vous pouvez accéder à une partie "Gestion des langues" permettant d’activer la prise en compte de nouvelles langues.
Chaque nouvelle langue ajoutée reste désactivable tant qu’aucun objet n’est créé dans cette langue. Dans ce cas, elle devient grisée dans la configuration et (...) -
La sauvegarde automatique de canaux SPIP
1er avril 2010, parDans le cadre de la mise en place d’une plateforme ouverte, il est important pour les hébergeurs de pouvoir disposer de sauvegardes assez régulières pour parer à tout problème éventuel.
Pour réaliser cette tâche on se base sur deux plugins SPIP : Saveauto qui permet une sauvegarde régulière de la base de donnée sous la forme d’un dump mysql (utilisable dans phpmyadmin) mes_fichiers_2 qui permet de réaliser une archive au format zip des données importantes du site (les documents, les éléments (...)
Sur d’autres sites (5849)
-
av::av_encode_video produces blurred video from crisp files
9 janvier 2023, par AbdirizakI am using the
av::av_encode_video()
function to produce a .mp4 video from png files, as in this answer. I pay special attention for the png files to be perfectly crisp, i.e. I plot matrices to png with exactly the same dimensions, so that every matrix cell maps to one cell in the png. Here is code to illustrate what I mean :

library(av)

n.times <- 24*10
n.row <- 50
n.col <- 26

out.dir <- "/Users/Abdirizak/Documents/some/directory/"

for (i in 1:n.times) {
 
 current.mat <- matrix(data = rnorm(n.row*n.col), nrow = n.row, ncol = n.col)
 
 setwd(out.dir)
 png(filename = paste0(i, ".png"), width = n.row, height = n.col)
 
 par(mar = rep(0,4))
 image(current.mat)
 
 dev.off()
 
}

setwd(out.dir)
png.files <- paste0(out.dir, list.files(pattern = ".png$"))

av::av_encode_video(input = png.files, output = "000.mp4", framerate = 24)



Now, even though my input .png files are perfectly crisp, the output .mp4 video is blurry. How can I prevent that from happening ? I.e. how can I get a perfectly crisp video ? (I am aware that this will likely inflate the file size of the .mp4 file)


I already digged a bit into the
vfilter
argument ofav_encode_video()
and the underlying ffmpeg filter graphs on here, but could not yet really get the hang on it.

I am looking at the .mp4 file through QuickTime Player on MacOS Ventura 13.0.1, and using R version 4.2.2 through RStudio 2022.12.0.353


Edit 9.1.2023 :


To further clarify, here is an example screenshot of a png image (not the original png file because that one appears too small here) :




As I said, a perfectly crisp image.


On the other hand, a screenshot of the .mp4 movie looks like this :




Somewhat unsatisfactory. Any suggestions are welcome.


-
ffmpeg doesn't sometimes start reading RTSP stream from IP camera without error
8 décembre 2022, par Petr DubI've an IP camera, which provide RTSP stream. I want to read this stream, rotate it 90° and provide data for displaying video via IIS server. I have a working solution via ffmpeg, but it is not reliable. It ends after several minutes without error and it is not starting sometimes.


I use this command :

ffmpeg.exe -thread_queue_size 128 -i "rtsp://<login>:<pwd>@192.168.0.201:554/live/ch0" -vf "transpose=1" -y -c:a aac -b:a 160000 -ac 1 -s 432x768 -g 50 -hls_time 2 -hls_list_size 1 -start_number 1 -hls_flags delete_segments m:\playlist.m3u8</pwd></login>


It works, but after several minutes (40 to 100) it stops without error (I have no idea why). When I restart the same ffmeg command, it sometimes doesn’t start reading the stream, but it doesn’t produce any error, the ffmpeg process is still running. Error output from ffmeg shows :


ffmpeg version 2022-11-03-git-5ccd4d3060-full_build-www.gyan.dev Copyright (c) 2000-2022 the FFmpeg developers
 built with gcc 12.1.0 (Rev2, 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-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libaribb24 --enable-libdav1d --enable-libdavs2 --enable-libuavs3d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libaom --enable-libjxl --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-liblensfun --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libvpl --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --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 57. 40.100 / 57. 40.100
 libavcodec 59. 51.101 / 59. 51.101
 libavformat 59. 34.101 / 59. 34.101
 libavdevice 59. 8.101 / 59. 8.101
 libavfilter 8. 49.101 / 8. 49.101
 libswscale 6. 8.112 / 6. 8.112
 libswresample 4. 9.100 / 4. 9.100
 libpostproc 56. 7.100 / 56. 7.100



The next row should be :


Input #0, rtsp, from 'rtsp://<login>:<pwd>@192.168.0.201:554/live/ch0'</pwd></login>


Any ideas, what should I do ? At least to force ffmpeg end with error and not stays “running”…


Edit : I finally wrote a windows service, which starts the ffmpeg and monitors its error output. When nothing comes to this output for several seconds, it kills the ffmpeg process and starts a new one.


-
How to overlay sequence of frames on video using ffmpeg-python ?
19 novembre 2022, par Yogesh YadavI tried below but it is only showing the background video.


background_video = ffmpeg.input( "input.mp4")
overlay_video = ffmpeg.input(f'{frames_folder}*.png', pattern_type='glob', framerate=25)
subprocess = ffmpeg.overlay(
 background_video,
 overlay_video,
 ).filter("setsar", sar=1)



I also tried to assemble sequence of frames into .webm/.mov video but transparency is lost. video is taking black as background.


P.s - frame size is same as background video size. So no scaling needed.


Edit


I tried @Rotem suggestions




Try using single PNG image first




overlay_video = ffmpeg.input('test-frame.png')



It's not working for frames generated by OpenCV but working for any other png image. This is weird, when I'm manually viewing these frames folder it's showing blank images(Link to my frames folder).
But If I convert these frames into the video(see below) it is showing correctly what I draw on each frame.


output_options = {
 'crf': 20,
 'preset': 'slower',
 'movflags': 'faststart',
 'pix_fmt': 'yuv420p'
 }
ffmpeg.input(f'{frames_folder}*.png', pattern_type='glob', framerate=25 , reinit_filter=0).output(
 'movie.avi',
 **output_options
 ).global_args('-report').run()





try creating a video from all the PNG images without overlay




It's working as expected only issue is transparency. Is there is way to create a transparent background video ? I tried .webm/.mov/.avi but no luck.




Add .global_args('-report') and check the log file




Report written to "ffmpeg-20221119-110731.log"
Log level: 48
ffmpeg version 5.1 Copyright (c) 2000-2022 the FFmpeg developers
 built with Apple clang version 13.1.6 (clang-1316.0.21.2.5)
 configuration: --prefix=/opt/homebrew/Cellar/ffmpeg/5.1 --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-librist --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvmaf --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-videotoolbox --enable-neon
 libavutil 57. 28.100 / 57. 28.100
 libavcodec 59. 37.100 / 59. 37.100
 libavformat 59. 27.100 / 59. 27.100
 libavdevice 59. 7.100 / 59. 7.100
 libavfilter 8. 44.100 / 8. 44.100
 libswscale 6. 7.100 / 6. 7.100
 libswresample 4. 7.100 / 4. 7.100
 libpostproc 56. 6.100 / 56. 6.100
Input #0, image2, from './frames/*.png':
 Duration: 00:00:05.00, start: 0.000000, bitrate: N/A
 Stream #0:0: Video: png, rgba(pc), 1920x1080, 25 fps, 25 tbr, 25 tbn
Codec AVOption crf (Select the quality for constant quality mode) specified for output file #0 (movie.avi) 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 preset (Configuration preset) specified for output file #0 (movie.avi) 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 (png (native) -> mpeg4 (native))
Press [q] to stop, [?] for help
Output #0, avi, to 'movie.avi':
 Metadata:
 ISFT : Lavf59.27.100
 Stream #0:0: Video: mpeg4 (FMP4 / 0x34504D46), yuv420p(tv, progressive), 1920x1080, q=2-31, 200 kb/s, 25 fps, 25 tbn
 Metadata:
 encoder : Lavc59.37.100 mpeg4
 Side data:
 cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: N/A
frame= 125 fps= 85 q=31.0 Lsize= 491kB time=00:00:05.00 bitrate= 804.3kbits/s speed=3.39x 
video:482kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.772174%



To draw frame I used below.


for i in range(num_frames):
 transparent_img = np.zeros((height, width, 4), dtype=np.uint8)
 cv2.line(transparent_img, (x1,y1), (x2,y2) ,(255, 255, 255), thickness=1, lineType=cv2.LINE_AA)
 self.frames.append(transparent_img)


## To Save each frame of the video in the given folder
for i, f in enumerate(frames):
 cv2.imwrite("{}/{:0{n}d}.png".format(path_to_frames, i, n=num_digits), f)