
Recherche avancée
Médias (3)
-
MediaSPIP Simple : futur thème graphique par défaut ?
26 septembre 2013, par
Mis à jour : Octobre 2013
Langue : français
Type : Video
-
GetID3 - Bloc informations de fichiers
9 avril 2013, par
Mis à jour : Mai 2013
Langue : français
Type : Image
-
GetID3 - Boutons supplémentaires
9 avril 2013, par
Mis à jour : Avril 2013
Langue : français
Type : Image
Autres articles (2)
-
Selection of projects using MediaSPIP
2 mai 2011, parThe examples below are representative elements of MediaSPIP specific uses for specific projects.
MediaSPIP farm @ Infini
The non profit organizationInfini develops hospitality activities, internet access point, training, realizing innovative projects in the field of information and communication technologies and Communication, and hosting of websites. It plays a unique and prominent role in the Brest (France) area, at the national level, among the half-dozen such association. Its members (...) -
Sélection de projets utilisant MediaSPIP
29 avril 2011, parLes exemples cités ci-dessous sont des éléments représentatifs d’usages spécifiques de MediaSPIP pour certains projets.
Vous pensez avoir un site "remarquable" réalisé avec MediaSPIP ? Faites le nous savoir ici.
Ferme MediaSPIP @ Infini
L’Association Infini développe des activités d’accueil, de point d’accès internet, de formation, de conduite de projets innovants dans le domaine des Technologies de l’Information et de la Communication, et l’hébergement de sites. Elle joue en la matière un rôle unique (...)
Sur d’autres sites (2305)
-
Python cv2 script that scans a giant image to a video. Raises error : Unknown C++ exception from OpenCV code
26 avril 2022, par NolreneaI wrote a script that scans a giant image to make a video. Normally I just post my scripts straight to my Code Review account, but this script is ugly, needs to be refactored, implements only horizontal scrolling and contains a bug that I can't get rid of.


It is working but not perfect, I can't get the last line at the bottom of the image, with height of
image_height % 1080
. If I ignore it, the code is working fine, if I try to fix it, it throws exceptions.

Example :


Original image (Google Drive)


Video Output (Google Drive)


As you can see from the video, everything is working properly except the fact that I can't get the bottom line.


Full working code



import cv2
import numpy as np
import random
import rpack
from fractions import Fraction
from math import prod

def resize_guide(image_size, target_area):
 aspect_ratio = Fraction(*image_size).limit_denominator()
 horizontal = aspect_ratio.numerator
 vertical = aspect_ratio.denominator
 unit_length = (target_area/(horizontal*vertical))**.5
 return (int(horizontal*unit_length), int(vertical*unit_length))

fourcc = cv2.VideoWriter_fourcc(*'h264')
FRAME = np.zeros((1080, 1920, 3), dtype=np.uint8)

def new_frame():
 return np.ndarray.copy(FRAME)

def center(image):
 frame = new_frame()
 h, w = image.shape[:2]
 yoff = round((1080-h)/2)
 xoff = round((1920-w)/2)
 frame[yoff:yoff+h, xoff:xoff+w] = image
 return frame

def image_scanning(file, fps=60, pan_increment=64, horizontal_increment=8, fast_decrement=256):
 image = cv2.imread(file)
 height, width = image.shape[:2]
 assert width*height >= 1920*1080
 video_writer = cv2.VideoWriter(file+'.mp4', fourcc, fps, (1920, 1080))
 fit_height = True
 if height < 1080:
 width = width*1080/height
 image = cv2.resize(image, (width, 1080), interpolation = cv2.INTER_AREA)
 aspect_ratio = width / height
 zooming_needed = False
 if 4/9 <= aspect_ratio <= 16/9:
 new_width = round(width*1080/height)
 fit = cv2.resize(image, (new_width, 1080), interpolation = cv2.INTER_AREA)
 zooming_needed = True
 
 elif 16/9 < aspect_ratio <= 32/9:
 new_height = round(height*1920/width)
 fit = cv2.resize(image, (1920, new_height), interpolation = cv2.INTER_AREA)
 fit_height = False
 zooming_needed = True
 
 centered = center(fit)
 for i in range(fps):
 video_writer.write(centered)
 if fit_height:
 xoff = round((1920 - new_width)/2)
 while xoff:
 if xoff - pan_increment >= 0:
 xoff -= pan_increment
 else:
 xoff = 0
 frame = new_frame()
 frame[0:1080, xoff:xoff+new_width] = fit
 video_writer.write(frame)
 else:
 yoff = round((1080 - new_height)/2)
 while yoff:
 if yoff - pan_increment >= 0:
 yoff -= pan_increment
 else:
 yoff = 0
 frame = new_frame()
 frame[yoff:yoff+new_height, 0:1920] = fit
 video_writer.write(frame)
 
 if zooming_needed:
 if fit_height:
 width_1, height_1 = new_width, 1080
 else:
 width_1, height_1 = 1920, new_height
 new_area = width_1 * height_1
 original_area = width * height
 area_diff = original_area - new_area
 unit_diff = area_diff / fps
 for i in range(1, fps+1):
 zoomed = cv2.resize(image, resize_guide((width_1, height_1), new_area+unit_diff*i), interpolation=cv2.INTER_AREA)
 zheight, zwidth = zoomed.shape[:2]
 zheight = min(zheight, 1080)
 zwidth = min(zwidth, 1920)
 frame = new_frame()
 frame[0:zheight, 0:zwidth] = zoomed[0:zheight, 0:zwidth]
 video_writer.write(frame)
 y, x = 0, 0
 completed = False
 while y != height - 1080:
 x = 0
 while x != width - 1920:
 if x + horizontal_increment + 1920 <= width:
 x += horizontal_increment
 frame = image[y:y+1080, x:x+1920]
 video_writer.write(frame)
 else:
 x = width - 1920
 frame = image[y:y+1080, x:x+1920]
 for i in range(round(fps/3)):
 video_writer.write(frame)
 if y == height - 1080:
 completed = True
 while x != 0:
 if x - fast_decrement - 1920 >= 0:
 x -= fast_decrement
 else:
 x = 0
 frame = image[y:y+1080, x:x+1920]
 video_writer.write(frame)
 if y + 2160 <= height:
 y += 1080
 else:
 y = height - 1080
 cv2.destroyAllWindows()
 video_writer.release()
 del video_writer



The above the the code needed to produce the example video. It is working but the bottom line is missing.


Now if I change the last few lines to this :


if y + 2160 <= height:
 y += 1080
 else:
 y = height - 1080
 x = 0
 while x != width - 1920:
 if x + horizontal_increment + 1920 <= width:
 x += horizontal_increment
 frame = image[y:y+1080, x:x+1920]
 video_writer.write(frame)
 cv2.destroyAllWindows()
 video_writer.release()
 del video_writer



I expect it to include the bottom line, but it just throws exceptions instead :


OpenCV: FFMPEG: tag 0x34363268/'h264' is not supported with codec id 27 and format 'mp4 / MP4 (MPEG-4 Part 14)'
OpenCV: FFMPEG: fallback to use tag 0x31637661/'avc1'
---------------------------------------------------------------------------
error Traceback (most recent call last)
 in <module>
----> 1 image_scanning("D:/collages/91f53ebcea2a.png")

 in image_scanning(file, fps, pan_increment, horizontal_increment, fast_decrement)
 122 x += horizontal_increment
 123 frame = image[y:y+1080, x:x+1920]
--> 124 video_writer.write(frame)
 125 cv2.destroyAllWindows()
 126 video_writer.release()

error: Unknown C++ exception from OpenCV code
</module>


(If you can't get the example code working I can't help you, but I am using Python 3.9.10 x64 on Windows 10, and I have this file : "C :\Windows\System32\openh264-1.8.0-win64.dll", the '.avi' format generates video files with Gibibytes (binary unit, not SI Gigabyte) of size)


How to get rid of the exception ?


-
docker service create : How to deal with custom or unknown parameter needed by linuxserver/ffmpeg image ?
24 mai 2022, par MikeI am new to docker and docker swarm and started dockerizing several services and am trying to get them running as docker swarm services. I ran into a road block with the linuxserver/ffmpeg image :


- 

- it uses a —device parameter which is not implemented in create service
- it expects several custom parameters to pass them to the ffmpeg encoder






From my research up to now I assume that passing parameters is not implemented in docker create service, but maybe you can think of a workaround ? (unfortunately the image does not process environment variables, or at least they are not documented)


This is how I start dockerized ffmpeg (working fine in standalone mode) :


docker run -d /

—network="host" /

—device=/dev/video0 :/dev/video0 / ### error : unknow flag

—name ffmpeg_streamer /

—restart always -it /

-v $(pwd)/video :/video /

linuxserver/ffmpeg / ### custom parameters below here

-stream_loop /

-1 -re -nostdin /

-i "/video/test.avi" /

-f pulse /

-vcodec libx264 /

-preset:v veryfast /

-b:v 400k /

-f flv rtmp ://localhost:1935/live/streamkey

Many thanks for looking into this !


-
ffmpeg -vcodec is not working , unknown encoder [closed]
24 mai 2022, par Younghwan Kimi want to use ffmpeg to encode ,
but i guess it's not working '-vcodec' option,


command :


ffmpeg -i test.mp4 -vcodec videocodec -acodec audiocodec test.flv 2>&1



output :


libswresample 4. 3.100 / 4. 3.100
 libpostproc 56. 3.100 / 56. 3.100
 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'test.mp4':
 Metadata:
 major_brand : isom
 minor_version : 512
 compatible_brands: isomiso2avc1mp41
 encoder : Lavf58.45.100
 Duration: 00:02:34.40, start: 0.000000, bitrate: 934 kb/s
 Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 
 1916x1032 [SAR 1:1 DAR 479:258], 921 kb/s, 30 fps, 30 tbr, 15360 tbn (default)
 Metadata:
 handler_name : VideoHandler
 vendor_id : [0][0][0][0]
 Stream #0:1[0x2](eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 4 kb/s 
 (default)
 Metadata:
 handler_name : AAC Audio Track
 vendor_id : [0][0][0][0]
 **Unknown encoder 'videocodec'**



how can i figure it out ?