
Recherche avancée
Autres articles (36)
-
Personnaliser en ajoutant son logo, sa bannière ou son image de fond
5 septembre 2013, parCertains thèmes prennent en compte trois éléments de personnalisation : l’ajout d’un logo ; l’ajout d’une bannière l’ajout d’une image de fond ;
-
Ecrire une actualité
21 juin 2013, parPrésentez les changements dans votre MédiaSPIP ou les actualités de vos projets sur votre MédiaSPIP grâce à la rubrique actualités.
Dans le thème par défaut spipeo de MédiaSPIP, les actualités sont affichées en bas de la page principale sous les éditoriaux.
Vous pouvez personnaliser le formulaire de création d’une actualité.
Formulaire de création d’une actualité Dans le cas d’un document de type actualité, les champs proposés par défaut sont : Date de publication ( personnaliser la date de publication ) (...) -
Des sites réalisés avec MediaSPIP
2 mai 2011, parCette page présente quelques-uns des sites fonctionnant sous MediaSPIP.
Vous pouvez bien entendu ajouter le votre grâce au formulaire en bas de page.
Sur d’autres sites (6933)
-
Python & OpenCV - VideoCapture.read() always returns false
21 août 2017, par JulenI need to extract frames from a video at a given time, and I’m using OpenCV for it. I’m using Linux Mint 18.1, but it must also run on Ubuntu.
This code example is not working for me :
import cv2
print('making screenshot from {0}'.format('/tmp/big_buck_bunny_720p_5mb.mp4'))
cap = cv2.VideoCapture(video_path)
cap.set(cv2.CAP_PROP_POS_MSEC,1000)
ret,frame = cap.read()
print(ret) # This is false
cv2.imwrite("image.jpg", frame) # Creates an empty file(I’ve checked that the path of the video is correct and that the file is not corrupted).
I have installed the Python OpenCV 3.3.0 version :
>>> import cv2
>>> cv2.__version__
'3.3.0'I’ve compiled and installed the source for OpenCV (with the
WITH_FFMPEG=ON
option) :git clone https://github.com/Itseez/opencv.git /tmp/opencv-3
/tmp/opencv-3
mkdir -p release
cd release
cmake -D WITH_FFMPEG=ON -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
make
sudo make installThe output of
ffmpeg -version
is the following :ffmpeg version 2.8.11-0ubuntu0.16.04.1 Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.4) 20160609
configuration: --prefix=/usr --extra-version=0ubuntu0.16.04.1 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-libx264 --enable-libopencv
libavutil 54. 31.100 / 54. 31.100
libavcodec 56. 60.100 / 56. 60.100
libavformat 56. 40.101 / 56. 40.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 40.101 / 5. 40.101
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.101 / 1. 2.101
libpostproc 53. 3.100 / 53. 3.100What am I missing ?
-
Django api returns Gif as JPG despite a function to add it as video
7 septembre 2023, par EarthlingI'm trying to upload a .gif to my django 3.2 api. I have already ran troubleshoots through Postman and came to the conclusion that my flutter app sends it as a .gif and it gets returned as a .jpg. The problem is on the backend. Here is my relevant code which checks for file_meme subtype and then the function should convert the incoming .gif to a video :




def add_media(self, file, order=None):
 check_can_add_media(post=self)

 is_in_memory_file = isinstance(file, InMemoryUploadedFile) or isinstance(file, SimpleUploadedFile)

 if is_in_memory_file:
 file_mime = magic.from_buffer(file.read())
 elif isinstance(file, TemporaryUploadedFile):
 file_mime = magic.from_file(file.temporary_file_path())
 else:
 file_mime = magic.from_file(file.name)

 check_mimetype_is_supported_media_mimetypes(file_mime)
 # Mime check moved pointer
 file.seek(0)

 file_mime_types = file_mime.split('/')

 file_mime_type = file_mime_types[0]
 file_mime_subtype = file_mime_types[1]

 temp_files_to_close = []

 if file_mime_subtype == 'gif':
 if is_in_memory_file:
 file = write_in_memory_file_to_disk(file)

 temp_dir = tempfile.gettempdir()
 converted_gif_file_name = os.path.join(temp_dir, str(uuid.uuid4()) + '.mp4')

 ff = ffmpy.FFmpeg(
 inputs={file.temporary_file_path() if hasattr(file, 'temporary_file_path') else file.name: None},
 outputs={converted_gif_file_name: None})
 ff.run()
 converted_gif_file = open(converted_gif_file_name, 'rb')
 temp_files_to_close.append(converted_gif_file)
 file = File(file=converted_gif_file)
 file_mime_type = 'video'

 has_other_media = self.media.exists()
 
 if file_mime_type == 'image':
 post_image = self._add_media_image(image=file, order=order)
 if not has_other_media:
 self.media_width = post_image.width
 self.media_height = post_image.height
 self.media_thumbnail = file

 elif file_mime_type == 'video':
 post_video = self._add_media_video(video=file, order=order)
 if not has_other_media:
 self.media_width = post_video.width
 self.media_height = post_video.height
 self.media_thumbnail = post_video.thumbnail.file
 else:
 raise ValidationError(
 _('Unsupported media file type')
 )

 for file_to_close in temp_files_to_close:
 file_to_close.close()
 
 
 self.save()







def _add_media_image(self, image, order):
 return PostImage.create_post_media_image(image=image, post_id=self.pk, order=order)

def _add_media_video(self, video, order):
 return PostVideo.create_post_media_video(file=video, post_id=self.pk, order=order)


@classmethod
 def create_post_media_image(cls, image, post_id, order):
 hash = sha256sum(file=image.file)
 post_image = cls.objects.create(image=image, post_id=post_id, hash=hash, thumbnail=image)
 PostMedia.create_post_media(type=PostMedia.MEDIA_TYPE_IMAGE,
 content_object=post_image,
 post_id=post_id, order=order)
 return post_image


@classmethod
 def create_post_media_video(cls, file, post_id, order):
 hash = sha256sum(file=file.file)
 video_backend = get_backend()

 if isinstance(file, InMemoryUploadedFile):
 # If its in memory, doing read shouldn't be an issue as the file should be small.
 in_disk_file = write_in_memory_file_to_disk(file)
 thumbnail_path = video_backend.get_thumbnail(video_path=in_disk_file.name, at_time=0.0)
 else:
 thumbnail_path = video_backend.get_thumbnail(video_path=file.file.name, at_time=0.0)

 with open(thumbnail_path, 'rb+') as thumbnail_file:
 post_video = cls.objects.create(file=file, post_id=post_id, hash=hash, thumbnail=File(thumbnail_file), )
 PostMedia.create_post_media(type=PostMedia.MEDIA_TYPE_VIDEO,
 content_object=post_video,
 post_id=post_id, order=order)
 return post_video
 
 



I'm not sure where the problem is. From my limited understanding, it is taking only the first frame of the .gif and uploading it as an image.


-
Shaka Player returns 4001 error - Node.js local web server playing MPEG-DASH
27 mai 2020, par salgarjiI've used Chrome inspection tool to access 'Console' and analyze what is happening. Complete error information :



D {severity: 2, category: 4, code: 4001, data: Array(1), handled: false}
category: 4
code: 4001
data: Array(1)
0: "http://localhost:8080/dash_segmentos/video.mpd"
length: 1
__proto__: Array(0)
handled: false
severity: 2
__proto__: Object




My
Server.js
file :


var http = require('http');
var fs = require('fs');

console.log(__dirname);

var path='dash_segmentos/video.mpd';
fs.access(path, fs.constants.R_OK | fs.constants.W_OK, (err) => {
 if (err) {
 console.log("%s doesn't exist", path);
 } else {
 console.log('can read/write %s', path);
 }
});

const PORT=8080; 

fs.readFile('./player.html', function (err, html) {

 if (err) throw err; 

 http.createServer(function(request, response) { 
 response.setHeader("Access-Control-Allow-Headers", "authorization, content-type");
 response.setHeader("Access-Control-Allow-Origin", "*");
 response.setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
 response.writeHeader(200, {"Content-Type": "text/html"}); 
 response.write(html); 
 response.end();
 }).listen(PORT);
});




As you can see I've added CORS (I guess it's correct) and a console.log to see if it's in the proper location. Furthermore, I've verified that file is accessible with
fs.access
and it returnscan read/write dash_segmentos/video.mpd
For this reason, I'm sure I am in the correct path and referencing the right file.


The HTML code (
player.html
) provided toServer.js
:




 
 <code class="echappe-js"><script type="text/javascript"&#xA;src="https://cdnjs.cloudflare.com/ajax/libs/shaka-player/2.5.11/shaka-player.compiled.js"></script>

 
 

 



<script>&#xA;function initApp() { &#xA;shaka.polyfill.installAll(); &#xA;if (shaka.Player.isBrowserSupported()) { &#xA; initPlayer(); &#xA; } else { &#xA; console.error(&#x27;Browser not supported!&#x27;);&#xA; }}&#xA;&#xA;function initPlayer() { &#xA;var video = document.getElementById( &#x27;video&#x27; );&#xA;var player = new shaka.Player( video );&#xA; window.player = player; &#xA;player.addEventListener(&#x27;error&#x27;, onErrorEvent); &#xA;player.load(path).then(function (){&#xA; console.log(&#x27;Video loaded correctly&#x27;);&#xA; }).catch(onError);&#xA;&#xA;function onErrorEvent(event) {&#xA; onError(event.detail); &#xA; }&#xA;function onError(error) {&#xA; console.error(&#x27;Codigo de error: &#x27;, error.code, &#x27; en &#x27;, error);&#xA; }&#xA;}&#xA;</script>


<script>&#xA;var path=&#x27;dash_segmentos/video.mpd&#x27;;&#xA;//var path=&#x27;https://dash.akamaized.net/dash264/TestCases/2c/qualcomm/1/MultiResMPEG2.mpd&#x27;;&#xA;//the URL above is working! but it won&#x27;t read my local mpd&#xA;&#xA;document.addEventListener(&#x27;DOMContentLoaded&#x27;, initApp);&#xA;&#xA; </script>

 




I've tried changing the URL to an online resource and the player is properly working.



My fluent-ffmpeg command which generates the video is :



var ffmpeg = require('fluent-ffmpeg');

var grabacion = new ffmpeg();

grabacion.addInput('0')
.inputOptions(['-y -nostdin', '-f avfoundation', '-video_size 1280x720', '-framerate 30'])
.outputOptions(['-vcodec libx264', '-keyint_min 0', '-g 100', '-map 0:v', '-b:v 1000k', '-f dash',
 '-use_template 1', '-use_timeline 0', '-init_seg_name video0-$RepresentationID$-$Number$.mp4',
 '-media_seg_name video0-$RepresentationID$-$Number$.mp4','-single_file 0', '-remove_at_exit 0', '-window_size 20', '-seg_duration 4'])
.output('/path/to/files/dash_segmentos/video.mpd')
.run();




The mpd manifest file is :



<?xml version="1.0" encoding="utf-8"?>
<mpd xmlns="urn:mpeg:dash:schema:mpd:2011" profiles="urn:mpeg:dash:profile:isoff-live:2011" type="static" mediapresentationduration="PT26.7S" maxsegmentduration="PT4.0S" minbuffertime="PT13.2S">
 <programinformation>
 </programinformation>
 <servicedescription>
 </servicedescription>
 <period start="PT0.0S">
 <adaptationset contenttype="video" startwithsap="1" segmentalignment="true" bitstreamswitching="true" framerate="30000/1001" maxwidth="1280" maxheight="720" par="16:9">
 <representation mimetype="video/mp4" codecs="avc1.7a001f" bandwidth="1000000" width="1280" height="720" sar="1:1">
 <segmenttemplate timescale="1000000" duration="4000000" initialization="video0-$RepresentationID$-$Number$.mp4" media="video0-$RepresentationID$-$Number$.mp4" startnumber="1">
 </segmenttemplate>
 </representation>
 </adaptationset>
 </period>
</mpd>




Is something about ffmpeg ? Permissions ? Pixel format ? Encoding ? I've tried with other mpd file provided by my Raspberry Pi using video4linux (v4l) and it returns the same error !



I know that's a lot of code, but maybe you find it quicker than me. I guess it's a Shaka Player thing with the XML, but I can't explain how ffmpeg is wrongly creating XML code.



Thank you in advance !!