
Recherche avancée
Médias (1)
-
Rennes Emotion Map 2010-11
19 octobre 2011, par
Mis à jour : Juillet 2013
Langue : français
Type : Texte
Autres articles (73)
-
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 (...) -
XMP PHP
13 mai 2011, parDixit Wikipedia, XMP signifie :
Extensible Metadata Platform ou XMP est un format de métadonnées basé sur XML utilisé dans les applications PDF, de photographie et de graphisme. Il a été lancé par Adobe Systems en avril 2001 en étant intégré à la version 5.0 d’Adobe Acrobat.
Étant basé sur XML, il gère un ensemble de tags dynamiques pour l’utilisation dans le cadre du Web sémantique.
XMP permet d’enregistrer sous forme d’un document XML des informations relatives à un fichier : titre, auteur, historique (...) -
Les tâches Cron régulières de la ferme
1er décembre 2010, parLa gestion de la ferme passe par l’exécution à intervalle régulier de plusieurs tâches répétitives dites Cron.
Le super Cron (gestion_mutu_super_cron)
Cette tâche, planifiée chaque minute, a pour simple effet d’appeler le Cron de l’ensemble des instances de la mutualisation régulièrement. Couplée avec un Cron système sur le site central de la mutualisation, cela permet de simplement générer des visites régulières sur les différents sites et éviter que les tâches des sites peu visités soient trop (...)
Sur d’autres sites (7835)
-
FFMPEG split video with equal frames in the splits....?
17 janvier 2017, par Gurinderbeer SinghI am using FFMPEG to split a video file by using the following command :
ffmpeg -i input.mp4 -c copy -segment_times 600,600 -f segment out%d.mp4
This command divides video based on time.. But even if output splits are of same duration, number of frames are different in the splits..
Is there a way of splitting a video file without recoding so that number of frames are equal in splitted files.?
Even if it use some other tool than FFMPEG.
For example : input.mp4 of duration 200 seconds has 5000 frames.
Can we split this into :
input1.mp4 having 2500 frames
and input2.mp4 having 2500 frames.It doesn’t matter if duration of output splits is different..
Please help.....!
-
Frames took with ELP camera has unknown pixel format at FHD ?
11 novembre 2024, par Marcel KoperaI'm trying to take a one frame ever x seconds from my usb camera. Name of the camera is : ELP-USBFHD06H-SFV(5-50).
Code is not 100% done yet, but I'm using it this way right now ↓ (
shot
fn is called frommain.py
in a loop)


import cv2
import subprocess

from time import sleep
from collections import namedtuple

from errors import *

class Camera:
 def __init__(self, cam_index, res_width, res_height, pic_format, day_time_exposure_ms, night_time_exposure_ms):
 Resolution = namedtuple("resolution", ["width", "height"])
 self.manual_mode(True)

 self.cam_index = cam_index
 self.camera_resolution = Resolution(res_width, res_height)
 self.picture_format = pic_format
 self.day_time_exposure_ms = day_time_exposure_ms
 self.night_time_exposure_ms = night_time_exposure_ms

 self.started: bool = False
 self.night_mode = False

 self.cap = cv2.VideoCapture(self.cam_index, cv2.CAP_V4L2)
 self.cap.set(cv2.CAP_PROP_FRAME_WIDTH, self.camera_resolution.width)
 self.cap.set(cv2.CAP_PROP_FRAME_HEIGHT, self.camera_resolution.height)
 self.cap.set(cv2.CAP_PROP_FOURCC, cv2.VideoWriter_fourcc(*self.picture_format))

 

 def start(self):
 sleep(1)
 if not self.cap.isOpened():
 return CameraCupError()

 self.set_exposure_time(self.day_time_exposure_ms)
 self.set_brightness(0)
 sleep(0.1)
 
 self.started = True



 def shot(self, picture_name, is_night):
 if not self.started:
 return InitializationError()

 self.configure_mode(is_night)

 # Clear buffer
 for _ in range(5):
 ret, _ = self.cap.read()

 ret, frame = self.cap.read()

 sleep(0.1)

 if ret:
 print(picture_name)
 cv2.imwrite(picture_name, frame)
 return True

 else:
 print("No photo")
 return False


 
 def release(self):
 self.set_exposure_time(156)
 self.set_brightness(0)
 self.manual_mode(False)
 self.cap.release()



 def manual_mode(self, switch: bool):
 if switch:
 subprocess.run(["v4l2-ctl", "--set-ctrl=auto_exposure=1"])
 else:
 subprocess.run(["v4l2-ctl", "--set-ctrl=auto_exposure=3"])
 sleep(1)

 
 
 def configure_mode(self, is_night):
 if is_night == self.night_mode:
 return

 if is_night:
 self.night_mode = is_night
 self.set_exposure_time(self.night_time_exposure_ms)
 self.set_brightness(64)
 else:
 self.night_mode = is_night
 self.set_exposure_time(self.day_time_exposure_ms)
 self.set_brightness(0)
 sleep(0.1)



 def set_exposure_time(self, ms: int):
 ms = int(ms)
 default_val = 156

 if ms < 1 or ms > 5000:
 ms = default_val

 self.cap.set(cv2.CAP_PROP_EXPOSURE, ms)



 def set_brightness(self, value: int):
 value = int(value)
 default_val = 0

 if value < -64 or value > 64:
 value = default_val

 self.cap.set(cv2.CAP_PROP_BRIGHTNESS, value)



Here are settings for the camera (yaml file)


camera:
 camera_index: 0
 res_width: 1920
 res_height: 1080
 picture_format: "MJPG"
 day_time_exposure_ms: 5
 night_time_exposure_ms: 5000
 photos_format: "jpg"




I do some configs like set manual mode for the camera, change exposure/brightness and saving frame.
Also the camera is probably catching the frames to the buffer (it is not saving latest frame in real time : it's more laggish), so I have to clear buffer every time. like this


# Clear buffer from old frames
 for _ in range(5):
 ret, _ = self.cap.read()
 
 # Get a new frame
 ret, frame = self.cap.read()



What I really don't like, but I could find a better way (tldr : setting buffer for 1 frame doesn't work on my camera).


Frames saved this method looks good with 1920x1080 resolution. BUT when I try to run
ffmpeg
command to make a timelapse from savedjpg
file like this

ffmpeg -framerate 20 -pattern_type glob -i "*.jpg" -c:v libx264 output.mp4



I got an error like this one


[image2 @ 0x555609c45240] Could not open file : 08:59:20.jpg
[image2 @ 0x555609c45240] Could not find codec parameters for stream 0 (Video: mjpeg, none(bt470bg/unknown/unknown)): unspecified size
Consider increasing the value for the 'analyzeduration' (0) and 'probesize' (5000000) options
Input #0, image2, from '*.jpg':
 Duration: 00:00:00.05, start: 0.000000, bitrate: N/A
 Stream #0:0: Video: mjpeg, none(bt470bg/unknown/unknown), 20 fps, 20 tbr, 20 tbn
Output #0, mp4, to 'output.mp4':
Output file #0 does not contain any stream



Also when I try to copy the files from Linux to Windows I get some weird copy failing error and option to skip the picture. But even when I press the skip button, the picture is copied and can be opened. I'm not sure what is wrong with the format, but the camera is supporting MPEG at 1920x1080.


>>> v4l2-ctl --all

Driver Info:
 Driver name : uvcvideo
 Card type : H264 USB Camera: USB Camera
 Bus info : usb-xhci-hcd.1-1
 Driver version : 6.6.51
 Capabilities : 0x84a00001
 Video Capture
 Metadata Capture
 Streaming
 Extended Pix Format
 Device Capabilities
 Device Caps : 0x04200001
 Video Capture
 Streaming
 Extended Pix Format
Media Driver Info:
 Driver name : uvcvideo
 Model : H264 USB Camera: USB Camera
 Serial : 2020032801
 Bus info : usb-xhci-hcd.1-1
 Media version : 6.6.51
 Hardware revision: 0x00000100 (256)
 Driver version : 6.6.51
Interface Info:
 ID : 0x03000002
 Type : V4L Video
Entity Info:
 ID : 0x00000001 (1)
 Name : H264 USB Camera: USB Camera
 Function : V4L2 I/O
 Flags : default
 Pad 0x0100000d : 0: Sink
 Link 0x0200001a: from remote pad 0x1000010 of entity 'Extension 4' (Video Pixel Formatter): Data, Enabled, Immutable
Priority: 2
Video input : 0 (Camera 1: ok)
Format Video Capture:
 Width/Height : 1920/1080
 Pixel Format : 'MJPG' (Motion-JPEG)
 Field : None
 Bytes per Line : 0
 Size Image : 4147789
 Colorspace : sRGB
 Transfer Function : Default (maps to sRGB)
 YCbCr/HSV Encoding: Default (maps to ITU-R 601)
 Quantization : Default (maps to Full Range)
 Flags :
Crop Capability Video Capture:
 Bounds : Left 0, Top 0, Width 1920, Height 1080
 Default : Left 0, Top 0, Width 1920, Height 1080
 Pixel Aspect: 1/1
Selection Video Capture: crop_default, Left 0, Top 0, Width 1920, Height 1080, Flags:
Selection Video Capture: crop_bounds, Left 0, Top 0, Width 1920, Height 1080, Flags:
Streaming Parameters Video Capture:
 Capabilities : timeperframe
 Frames per second: 15.000 (15/1)
 Read buffers : 0

User Controls

 brightness 0x00980900 (int) : min=-64 max=64 step=1 default=0 value=64
 contrast 0x00980901 (int) : min=0 max=64 step=1 default=32 value=32
 saturation 0x00980902 (int) : min=0 max=128 step=1 default=56 value=56
 hue 0x00980903 (int) : min=-40 max=40 step=1 default=0 value=0
 white_balance_automatic 0x0098090c (bool) : default=1 value=1
 gamma 0x00980910 (int) : min=72 max=500 step=1 default=100 value=100
 gain 0x00980913 (int) : min=0 max=100 step=1 default=0 value=0
 power_line_frequency 0x00980918 (menu) : min=0 max=2 default=1 value=1 (50 Hz)
 0: Disabled
 1: 50 Hz
 2: 60 Hz
 white_balance_temperature 0x0098091a (int) : min=2800 max=6500 step=1 default=4600 value=4600 flags=inactive
 sharpness 0x0098091b (int) : min=0 max=6 step=1 default=3 value=3
 backlight_compensation 0x0098091c (int) : min=0 max=2 step=1 default=1 value=1

Camera Controls

 auto_exposure 0x009a0901 (menu) : min=0 max=3 default=3 value=1 (Manual Mode)
 1: Manual Mode
 3: Aperture Priority Mode
 exposure_time_absolute 0x009a0902 (int) : min=1 max=5000 step=1 default=156 value=5000
 exposure_dynamic_framerate 0x009a0903 (bool) : default=0 value=0



I also tried to save the picture using
ffmpeg
in a case something is not right withopencv
like this :

ffmpeg -f v4l2 -framerate 30 -video_size 1920x1080 -i /dev/video0 -c:v libx264 -preset fast -crf 23 -t 00:01:00 output.mp4




It is saving the picture but also changing its format


[video4linux2,v4l2 @ 0x555659ed92b0] The V4L2 driver changed the video from 1920x1080 to 800x600
[video4linux2,v4l2 @ 0x555659ed92b0] The driver changed the time per frame from 1/30 to 1/15



But the format looks right when set it back to FHD using
v4l2



>>> v4l2-ctl --device=/dev/video0 --set-fmt-video=width=1920,height=1080,pixelformat=MJPG
>>> v4l2-ctl --get-fmt-video

Format Video Capture:
 Width/Height : 1920/1080
 Pixel Format : 'MJPG' (Motion-JPEG)
 Field : None
 Bytes per Line : 0
 Size Image : 4147789
 Colorspace : sRGB
 Transfer Function : Default (maps to sRGB)
 YCbCr/HSV Encoding: Default (maps to ITU-R 601)
 Quantization : Default (maps to Full Range)
 Flags :



I'm not sure what could be wrong with the format/camera and I don't think I have enough information to figure it out.


I tried to use
ffmpeg
instead ofopencv
and also change a few settings inopencv's cup
config.

-
ffmpeg change audio encoding and combine audio files
7 septembre 2024, par SimonI asked a question about combining linear16 encoded audio files together here - Combine linear16 encoded audio files | PHP


I was suggested to use ffmpeg, I'm new with it, any suggestion how to combine LINEAR16 encoded audio files ?


...
$client = new TextToSpeechClient();
$synthesisInputText = new SynthesisInput();
$audioConfig = new AudioConfig();
// $audioConfig->setAudioEncoding(AudioEncoding::MP3); works fine
$audioConfig->setAudioEncoding(AudioEncoding::LINEAR16);
$voice = new VoiceSelectionParams();

$voice->setLanguageCode('en-US');
$voice->setName('en-US-Neural2-A');

$media_total = '';
foreach($txt_array as $k => $txt) {

 $synthesisInputText->setText($txt);
 $response = $client->synthesizeSpeech($synthesisInputText, $voice, $audioConfig);
 $media = $response->getAudioContent();

 $media_total .= $media; // audio is encoded linear16, and combining in this way does not work
 
// how to use ffmpeg here, to combine $media pieces, change encoding

}



Thanks


UPDATE


Examples of generated audio files, stored in mp3 file :
https://storage.googleapis.com/gspeech-audio-storage/gspeech_en-US:6:D:1:0_5c021edd23218122a7ce116cb297bc91_5be04f8b55b1b28025ad6eea55109e83.mp3


The audio looks like this. Seems like when making encoding as linear16, the output like the WAV format :


5249 4646 240b 0400 5741 5645 666d 7420
1000 0000 0100 0100 c05d 0000 80bb 0000
0200 1000 6461 7461 000b 0400 ffff f2ff
d6ff bcff b7ff c9ff f5ff 2900 5800 7b00
8800 8b00 8c00 8d00 9000 9400 9100 8800
7a00 6600 5400 4500 3e00 3b00 3600 3200
2800 1b00 1000 0a00 0700 0200 f8ff f5ff
f3ff f8ff ffff 0400 0300 0e00 1b00 0c00
0800 0500 1000 1500 1e00 2800 2b00 2e00
2b00 2d00 2900 3000 3300 3200 2f00 2600
1800 0b00 0200 feff f6ff f7ff f5ff f3ff
f1ff edff eaff e6ff e1ff d5ff d0ff caff
c5ff c3ff c2ff c1ff cbff ccff cbff d0ff
d9ff d7ff ddff ddff e0ff e5ff e2ff f2ff
f4ff fdff 0200 0100 0600 0a00 1000 0e00
1300 0f00 0f00 1c00 1a00 2000 2400 2500
2500 2000 1d00 1800 1300 0f00 1200 0500
fdff f1ff ecff ddff d3ff cdff b7ff c1ff
c0ff b8ff b4ff b2ff aaff a8ff a5ff abff
a6ff a0ff 9bff 91ff 8fff 8aff 86ff 83ff
84ff 8aff 83ff 78ff 70ff 65ff 66ff 6eff
71ff 70ff 6fff 69ff 5aff 54ff 4fff 5bff
5eff 64ff 6eff 68ff 68ff 6aff 6aff 65ff
71ff 63ff 5aff 54ff 4aff 4eff 56ff 58ff
66ff 6bff 66ff 66ff 70ff 75ff 6bff 7bff
71ff 76ff 8bff 98ff 8eff 95ff 9fff 92ff
93ff 98ff a2ff afff bdff baff b5ff bdff
b6ff c1ff c0ff c9ff d9ff dfff e7ff f5ff
f8ff ffff 1000 1200 1200 0a00 0a00 1100
f7ff 0900 0a00 0300 1300 0e00 1300 1900
1e00 2600 0400 1700 2000 2600 3200 2f00
2b00 1c00 2500 1d00 2800 2f00 3200 3d00
2b00 3c00 3100 4300 4900 4300 5c00 6c00
6a00 5f00 5e00 4d00 4400 4800 4900 2e00
3300 3500 3900 3e00 4800 3a00 3600 3a00
3700 3900 2d00 3800 3800 2700 2500 2000
2c00 2800 2700 3100 0f00 2100 4200 2f00
2e00 2400 2c00 2600 1900 2a00 0100 1600
1d00 2900 4100 4100 6400 5c00 5700 4800
3e00 3800 1f00 2700 3600 2400 3d00 5200
6600 6400 6200 4600 4f00 4800 2200 2000
1f00 2800 0400 2300 1700 2b00 2700 1800
0000 0000 f0ff e3ff b9ff a6ff acff a3ff
a2ff 97ff a5ff 96ff 7aff 5cff 56ff 4eff
31ff 18ff 2aff 1eff 11ff 19ff 04ff 07ff
08ff e3fe f3fe 1eff e8fe f5fe f1fe cffe
03ff e2fe 17ff 2bff 11ff 34ff 4fff 4fff
2dff 4bff 43ff 2eff 60ff 49ff 6cff acff
e9ff 0b00 5600 3e00 5000 3d00 5b00 5500
4300 2100 3500 2d00 6200 6800 4b00 5900
9a00 3a00 5d00 6e00 3200 0400 1400 f8ff
2900 3200 0700 ebff 0700 f2ff 2800 1100
1c00 3700 d7ff ddff cdff e3ff f2ff 0e00
daff 2f00 6900 8f00 a900 7900 6e00 6b00
f000 e500 7e00 ab00 de00 c700 e000 4801
3b01 5c01 1901 0701 6c01 e300 f800 4a01
2901 5a01 5f01 6701 8801 5901 1701 1e01
4901 3f01 1f01 ff00 5601 cf00 5200 0401
2e01 7001 2801 4d01 a100 df00 df00 6801
6401 a100 fa00 ba01 e300 b000 2c01 5501
b3ff 7e01 5702 3700 f300 6401 f501 3f02
9dff 98ff 8201 2cff 24fd 6b01 6bff 48ff
7301 f201 9102 a0ff 3c02 9c00 c500 3901
5d02 a500 1200 1300 bdfe d8fe 25ff 10fe
04fd a400 0300 ad01 9e04 6105 1405 ee04
fe04 8a05 4606 2f05 5702 fa02 1901 b002
4cff 8b01 9902 6a03 0d04 2e05 f202 3801
9000 d4fe 0c00 2501 56ff 41ff 31ff 98fd
d0fd a7fb 3efe 45ff 91fc c9fe 3cfd 21fc
b5fd 2bfd 7bfb 0afd 14ff f1fe 95ff 18ff
0000 50fd 59fe a000 f9ff 7a00 8100 1100
f0ff 5300 af00 1f00 3a03 e001 7703 2e03
9503 5001 8fff b400 c9ff 1602 d201 3e00
2201 9501 88ff 71ff f901 5100 4eff 1b00
7e00 aefe e6fd 24fd 27fc d2fe 47fd d5fe
befe ddfd 22ff 03fe c7fc 5dfe c2fd f2fb
aefe 45fd 63fd 16fb 82fd ecfc 5ffc 66fd
3cfe fcfd 4cfd 21fe f2fd 3bfd 0afd f8fc
74fd bafe 36fd 6bff 65fe c2fd c0fd e8fe
cbff 1dff dcff 26ff 3afe 92fd 06fd 49fe
78fb 30fe 8bff dafe bcff 37ff 50fe a3fe
69fe 7dfe 5e00 06ff 1900 4afd 93fd 09ff
0eff d5fd a900 d702 0300 a301 2903 2fff
07ff d6fd 51fe 9aff 8dff 3200 4a01 e200
cdff 5201 d501 fd01 bd00 6001 ab00 c6fd
20ff ccff c0fc 6eff c400 44ff 8001 24ff
3bff 0800 93fd 9500 bffe 9dfe c8fe dafd
5ffe 76fe e6ff 8bfe 8500 6001 73ff a200
d2fe fdfe 1bff 60ff cb00 1800 1d01 7e00
f800 c600 ec00 9e01 c101 f601 8701 ff01
fb01 d400 bc00 b300 5c00 9100 eeff 6e01
6c02 3eff b0ff 1101 7bff d8ff 9c00 6ffe
1fff aafd a0fe d8fd b5fe 5cfd 36fc 31ff
24fe 71ff 23fe 60ff 65fd 20fd 5efd 9efb
7bfe 07fc 3ffc c1fe ecfc c1fb bcfb ebfc
6afd d1fd 9cff 8dfe 82fd cffd 4dfc 53fd
6cfd 82fe a1fd 52fd f8fe 6ffd 39fd e8fc
b7fb 23fd 2dfd aefc aefc bffc 75fc f0fa
f5fc e8fd 76fe 2dfd 9afc 80fd 1bfc a8fa
36fd 35fa d8f9 31fa d1fa f8fb a2fc e7fd
52fd d0fe d9ff 2eff 97ff 41ff 23fd 22fe
73fd 88fd 78ff 9aff e2fe 0802 e203 b203
0b04 6104 9303 1903 d701 4704 b905 0903
d103 5805 3006 0706 7707 4a07 9607 e907
d606 b906 1f08 ee04 1a04 1507 3d08 ff08
ce09 740a a609 5109 ff08 fd08 a708 e507
1e08 2e07 7208 4e08 9807 3009 6808 d408
c00a 250a f308 6807 4806 5c05 0904 2206
6e06 8707 c208 3c08 8e0a 7e09 fc07 7708
d406 d205 6405 6d04 7e04 6604 7704 7005
7707 2107 1a06 9b05 ab03 5901 47fe 75fd
28fc 84fa 87fb 21fc d4fb 77f9 41f9 98f8
57f7 2bf6 7af4 64f2 7cee 29ec 05ea 9ee8
90e9 0aea d2ea b6eb efeb 77e9 e0e6 85e6
59e4 5fe4 89e6 cee8 10ea 5eeb 5aee 66ef
49f2 4cf7 3ffa 91fb befd 75fd 8ffd 32fd
9eff 0202 8806 7a07 c90d ca15 b913 5614
7a16 7e16 a515 c617 2c17 c815 8b13 ef0f
9512 4f13 0212 5313 c413 0511 5810 cf0d
f907 8704 6b01 47fd 7afb 8bfb a9f8 25f8
0ef7 acf5 1cf5 83f3 fff2 53f0 c4ed 7ceb
76eb 14e9 eee8 f8e9 cfeb 1ded 89ef dff2
fcf3 caf4 bff4 0df6 b7f6 57f7 89f9 56fc
bafe 6702 c705 2609 ee0b 480e 5610 c512
9713 1614 9015 9d16 da16 e417 ad19 831a
cb1b 541d 421e 341e 5f1d 701b 1419 c117
e615 6b15 af15 b714 6e13 fe13 3112 1d11
be0f 130c 430a 4d08 9305 0d03 4402 9cff
4ffd 1efe 9dfd 73fc 8efa 49f9 76f7 e3f3
3bf1 19f0 fded ebeb daec edec c4eb bdea
ace9 b4e7 b7e5 73e4 f8e2 f3e1 d3e0 fadf
35df 77e0 c6e1 84e2 f3e2 14e2 04e1 03df
49dc 7bdc 61db a2dc dde4 99ed fef1 1bf9
93fc 76f9 11fa 3c01 df02 ce04 2c07 f106
8f09 9b07 470a 4d0f 5213 b817 6d20 5a23
...



And when the encoding is set to mp3, it looks like this :


fff3 84c4 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
...



It seems like the linear16 file, which can be repeated one after another, and it works fine.


I was trying to convert audio1 format to audio2 in native php by making a byte analyze, but the result was broken, and not be readable.