
Recherche avancée
Médias (1)
-
Bug de détection d’ogg
22 mars 2013, par
Mis à jour : Avril 2013
Langue : français
Type : Video
Autres articles (55)
-
Dépôt de média et thèmes par FTP
31 mai 2013, parL’outil MédiaSPIP traite aussi les média transférés par la voie FTP. Si vous préférez déposer par cette voie, récupérez les identifiants d’accès vers votre site MédiaSPIP et utilisez votre client FTP favori.
Vous trouverez dès le départ les dossiers suivants dans votre espace FTP : config/ : dossier de configuration du site IMG/ : dossier des média déjà traités et en ligne sur le site local/ : répertoire cache du site web themes/ : les thèmes ou les feuilles de style personnalisées tmp/ : dossier de travail (...) -
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 ;
-
Changer le statut par défaut des nouveaux inscrits
26 décembre 2015, parPar défaut, lors de leur inscription, les nouveaux utilisateurs ont le statut de visiteur. Ils disposent de certains droits mais ne peuvent pas forcément publier leurs contenus eux-même etc...
Il est possible de changer ce statut par défaut. en "rédacteur".
Pour ce faire, un administrateur webmestre du site doit aller dans l’espace privé de SPIP en ajoutant ecrire/ à l’url de son site.
Une fois dans l’espace privé, il lui faut suivre les menus configuration > Interactivité et activer (...)
Sur d’autres sites (5888)
-
FFMPEG remux sample without writing to file
31 janvier 2020, par DanielLet’s consider this very nice and easy to use remux sample by horgh.
I’d like to achieve the same task : convert an RTSP H264 encoded stream to a fragmented MP4 stream.
This code does exactly this task.However I don’t want to write the mp4 onto disk at all, but I need to get a byte buffer or array in C with the contents that would normally written to disk.
How is that achievable ?
This sample uses vs_open_output to define the output format and this function needs an output url.If I would get rid of outputting the contents to disk, how shall I modify this code ?
Or there might be better alternatives as well, those are also welcomed.Update :
As szatmary recommended, I have checked his example link.
However as I stated in the question I need the output as buffer instead of a file.
This example demonstrates nicely how can I read my custom source and give it to ffmpeg.What I need is how can open the input as standard (with avformat_open_input) then do my custom modification with the packets and then instead writing to file, write to a buffer.
What have I tried ?
Based on szatmary’s example I created some buffers and initialization :
uint8_t *buffer;
buffer = (uint8_t *)av_malloc(4096);
format_ctx = avformat_alloc_context();
format_ctx->pb = avio_alloc_context(
buffer, 4096, // internal buffer and its size
1, // write flag (1=true, 0=false)
opaque, // user data, will be passed to our callback functions
0, // no read
&IOWriteFunc,
&IOSeekFunc
);
format_ctx->flags |= AVFMT_FLAG_CUSTOM_IO;
AVOutputFormat * const output_format = av_guess_format("mp4", NULL, NULL);
format_ctx->oformat = output_format;
avformat_alloc_output_context2(&format_ctx, output_format,
NULL, NULL)Then of course I have created ’IOWriteFunc’ and ’IOSeekFunc’ :
static int IOWriteFunc(void *opaque, uint8_t *buf, int buf_size) {
printf("Bytes read: %d\n", buf_size);
int len = buf_size;
return (int)len;
}
static int64_t IOSeekFunc (void *opaque, int64_t offset, int whence) {
switch(whence){
case SEEK_SET:
return 1;
break;
case SEEK_CUR:
return 1;
break;
case SEEK_END:
return 1;
break;
case AVSEEK_SIZE:
return 4096;
break;
default:
return -1;
}
return 1;
}Then I need to write the header to the output buffer, and the expected behaviour here is to print "Bytes read : x" :
AVDictionary * opts = NULL;
av_dict_set(&opts, "movflags", "frag_keyframe+empty_moov", 0);
av_dict_set_int(&opts, "flush_packets", 1, 0);
avformat_write_header(output->format_ctx, &opts)In the last line during execution, it always runs into segfault, here is the backtrace :
#0 0x00007ffff7a6ee30 in () at /usr/lib/x86_64-linux-gnu/libavformat.so.57
#1 0x00007ffff7a98189 in avformat_init_output () at /usr/lib/x86_64-linux-gnu/libavformat.so.57
#2 0x00007ffff7a98ca5 in avformat_write_header () at /usr/lib/x86_64-linux-gnu/libavformat.so.57
...The hard thing for me with the example is that it uses avformat_open_input.
However there is no such thing for the output (no avformat_open_ouput).
Update2 :
I have found another example for reading : doc/examples/avio_reading.c.
There are mentions of a similar example for writing (avio_writing.c), but ffmpeg does not have this available (at least in my google search).
Is this task really this hard to solve ? standard rtsp input to custom avio ?
Fortunately ffmpeg.org is down. Great.
-
FFMPEG PHP enter command lines ?
3 mai 2019, par RobertYou will have to excuse me I have been spending the past 2 days reading through old FFMPEG posts for an answer but did little but confuse myself.
It seems from what I read FFMPEG-PHP wrappers aren’t supported anymore ??? and to be honest they don’t seem like the proper way of learning how to incorporate it with PHP as there is a whole lot more help for command line FFMPEG usage and the FFMPEG-PHP wrapper usage looks nothing like the command line as far as I can tell.So I have 2 questions on using ffmpeg with PHP. So we are on the same page I posted a little info below.
I downloaded FFMPEG static for windows 64bit.
I then ran (in composer)$ composer require php-ffmpeg/php-ffmpeg
in my vendor folder i have the following path.
vendor\ffmpeg-20190429-ac551c5-win64-static\bin
if I open the command prompt in that folder and type FFMPEG I get.
ffmpeg version N-93710-gac551c54b1 Copyright (c) 2000-2019 the FFmpeg
developers
built with gcc 8.3.1 (GCC) 20190414
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-
fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-
libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --
enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg
--enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --
enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack
--enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --
enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-
libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa
--enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --
enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-
nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
libavutil 56. 26.100 / 56. 26.100
libavcodec 58. 52.100 / 58. 52.100
libavformat 58. 27.103 / 58. 27.103
libavdevice 58. 7.100 / 58. 7.100
libavfilter 7. 50.100 / 7. 50.100
libswscale 5. 4.100 / 5. 4.100
libswresample 3. 4.100 / 3. 4.100
libpostproc 55. 4.100 / 55. 4.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...So I’m pretty sure FFMPEG is installed which was my goal.
Now on my PHP side here is where I am at, and I’m not sure how this works.
1ST QUESTION. Do I need to save my $_POST files to the drive before manipulating them ? Or can I use the $file and $filep as is ? I don’t really want to store those files, only the output.
My SLIM code.
$app->post('/telestrator', function(Request $request, Response $response)
{
$response = array();
if (isset ($_POST['ID']) && ($_POST['position']) && $_FILES['video']
['error'] === UPLOAD_ERR_OK && $_FILES['image']['error'] ===
UPLOAD_ERR_OK) {
$file = $_FILES['video']['tmp_name'];
$filep = $_FILES['image']['tmp_name'];
$time = $_POST['position'];
$position = msToTime($time);
$filetime = round(microtime(true) * 1000);
$outputfolder = 'teletemp/';
$ID = $_POST['ID'];
$tempvid = $ID . 'tempvid' . 'mp4';
$finalvid = $ID . $filetime . 'mp4';
$ffmpegpath = "public/ffmpeg.exe";
echo "Starting ffmpeg...\n\n";
echo shell_exec("$ffmpegpath -loop 1 -i $filep -c:v libx264 -t 3 -pix_fmt
yuv420p \"$outputfolder.\" $tempvid /");
echo shell_exec("$ffmpegpath -i $file -t $position -c copy
\"$outputfolder\"
small-1.mp4 -ss $position -codec copy \"$outputfolder\" small-2.mp4 ");
echo shell_exec("$ffmpegpath -i small-1.mp4 -i $tempvid.mp4 -i small-
2.mp4 \
-filter_complex \"[0:v:0][1:v:0][2:v:0]concat=n=3:v=1:a=1[outv]\" \
-map \"[outv]\" $finalvid" );
echo "Done.\n";
$upload = new videouploads();
$desc = 'telestrated video for ' . $ID . $filetime;
$ID = $_POST['ID'];
if ($upload->saveVideoFile($finalvid, getFileExtension($finalvid),
$desc, $ID)) {
$response['error'] = false;
$response['message'] = 'File Uploaded Successfullly';
}
else {
$response['error'] = true;
$response['message'] = 'Required parameters are not available';
}
echo json_encode($response);
}
});
function getFileExtension($file)
{
$path_parts = pathinfo($file);
return $path_parts['extension'];
}
function msToTime($duration) {
$seconds = floor($duration / 1000);
$minutes = floor($seconds / 60);
$hours = floor($minutes / 60);
$milliseconds = $duration % 1000;
$seconds = $seconds % 60;
$minutes = $minutes % 60;
$format = '%02u:%02u:%02u.%03u';
$time = sprintf($format, $hours, $minutes, $seconds, $milliseconds);
return rtrim($time, '0');
}so it’s not running here is my postman. How do I get it to actually run the FFMPEG.
Starting ffmpeg...
Done.
<br />
<b>Notice</b>: Undefined index: extension in
<b>C:\xampp\htdocs\Pathways\public\index.php</b> on line
<b>14741</b>
<br />
{"error":false,"message":"File Uploaded Successfullly"} -
Encoding AAC audio with libav
14 mars 2018, par Michael IVI am trying to encode AAC using FFMPEG C libs. The closest thing I found on SO is this question,but it deals with mp4 container which has aac stream. That’s not what I am trying to do. I am encoding single audio file. Now, FFMPEG example for audio encoding doesn’t show aac and it is not clear if it is enough also for the aac codec. Here is how I do it :
Setup :
AVCodec* mInputAudioCodec = NULL;
AVCodecContext* mInputAudioCodecContext = NULL;
AVPacket* mAudioPacket = NULL;
AVFrame* mAudioInputFrame = NULL;
mInputAudioCodec = avcodec_find_encoder(AV_CODEC_ID_AAC);
if (!mInputAudioCodec)
{
return false;
}
mInputAudioCodecContext = avcodec_alloc_context3(mInputAudioCodec);
if (!mInputAudioCodecContext)
{
return false;
}
mInputAudioCodecContext->bit_rate = 192000;// 64000;
mInputAudioCodecContext->sample_fmt = AV_SAMPLE_FMT_FLTP; AV_SAMPLE_FMT_S16;
// check that a given sample format is supported by the encoder
const enum AVSampleFormat *p = mInputAudioCodec->sample_fmts;
bool formatSupported = false;
while (*p != AV_SAMPLE_FMT_NONE)
{
if (*p == mInputAudioCodecContext->sample_fmt)
{
formatSupported = true;
break;
}
p++;
}
if (formatSupported == false)
{
return false;
}
mInputAudioCodecContext->sample_rate = 48000;
mInputAudioCodecContext->channel_layout = AV_CH_LAYOUT_STEREO;
mInputAudioCodecContext->channels = av_get_channel_layout_nb_channels(mInputAudioCodecContext->channel_layout);
// open codec:
if (avcodec_open2(mInputAudioCodecContext, mInputAudioCodec, NULL) < 0)
{
return false;
}
mAudioPacket = av_packet_alloc();
mAudioInputFrame = av_frame_alloc();
mAudioInputFrame->nb_samples = mInputAudioCodecContext->frame_size;
mAudioInputFrame->format = mInputAudioCodecContext->sample_fmt;
mAudioInputFrame->channel_layout = mInputAudioCodecContext->channel_layout;
mAudioInputFrame->sample_rate = mInputAudioCodecContext->sample_rate;
if (av_frame_get_buffer(mAudioInputFrame, 0) < 0)
{
return false;
}
mFileOut = fopen("audio.aac","wb");Encoding :
For the simplicity, I encode synthetic frames,just like in FFMPEG example.
FLTP is planar format,so I write dummy data into two separate buffers.int ret = 0;
ret = av_frame_make_writable(mAudioInputFrame);
if (ret < 0)
{
return;
}
//generate sound data:
float* samples0 = (float*)mAudioInputFrame->data[0];
float* samples1 = (float*)mAudioInputFrame->data[1];
float t = 0;
float tincr = 2 * M_PI * 440.0f / mInputAudioCodecContext->sample_rate;
for (int j = 0; j < mInputAudioCodecContext->frame_size; j++)
{
*samples0 = (sin(t) * 10000);
*samples1 = (sin(t) * 10000);
samples0++;
samples1++;
t += tincr;
}
av_init_packet(mAudioPacket);
mAudioPacket->data = NULL;
mAudioPacket->size = 0;
ret = avcodec_send_frame(mInputAudioCodecContext, mAudioInputFrame);
if (ret < 0)
{
fprintf(stderr, "Error sending the frame to the encoder\n");
}
/* read all the available output packets (in general there may be any
* number of them */
while (ret >= 0)
{
ret = avcodec_receive_packet(mInputAudioCodecContext, mAudioPacket);
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
{
return;
}
else if (ret < 0)
{
return;
}
fwrite(mAudioPacket->data, 1, mAudioPacket->size, mFileOut);
}
av_packet_unref(mAudioPacket);The encoding session performs ok, avcodec lib doesn’t spit any warnings or errors. But the resulting .aac file is not opened neither by VLC nor by any other audio player. It is corrupted. I ran FFProbe on the file and here is what it says :
[aac @ 000000000274b840] Format aac detected only with low score of 1,
misdetection possible ! [aac @ 00000000026fb2e0] More than one AAC RDB
per ADTS frame is not implemented. Update your FFmpeg version to the
newest one from Git. If the problem still occurs, it means that your
file has a feature which has not been implemented. [aac @
00000000026fb2e0] Sample rate index in program config element does not
match the sample rate index configured by the container. [aac @
00000000026fb2e0] Inconsistent channel configuration. [aac @
00000000026fb2e0] get_buffer() failed [aac @ 00000000026fb2e0] channel
element 2.15 is not allocated [aac @ 00000000026fb2e0] Assuming an
incorrectly encoded 7.1 channel layout instead of a spec-compliant
7.1(wide) layout, use -strict 1 to decode according to the specification instead. [aac @ 00000000026fb2e0] Multiple frames in a
packet. [aac @ 00000000026fb2e0] Number of scalefactor bands in group
(53) exceeds limit (51). [aac @ 00000000026fb2e0] channel element 2.1
is not allocated [aac @ 000000000274b840] decoding for stream 0 failed
[aac @ 000000000274b840] Estimating duration from bitrate, this may be
inaccurate [aac @ 000000000274b840] Could not find codec parameters
for stream 0 (Audio : aac (SSR), stereo, fltp, 254 kb/s) : unspecified
sample rate Consider increasing the value for the ’analyzeduration’
and ’probesize’ options Input #0, aac, from ’audio.aac’ : Duration :
00:00:03.21, bitrate : 254 kb/s
Stream #0:0 : Audio : aac (SSR), stereo, fltp, 254 kb/sWhat am I doing wrong here ?