
Recherche avancée
Médias (1)
-
The Great Big Beautiful Tomorrow
28 octobre 2011, par
Mis à jour : Octobre 2011
Langue : English
Type : Texte
Autres articles (63)
-
Les vidéos
21 avril 2011, parComme les documents de type "audio", Mediaspip affiche dans la mesure du possible les vidéos grâce à la balise html5 .
Un des inconvénients de cette balise est qu’elle n’est pas reconnue correctement par certains navigateurs (Internet Explorer pour ne pas le nommer) et que chaque navigateur ne gère en natif que certains formats de vidéos.
Son avantage principal quant à lui est de bénéficier de la prise en charge native de vidéos dans les navigateur et donc de se passer de l’utilisation de Flash et (...) -
(Dés)Activation de fonctionnalités (plugins)
18 février 2011, parPour gérer l’ajout et la suppression de fonctionnalités supplémentaires (ou plugins), MediaSPIP utilise à partir de la version 0.2 SVP.
SVP permet l’activation facile de plugins depuis l’espace de configuration de MediaSPIP.
Pour y accéder, il suffit de se rendre dans l’espace de configuration puis de se rendre sur la page "Gestion des plugins".
MediaSPIP est fourni par défaut avec l’ensemble des plugins dits "compatibles", ils ont été testés et intégrés afin de fonctionner parfaitement avec chaque (...) -
Activation de l’inscription des visiteurs
12 avril 2011, parIl est également possible d’activer l’inscription des visiteurs ce qui permettra à tout un chacun d’ouvrir soit même un compte sur le canal en question dans le cadre de projets ouverts par exemple.
Pour ce faire, il suffit d’aller dans l’espace de configuration du site en choisissant le sous menus "Gestion des utilisateurs". Le premier formulaire visible correspond à cette fonctionnalité.
Par défaut, MediaSPIP a créé lors de son initialisation un élément de menu dans le menu du haut de la page menant (...)
Sur d’autres sites (11102)
-
FFMpeg Command work in command line, but not in python script
20 février 2015, par FooldjOkay, kind of a weird problem. But I’m not sure whether it’s python, ffmpeg, or some stupid thing I’m doing wrong.
I’m trying to take a video, and take 1 frame a second, and output that frame to an image. Right now, if i use the command line with ffmpeg :
ffmpeg -i test.avi -r 1 -f image2 image-%3d.jpeg -pix_fmt rgb24 -vcodec rawrvideo
It outputs about 10 images, the images look fine, awesome. Now I have this code (right now some code from some github, as I wanted stuff that i was relatively sure would work, and mine is allll convoluted)
import subprocess as sp
import numpy as np
import re
import cv2
import time
FFMPEG_BIN = r'ffmpeg.exe'
INPUT_VID = 'test.avi'
def getInfo():
command = [FFMPEG_BIN,'-i', INPUT_VID, '-']
pipe = sp.Popen(command, stdout=sp.PIPE, stderr=sp.PIPE)
pipe.stdout.readline()
pipe.terminate()
infos = pipe.stderr.read()
infos_list = infos.split('\r\n')
res = re.search(' \d+x\d+ ',infos)
res = [int(x) for x in res.group(0).split('x')]
return res
res = getInfo()
command = [ FFMPEG_BIN,
'-i', INPUT_VID,
'-f', 'image2pipe',
'-pix_fmt', 'rgb24',
'-vcodec', 'rawvideo', '-']
pipe = sp.Popen(command, stdout = sp.PIPE, bufsize=10**8)
n = 0
im2 = []
try:
mog = cv2.BackgroundSubtractorMOG2(120,2,True)
while True:
raw_image = pipe.stdout.read(res[0]*res[1]*3)
# transform the byte read into a numpy array
image = np.fromstring(raw_image, dtype='uint8')
image = image.reshape((res[1],res[0],3))
rgbImg = image.copy()
fname = ('_tmp%03d.png'%time.time())
cv2.imwrite(fname, rgbImg)
# throw away the data in the pipe's buffer.
#pipe.stdout.flush()
n += 1
print n
except:
print 'done',n
pipe.kill()
cv2.destroyAllWindows()When I run this, I get 10 images, but they all have a Blue Tint ! I cannot for the life of me figure out why. I’ve done tons of searches, I’ve tried quite a few different codecs (usually just messes things up worse). The media info for the video file is here :
General
Complete name : test.avi
Format : AVI
Format/Info : Audio Video Interleave
File size : 85.0 KiB
Duration : 133ms
Overall bit rate : 5 235 Kbps
Video
ID : 0
Format : JPEG
Codec ID : MJPG
Duration : 133ms
Bit rate : 1 240 Kbps
Width : 640 pixels
Height : 480 pixels
Display aspect ratio : 4:3
Frame rate : 30.000 fps
Color space : YUV
Chroma subsampling : 4:2:2
Bit depth : 8 bits
Compression mode : Lossy
Bits/(Pixel*Frame) : 0.135
Stream size : 20.1 KiB (24%)Any suggestions ? It seems like it should be an RGB mixup...just not sure where at...
-
FFmpeg : encoding in webm (vp9) for windows
2 juillet 2015, par SeltymarI’m trying to encode jpegs to a webm video in vp9 on windows 7.
I followed the instructions from webmproject in 2 pass.
I changed\dev\nul
byNUL
.ffmpeg.exe -i %4d.jpg -c:v libvpx-vp9 -pass 1 -b:v 1000K -threads 8 -speed 4 -tile-columns 6 -frame-parallel 1 -auto-alt-ref 1 -lag-in-frames 25 -an -f webm NUL
ffmpeg.exe -i %4d.jpg -c:v libvpx-vp9 -pass 2 -b:v 1000K -threads 8 -speed 1 -tile-columns 6 -frame-parallel 1 -auto-alt-ref 1 -lag-in-frames 25 -c:a libopus -b:a 64k -f webm out.webmbut after the first pass, it tells me "output file is empty, nothing was encoded". But the second pass create the video.
I also tryed in one pass :
ffmpeg -i %4d.jpg -c:v libvpx-vp9 -crf 10 -b:v 0 output.webm
Then I want to use the output video using html5 video and canvas tags as below.
<canvas>
Your browser does not support the canvas tag.
</canvas>
<code class="echappe-js"><script><br />
<br />
<br />
var videos = document.createElement('video');<br />
videos.src = "output.webm";<br />
videos.type = "video/webm";<br />
videos.load(); <br />
videos.play();<br />
videos.playbackRate = 1;<br />
var videoImage0 = document.getElementById('canvas'); <br />
videoImage0.width = 2700;<br />
videoImage0.height = 1350;<br />
<br />
var videoImageContexts =videoImage0.getContext('2d');<br />
//// background color if no video present<br />
videoImageContexts.fillStyle = '#0000ff';<br />
videoImageContexts.fillRect(0, 0, videoImage0.width, videoImage0.height); <br />
animate();<br />
<br />
function animate() {<br />
requestAnimationFrame(animate);<br />
update();<br />
<br />
}<br />
<br />
function update() {<br />
<br />
if (videos.readyState === videos.HAVE_ENOUGH_DATA) {<br />
videoImageContexts.drawImage(videos, 0, 0);<br />
}<br />
}<br />
</script>result :
- With both methods the output video can’t be read in VLC but it can be read if I drag and drop in firefox or chrome or using the video tag only.
- The html page above works correctly on chrome but not in firefox. In firefox, the color is not correct like if the blue channel was translated.
I think the problem is the encoding with FFmpeg. I’m using the static build from zeranoe. Here is the version
and libvpx is enable.
My questions :
-
Is there a problem on my command line ?
-
Is there a problem in my JS code that could lead to error in the decoding process ?
-
Trying to encode video file as hevc error in python
29 juin 2022, par jattI am getting a syntax error when trying to run this code with it saying the end quotes being the error.
process = sp.Popen(shlex.split(f'usr/bin/ffmpeg -y -s {width}x{height} -pixel_format bgr24 -f rawvideo -r {fps} -i pipe: -vcodec libx265 -pix_fmt yuv420p -crf 24 {output_filename}') stdin=sp.PIPE)


I don't know why because the end quote is supposed to be there and I am not sure how to fix it.
The original code is from here : How to output x265 compressed video with cv2.VideoWriter


import cv2
import numpy as np
import subprocess as sp
import shlex

width, height, n_frames, fps = 1344, 756, 50, 25 # 50 frames, resolution 1344x756, and 25 fps

output_filename = 'output.mp4'

# Open ffmpeg application as sub-process
# FFmpeg input PIPE: RAW images in BGR color format
# FFmpeg output MP4 file encoded with HEVC codec.
# Arguments list:
# -y Overwrite output file without asking
# -s {width}x{height} Input resolution width x height (1344x756)
# -pixel_format bgr24 Input frame color format is BGR with 8 bits per color component
# -f rawvideo Input format: raw video
# -r {fps} Frame rate: fps (25fps)
# -i pipe: ffmpeg input is a PIPE
# -vcodec libx265 Video codec: H.265 (HEVC)
# -pix_fmt yuv420p Output video color space YUV420 (saving space compared to YUV444)
# -crf 24 Constant quality encoding (lower value for higher quality and larger output file).
# {output_filename} Output file name: output_filename (output.mp4)
process = sp.Popen(shlex.split(f'usr/bin/ffmpeg -y -s {width}x{height} -pixel_format bgr24 -f rawvideo -r {fps} -i pipe: -vcodec libx265 -pix_fmt yuv420p -crf 24 {output_filename}') stdin=sp.PIPE)

# Build synthetic video frames and write them to ffmpeg input stream.
for i in range(n_frames):
 # Build synthetic image for testing ("render" a video frame).
 img = np.full((height, width, 3), 60, np.uint8)
 cv2.putText(img, str(i+1), (width//2-100*len(str(i+1)), height//2+100), cv2.FONT_HERSHEY_DUPLEX, 10, (255, 30, 30), 20) # Blue number

 # Write raw video frame to input stream of ffmpeg sub-process.
 process.stdin.write(img.tobytes())

# Close and flush stdin
process.stdin.close()

# Wait for sub-process to finish
process.wait()

# Terminate the sub-process
process.terminate()