
Recherche avancée
Médias (1)
-
La conservation du net art au musée. Les stratégies à l’œuvre
26 mai 2011
Mis à jour : Juillet 2013
Langue : français
Type : Texte
Autres articles (43)
-
Websites made with MediaSPIP
2 mai 2011, parThis page lists some websites based on MediaSPIP.
-
Creating farms of unique websites
13 avril 2011, parMediaSPIP platforms can be installed as a farm, with a single "core" hosted on a dedicated server and used by multiple websites.
This allows (among other things) : implementation costs to be shared between several different projects / individuals rapid deployment of multiple unique sites creation of groups of like-minded sites, making it possible to browse media in a more controlled and selective environment than the major "open" (...) -
Support audio et vidéo HTML5
10 avril 2011MediaSPIP utilise les balises HTML5 video et audio pour la lecture de documents multimedia en profitant des dernières innovations du W3C supportées par les navigateurs modernes.
Pour les navigateurs plus anciens, le lecteur flash Flowplayer est utilisé.
Le lecteur HTML5 utilisé a été spécifiquement créé pour MediaSPIP : il est complètement modifiable graphiquement pour correspondre à un thème choisi.
Ces technologies permettent de distribuer vidéo et son à la fois sur des ordinateurs conventionnels (...)
Sur d’autres sites (8579)
-
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.


-
Google Speech - Streaming Request Returns EOF
9 octobre 2017, par JoshUsing Go, I’m taking a RTMP stream, transcoding it to FLAC (using ffmpeg) and attempting to stream to Google’s Speech API to transcribe the audio. However, I keep getting
EOF
errors when sending the data. I can’t find any information on this error in the docs so I’m not exactly sure what’s causing it.I’m chunking the received data into 3s clips (length isn’t relevant as long as it’s less than the maximum length of a streaming recognition request).
Here is the core of my code :
func main() {
done := make(chan os.Signal)
received := make(chan []byte)
go receive(received)
go transcribe(received)
signal.Notify(done, os.Interrupt, syscall.SIGTERM)
select {
case <-done:
os.Exit(0)
}
}
func receive(received chan<- []byte) {
var b bytes.Buffer
stdout := bufio.NewWriter(&b)
cmd := exec.Command("ffmpeg", "-i", "rtmp://127.0.0.1:1935/live/key", "-f", "flac", "-ar", "16000", "-")
cmd.Stdout = stdout
if err := cmd.Start(); err != nil {
log.Fatal(err)
}
duration, _ := time.ParseDuration("3s")
ticker := time.NewTicker(duration)
for {
select {
case <-ticker.C:
stdout.Flush()
log.Printf("Received %d bytes", b.Len())
received <- b.Bytes()
b.Reset()
}
}
}
func transcribe(received <-chan []byte) {
ctx := context.TODO()
client, err := speech.NewClient(ctx)
if err != nil {
log.Fatal(err)
}
stream, err := client.StreamingRecognize(ctx)
if err != nil {
log.Fatal(err)
}
// Send the initial configuration message.
if err = stream.Send(&speechpb.StreamingRecognizeRequest{
StreamingRequest: &speechpb.StreamingRecognizeRequest_StreamingConfig{
StreamingConfig: &speechpb.StreamingRecognitionConfig{
Config: &speechpb.RecognitionConfig{
Encoding: speechpb.RecognitionConfig_FLAC,
LanguageCode: "en-GB",
SampleRateHertz: 16000,
},
},
},
}); err != nil {
log.Fatal(err)
}
for {
select {
case data := <-received:
if len(data) > 0 {
log.Printf("Sending %d bytes", len(data))
if err := stream.Send(&speechpb.StreamingRecognizeRequest{
StreamingRequest: &speechpb.StreamingRecognizeRequest_AudioContent{
AudioContent: data,
},
}); err != nil {
log.Printf("Could not send audio: %v", err)
}
}
}
}
}Running this code gives this output :
2017/10/09 16:05:00 Received 191704 bytes
2017/10/09 16:05:00 Saving 191704 bytes
2017/10/09 16:05:00 Sending 191704 bytes
2017/10/09 16:05:00 Could not send audio: EOF
2017/10/09 16:05:03 Received 193192 bytes
2017/10/09 16:05:03 Saving 193192 bytes
2017/10/09 16:05:03 Sending 193192 bytes
2017/10/09 16:05:03 Could not send audio: EOF
2017/10/09 16:05:06 Received 193188 bytes
2017/10/09 16:05:06 Saving 193188 bytes
2017/10/09 16:05:06 Sending 193188 bytes // Notice that this doesn't error
2017/10/09 16:05:09 Received 191704 bytes
2017/10/09 16:05:09 Saving 191704 bytes
2017/10/09 16:05:09 Sending 191704 bytes
2017/10/09 16:05:09 Could not send audio: EOFNotice that not all of the
Send
s fail.Could anyone point me in the right direction here ? Is it something to do with the FLAC headers or something ? I also wonder if maybe resetting the buffer causes some of the data to be dropped (i.e. it’s a non-trivial operation that actually takes some time to complete) and it doesn’t like this missing information ?
Any help would be really appreciated.