
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 (38)
-
MediaSPIP version 0.1 Beta
16 avril 2011, parMediaSPIP 0.1 beta est la première version de MediaSPIP décrétée comme "utilisable".
Le fichier zip ici présent contient uniquement les sources de MediaSPIP en version standalone.
Pour avoir une installation fonctionnelle, il est nécessaire d’installer manuellement l’ensemble des dépendances logicielles sur le serveur.
Si vous souhaitez utiliser cette archive pour une installation en mode ferme, il vous faudra également procéder à d’autres modifications (...) -
MediaSPIP 0.1 Beta version
25 avril 2011, parMediaSPIP 0.1 beta is the first version of MediaSPIP proclaimed as "usable".
The zip file provided here only contains the sources of MediaSPIP in its standalone version.
To get a working installation, you must manually install all-software dependencies on the server.
If you want to use this archive for an installation in "farm mode", you will also need to proceed to other manual (...) -
Mise à jour de la version 0.1 vers 0.2
24 juin 2013, parExplications des différents changements notables lors du passage de la version 0.1 de MediaSPIP à la version 0.3. Quelles sont les nouveautés
Au niveau des dépendances logicielles Utilisation des dernières versions de FFMpeg (>= v1.2.1) ; Installation des dépendances pour Smush ; Installation de MediaInfo et FFprobe pour la récupération des métadonnées ; On n’utilise plus ffmpeg2theora ; On n’installe plus flvtool2 au profit de flvtool++ ; On n’installe plus ffmpeg-php qui n’est plus maintenu au (...)
Sur d’autres sites (2199)
-
C++ ffmpeg API created video does not open in some players
18 novembre 2017, par ar2015After my previous question, I found codes from here to create videos in
C++
usingavcodec
offfmpeg
libraries.I have modified this code to comply with
C++
. Everything is fine and it createsmp4
videos. Except for the output video opens with some video managers and does not open with some others.E.g. I can open it on Linux by totem (the slider does not allow back and forth anyway). But VLC (on the same Linux machine) does not open this file. Probably, there will be similar problem in windows.
Is there any missing process for this code causing this problem ?
#include
#include
#include
#include <string>
#include <iostream>
extern "C" {
#include <libavcodec></libavcodec>avcodec.h>
#include <libavutil></libavutil>opt.h>
#include <libavutil></libavutil>imgutils.h>
}
static void encode(AVCodecContext *enc_ctx, AVFrame *frame, AVPacket *pkt,
FILE *outfile)
{
int ret;
/* send the frame to the encoder */
if (frame)
std::cout<<"Send frame "<<(frame->pts)<= 0) {
ret = avcodec_receive_packet(enc_ctx, pkt);
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
return;
else if (ret < 0) {
fprintf(stderr, "Error during encoding\n");
exit(1);
}
std::cout<<"Write packet "<<(pkt->pts)<<" (size="<<(pkt->size)<<")"</ printf("Write packet %3" PRId64" (size=%5d)\n", pkt->pts, pkt->size);
fwrite(pkt->data, 1, pkt->size, outfile);
av_packet_unref(pkt);
}
}
int main(int argc, char **argv)
{
const char *filename;
const AVCodec *codec;
AVCodecContext *c= NULL;
int i, ret, x, y;
FILE *f;
AVFrame *frame;
AVPacket *pkt;
uint8_t endcode[] = { 0, 0, 1, 0xb7 };
if (argc < 2) {
fprintf(stderr, "Usage: %s <output file="file">\n", argv[0]);
exit(0);
}
filename = argv[1];
std::string codec_name = "mpeg4";
avcodec_register_all();
/* find the mpeg1video encoder */
codec = avcodec_find_encoder_by_name(codec_name.c_str());
if (!codec) {
fprintf(stderr, "Codec '%s' not found\n", codec_name.c_str());
exit(1);
}
c = avcodec_alloc_context3(codec);
if (!c) {
fprintf(stderr, "Could not allocate video codec context\n");
exit(1);
}
pkt = av_packet_alloc();
if (!pkt)
exit(1);
/* put sample parameters */
// c->bit_rate = 400000;
c->bit_rate = 4000000;
/* resolution must be a multiple of two */
// c->width = 352;
// c->height = 288;
c->width = 640;
c->height = 480;
/* frames per second */
c->time_base = (AVRational){1, 25};
c->framerate = (AVRational){25, 1};
/* emit one intra frame every ten frames
* check frame pict_type before passing frame
* to encoder, if frame->pict_type is AV_PICTURE_TYPE_I
* then gop_size is ignored and the output of encoder
* will always be I frame irrespective to gop_size
*/
c->gop_size = 10;
c->max_b_frames = 1;
c->pix_fmt = AV_PIX_FMT_YUV420P;
if (codec->id == AV_CODEC_ID_H264)
av_opt_set(c->priv_data, "preset", "slow", 0);
/* open it */
ret = avcodec_open2(c, codec, NULL);
if (ret < 0) {
fprintf(stderr, "Could not open codec\n");
// fprintf(stderr, "Could not open codec: %s\n", av_err2str(ret));
exit(1);
}
f = fopen(filename, "wb");
if (!f) {
fprintf(stderr, "Could not open %s\n", filename);
exit(1);
}
frame = av_frame_alloc();
if (!frame) {
fprintf(stderr, "Could not allocate video frame\n");
exit(1);
}
frame->format = c->pix_fmt;
frame->width = c->width;
frame->height = c->height;
ret = av_frame_get_buffer(frame, 32);
if (ret < 0) {
fprintf(stderr, "Could not allocate the video frame data\n");
exit(1);
}
/* encode 10 second of video */
for (i = 0; i < 250; i++) {
fflush(stdout);
/* make sure the frame data is writable */
ret = av_frame_make_writable(frame);
if (ret < 0)
exit(1);
/* prepare a dummy image */
/* Y */
for (y = 0; y < c->height; y++) {
for (x = 0; x < c->width; x++) {
frame->data[0][y * frame->linesize[0] + x] = uint8_t(x + y + i * 3);
}
}
/* Cb and Cr */
for (y = 0; y < c->height/2; y++) {
for (x = 0; x < c->width/2; x++) {
frame->data[1][y * frame->linesize[1] + x] = uint8_t(128 + y + i * 2);
frame->data[2][y * frame->linesize[2] + x] = uint8_t(64 + x + i * 5);
}
}
frame->pts = i;
/* encode the image */
encode(c, frame, pkt, f);
}
/* flush the encoder */
encode(c, NULL, pkt, f);
/* add sequence end code to have a real MPEG file */
fwrite(endcode, 1, sizeof(endcode), f);
fclose(f);
avcodec_free_context(&c);
av_frame_free(&frame);
av_packet_free(&pkt);
return 0;
}
</output></iostream></string>build :
g++ -I ./FFmpeg/ video.cpp -L ./fflibs -lavdevice -lavfilter -lavformat -lavcodec -lrt -ldl -lXfixes -lXext -lX11 -lasound -lSDL -lz -lrt -lswresample -lswscale -lavutil -lm -llzma -lbz2 -lswresample -lpthread
run
./a.out myvideo.mp4
This video will be fine if converted in bash via
ffmpeg -i myvideo.mp4 out1.mp4
But I look for a method to fix it from the code.
Generated video played on totem (Ubuntu) :
Video after conversion :
-
Joining realtime raw PCM streams with ffmpeg and streaming them back out
15 avril 2024, par Nathan LadwigI am trying to use ffmpeg to join two PCM streams. I have it sorta kinda working but it's not working great.


I am using Python to receive two streams from two computers running Scream Audio Driver ( ttps ://github.com/duncanthrax/scream )


I am taking them in over UDP and writing them to pipes. The pipes are being received by ffmpeg and mixed, it's writing the mixed stream to another pipe. I'm reading that back in Python and sending it to the target receiver.


My ffmpeg command is


['ffmpeg', 
'-use_wallclock_as_timestamps', 'true', '-f', 's24le', '-ac', '2', '-ar', '48000', '-i', '/tmp/ffmpeg-fifo-1',
'-use_wallclock_as_timestamps', 'true', '-f', 's24le', '-ac', '2', '-ar', '48000', '-i', '/tmp/ffmpeg-fifo-2',
'-filter_complex', '[0]aresample=async=1[a0],[1]aresample=async=1[a1],[a0][a1]amix', '-y',
'-f', 's24le', '-ac', '2', '-ar', '48000', '/tmp/ffmpeg-fifo-in']



My main issue is that it should be reading ffmpeg-fifo-1 and ffmpeg-fifo-2 asynchronously, but it appears to be not. When the buffers get more than 50 frames out of sync with each other ffmpeg hangs and doesn't recover. I would like to fix this.


In this hacky test code the number of frames sent over each stream are counted and empty frames are sent if the count hits 12. This keeps ffmpeg happy.


The code below takes in two 48KHz 24-bit stereo PCM streams with Scream's header, mixes them, applies the same header, and sends them back out.


It works most of the time. Sometimes I'm getting blasted with static, I think this is when only one or two bytes of a frame are making it to ffmpeg, and it loses track.


The header is always 1152 bytes of pcm data with a 5 byte header. It's described in the Scream repo readme


This is my header :


01 18 02 03 00


01 - 48KHz
18 - Sampling Rate (18h=24d, 24bit)
02 - 2 channels
03 00 - WAVEFORMATEXTENSIBLE


import socket
import struct
import threading
import os
import sys
import time
import subprocess
import tempfile
import select

class Sender(threading.Thread):
 def __init__(self):
 super().__init__()
 TEMPDIR = tempfile.gettempdir() + "/"
 self.fifoin = TEMPDIR + "ffmpeg-fifo-in"
 self.start()

 def run(self):
 self.fd = open(self.fifoin, "rb")
 self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
 while True:
 try:
 header = bytes([0x01, 0x18, 0x02, 0x03, 0x00]) # 48khz, 24-bit, stereo
 data = self.fd.read(1152)
 sendbuf = header + data
 self.sock.sendto(sendbuf, ("192.168.3.199", 4010)) # Audio sink
 except Exception as e:
 print("Except")
 print(e)

class Receiver(threading.Thread):
 def __init__(self):
 super().__init__()
 TEMPDIR = tempfile.gettempdir() + "/"
 self.fifo1 = TEMPDIR + "ffmpeg-fifo-1"
 self.fifo2 = TEMPDIR + "ffmpeg-fifo-2"
 self.fifoin = TEMPDIR + "ffmpeg-fifo-in"
 self.fifos = [self.fifo1, self.fifo2]
 try:
 try:
 os.remove(self.fifoin)
 except:
 pass
 os.mkfifo(self.fifoin)
 except:
 pass
 self.start()
 sender=Sender()

 def run(self):
 ffmpeg_command=['ffmpeg', '-use_wallclock_as_timestamps', 'true', '-f', 's24le', '-ac', '2', '-ar', '48000', '-i', self.fifo1,
 '-use_wallclock_as_timestamps', 'true', '-f', 's24le', '-ac', '2', '-ar', '48000', '-i', self.fifo2,
 '-filter_complex', '[0]aresample=async=1[a0],[1]aresample=async=1[a1],[a0][a1]amix', "-y", '-f', 's24le', '-ac', '2', '-ar', '48000', self.fifoin]
 print(ffmpeg_command)

 sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
 sock.setsockopt(socket.SOL_SOCKET,socket.SO_RCVBUF,4096)
 sock.bind(("", 16401))

 recvbuf = bytearray(1157)
 framecount = [0,0]
 closed = 1
 while True:
 ready = select.select([sock], [], [], .2)
 if ready[0]:
 recvbuf, addr = sock.recvfrom(1157)
 if closed == 1:
 for fifo in self.fifos:
 try:
 try:
 os.remove(fifo)
 except:
 pass
 os.mkfifo(fifo)
 except:
 pass
 framecount = [0,0]
 print("data, starting ffmpeg")
 ffmpeg = subprocess.Popen (ffmpeg_command, shell=False, stdout=subprocess.PIPE, stdin=subprocess.PIPE)
 fifo1_fd = os.open(self.fifo1, os.O_RDWR)
 fifo1_file = os.fdopen(fifo1_fd, 'wb', 0)
 fifo2_fd = os.open(self.fifo2, os.O_RDWR)
 fifo2_file = os.fdopen(fifo2_fd, 'wb', 0)
 closed = 0
 for i in range(0,6):
 fifo1_file.write(bytes([0]*1157))
 fifo2_file.write(bytes([0]*1157))

 if addr[0] == "192.168.3.199":
 fifo1_file.write(recvbuf[5:])
 framecount[0] = framecount[0] + 1

 if addr[0] == "192.168.3.119":
 fifo2_file.write(recvbuf[5:])
 framecount[1] = framecount[1] + 1

 # Keep buffers roughly in sync while playing
 targetframes=max(framecount)
 if targetframes - framecount[0] > 11:
 while (targetframes - framecount[0]) > 0:
 fifo1_file.write(bytes([0]*1157))
 framecount[0] = framecount[0] + 1

 if targetframes - framecount[1] > 11:
 while (targetframes - framecount[1]) > 0:
 fifo2_file.write(bytes([0]*1157))
 framecount[1] = framecount[1] + 1
 else:
 if closed == 0:
 ffmpeg.kill()
 print("No data, killing ffmpeg")
 fifo1_file.close()
 fifo2_file.close()
 closed = 1
receiver=Receiver()

while True:
 time.sleep(50000)



Does anybody have any pointers on how I can make this better ?


-
Piwik 2.1 – Changes for Plugin developers
24 février 2014, par Piwik Core Team — DevelopmentThis blog post is aimed at developers of Piwik Plugins. If you are simply using Piwik and not developing plugins for Piwik, you do not need to read this post.
Piwik 2.1 will be released in a few days . This blog post will inform Piwik Plugin developers of the changes in Piwik 2.1 that may require that you update your plugin to work with this latest version.
Breaking API changes
Piwik can now handle an unlimited number of users having Super User access (#2589 #4564). In the past Piwik was limited to one Super User who was defined in the config file. From now on all users with Super User access are defined in the database the same way a regular user is. This brought some API changes but we will stay backward compatible until the first of April 2014. This gives you some time to migrate any custom plugins you may use. Although there is a layer for backward compatibility we recommend to make sure your plugin works with Piwik as soon as possible before April 1st.
List of changes
Deprecated methods
The following methods are deprecated and we recommend to use the new methods from now on. There are also some methods which won’t be replaced so make sure to adjust the logic of your plugin.
\Piwik\Piwik::isUserIsSuperUser => \Piwik\Piwik::hasUserSuperUserAccess
\Piwik\Piwik::setUserIsSuperUser => \Piwik\Piwik::setUserHasSuperUserAccess
\Piwik\Piwik::checkUserIsSuperUser => \Piwik\Piwik::checkUserHasSuperUserAccess
\Piwik\Access::isSuperUser => \Piwik\Access::hasSuperUserAccess
\Piwik\Access::checkUserIsSuperUser => \Piwik\Access::checkUserHasSuperUserAccess
\Piwik\Access::setSuperUser => \Piwik\Access::setSuperUserAccess
\FakeAccess::checkUserIsSuperUser => FakeAccess::checkUserHasSuperUserAccess
\FakeAccess::setSuperUser => FakeAccess::setSuperUserAccess
\Piwik\Piwik::isUserIsSuperUserOrTheUser => \Piwik\Piwik::hasUserSuperUserAccessOrIsTheUser
\Piwik\Piwik::checkUserIsSuperUserOrTheUser => \Piwik\Piwik::checkUserHasSuperUserAccessOrIsTheUser
\FakeAccess::getSuperUserLogin => No replacement
\Piwik\Piwik::getSuperUserLogin => No replacement, returns the userLogin of the first Super User we find in the database
\Piwik\Piwik::getSuperUserEmail => No replacement, returns an empty string from now on
\Piwik\Access::getSuperUserLogin => No replacement, returns the userLogin of the first Super User we find in the databaseConfig Super User
As mentioned, the Super User was defined in the config and you have accessed the Super User’s data either by using a convenient method like Piwik::getSuperUserLogin or directly via the Config object as follows :
\Piwik\Config::getInstance->superUser
As the config user is no longer defined in the config this will no longer work in the future. To stay backward compatible we return the first super user found in the database. This is not necessarily always the same user. So if you have used the super user login in some way in your plugin, make sure you are using the new function such as Piwik::getSuperUserLogin
Extended Auth Interface
The last change affects plugins who specify their own Authentication mechanism, for instance when using the custom LoginLDAP plugin. From now on the interface \Piwik\Auth (https://github.com/piwik/piwik/blob/master/core/Auth.php) requires the methods setTokenAuth and setLogin. There is no backward compatibility layer but we had a look at some plugins defining a custom Authentication adapter to make sure those methods are already defined there as expected.
For another example of a Login plugin, check out the LoginHttpAuth plugin on the Marketplace.
After updating the plugin
After you have made changes in your plugin to keep it compatible with Piwik 2.1, your plugin will no longer work with previous Piwik versions. Therefore you should define the minimum required version in your plugin.json file as follows :
"require": {
"piwik": ">=2.1"
}Summary
Piwik 2.1 introduces some changes in the Piwik Core APIs. This blog post explains how to modify any Plugins compatible with Piwik 2.0 to be compatible with Piwik 2.1. Thank you for taking the time to update your plugins !
Let us know if you have any feedback. Happy hacking !
PS : if you use the Web Analytics APIs and the Web Tracking APIs, we guarantee that we will support backwards compatibility of our Web APIs.