
Recherche avancée
Médias (1)
-
The pirate bay depuis la Belgique
1er avril 2013, par
Mis à jour : Avril 2013
Langue : français
Type : Image
Autres articles (90)
-
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 (...) -
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 ) (...)
Sur d’autres sites (10283)
-
FFmpeg "movflags" > "faststart" causes av_write_trailer() to return -2
30 juin 2016, par williamtroupI’m setting up the format layout for the ideo as follows :
AVOutputFormat* outputFormat = ffmpeg.av_guess_format(null, "output.mp4", null);
AVCodec* videoCodec = ffmpeg.avcodec_find_encoder(outputFormat->video_codec);
AVFormatContext* formatContext = ffmpeg.avformat_alloc_context();
formatContext->oformat = outputFormat;
formatContext->video_codec_id = videoCodec->id;
ffmpeg.avformat_new_stream(formatContext, videoCodec);This is how I am setting up the Codec Context :
AVCodecContext* codecContext = ffmpeg.avcodec_alloc_context3(videoCodec);
codecContext->bit_rate = 400000;
codecContext->width = 1280;
codecContext->height = 720;
codecContext->gop_size = 12;
codecContext->max_b_frames = 1;
codecContext->pix_fmt = videoCodec->pix_fmts[0];
codecContext->codec_id = videoCodec->id;
codecContext->codec_type = videoCodec->type;
codecContext->time_base = new AVRational
{
num = 1,
den = 30
};I’m using the following code to setup the "movflags" > "faststart" option for the header of the video :
AVDictionary* options = null;
int result = ffmpeg.av_dict_set(&options, "movflags", "faststart", 0);
int writeHeaderResult = ffmpeg.avformat_write_header(formatContext, &options);The file is opened and the header is written as follows :
if ((formatContext->oformat->flags & ffmpeg.AVFMT_NOFILE) == 0)
{
int ioOptionResult = ffmpeg.avio_open(&formatContext->pb, "output.mp4", ffmpeg.AVIO_FLAG_WRITE);
}
int writeHeaderResult = ffmpeg.avformat_write_header(formatContext, &options);After this, I write each video frame as follows :
outputFrame->pts = frameIndex;
packet.flags |= ffmpeg.AV_PKT_FLAG_KEY;
packet.pts = frameIndex;
packet.dts = frameIndex;
int encodedFrame = 0;
int encodeVideoResult = ffmpeg.avcodec_encode_video2(codecContext, &packet, outputFrame, &encodedFrame);
if (encodedFrame != 0)
{
packet.pts = ffmpeg.av_rescale_q(packet.pts, codecContext->time_base, m_videoStream->time_base);
packet.dts = ffmpeg.av_rescale_q(packet.dts, codecContext->time_base, m_videoStream->time_base);
packet.stream_index = m_videoStream->index;
if (codecContext->coded_frame->key_frame > 0)
{
packet.flags |= ffmpeg.AV_PKT_FLAG_KEY;
}
int writeFrameResult = ffmpeg.av_interleaved_write_frame(formatContext, &packet);
}After that, I write the trailer :
int writeTrailerResult = ffmpeg.av_write_trailer(formatContext);
However, writeTrailerResult is always -2. I’m been looking into this problem for days and cannot figure out what the problem is.
The DLLs used for the AutoGen library are :
avcodec-56.dll
avdevice-56.dll
avfilter-5.dll
avformat-56.dll
avutil-54.dll
postproc-53.dll
swresample-1.dll
swscale-3.dll -
ffmpeg : split mp3, encode aac and join produce artifacts and empty space
18 juin 2016, par aganeiroSource mp3
ffprobe -show_frames -select_streams a -print_format csv -show_entries
frame=index,pkt_dts_time ~/demo_files/000.orig.5352357791787324393.mp3
frame,0.000000
frame,0.026122
frame,0.052245
frame,0.078367every part I make with command, -ss position and -t time I got and calculate from previous ffprobe output
/home/xxx/bin/ffmpeg -analyzeduration 50000000 -probesize 50000000
-ss 0.000000 -i /home/xxx/demo_files/000.orig.5352357791787324393.mp3
-s 0 -t 0.926276 -flags +global_header -c:a libfdk_aac -strict -2
-b:a 64k -ac 2 -ar 44100 -vn -f mpegts -y /tmp/p0.ts
/home/xxx/bin/ffmpeg -analyzeduration 50000000 -probesize 50000000
-ss 1.018776 -i /home/xxx/demo_files/000.orig.5352357791787324393.mp
-s 0 -t 0.900153 -flags +global_header -c:a libfdk_aac -strict -2
-b:a 64k -ac 2 -ar 44100 -vn -f mpegts -y /tmp/p1.tsit’s produce
[mp3 @ 0x39ca980] Estimating duration from bitrate, this may be inaccurate
Input #0, mp3, from '/home/xxx/demo_files/000.orig.5352357791787324393.mp3':
Duration: 00:05:17.20, start: 0.000000, bitrate: 320 kb/s
Stream #0:0: Audio: mp3, 44100 Hz, stereo, s16p, 320 kb/s
[mpegts @ 0x39ccea0] Using AVStream.codec to pass codec
parameters to muxers is deprecated, use AVStream.codecpar instead.
[mpegts @ 0x39ccea0] frame size not set
Output #0, mpegts, to '/tmp/p0.ts':
Metadata:
encoder : Lavf57.38.100
Stream #0:0: Audio: aac (libfdk_aac), 44100 Hz, stereo, s16, 64 kb/s
Metadata:
encoder : Lavc57.46.100 libfdk_aac
Stream mapping:
Stream #0:0 -> #0:0 (mp3 (native) -> aac (libfdk_aac))
Press [q] to stop, [?] for help
size= 10kB time=00:00:00.92 bitrate= 92.3kbits/s speed=39.8x
video:0kB audio:8kB subtitle:0kB other streams:0kB global
headers:0kB muxing overhead: 24.619143%
Duration: 00:00:00.63, start: 1.400000, bitrate: 127 kb/sPart info
ffmpeg -hide_banner -i /tmp/p0.ts 2>&1 |grep -P 'Duration|Stream'
Duration: 00:00:00.95, start: 1.400000, bitrate: 90 kb/s
Stream #0:0[0x100]: Audio: aac (LC) ([15][0][0][0] / 0x000F),
44100 Hz, stereo, fltp, 68 kb/sThen I join all parts together with
/home/xxx/bin/ffmpeg -i /tmp/p0.ts -i /tmp/p1.ts -i /tmp/p2.ts
-i /tmp/p3.ts -i /tmp/p4.ts -i /tmp/p5.ts -filter_complex
"[0:a]asetpts=PTS-STARTPTS[a0];[1:a]asetpts=PTS-STARTPTS[a1];
[2:a]asetpts=PTS-STARTPTS[a2];[3:a]asetpts=PTS-STARTPTS[a3];
[4:a]asetpts=PTS-STARTPTS[a4];[5:a]asetpts=PTS-STARTPTS[a5];
[a0][a1][a2][a3][a4][a5] concat=n=6:v=0:a=1 [a]"
-map [a] -strict experimental -fflags +genpts -flags +global_header
-c libfdk_aac -bsf:a aac_adtstoasc -y /tmp/res.m4awaveform of original and joined on the left
So, as you can see joined have delays and waveforms starte later. Why ? maybe it depens that all encoded parts have start time 1.400000, ?? How to set start time to 0 on encode ?
Also I tried to cut empty space on joining with filter_complex but result stil not good and contains artifacts because trim position looks different in every part.
/home/xxx/bin/ffmpeg -i /tmp/p0.ts -i /tmp/p1.ts -i /tmp/p2.ts
-i /tmp/p3.ts -i /tmp/p4.ts -i /tmp/p5.ts -filter_complex
"[0:a]atrim=0.020000,asetpts=PTS-STARTPTS[a0];
[1:a]atrim=0.020000,asetpts=PTS-STARTPTS[a1];
[2:a]atrim=0.020000,asetpts=PTS-STARTPTS[a2];
[3:a]atrim=0.020000,asetpts=PTS-STARTPTS[a3];
[4:a]atrim=0.020000,asetpts=PTS-STARTPTS[a4];
[5:a]atrim=0.020000,asetpts=PTS-STARTPTS[a5];
[a0][a1][a2][a3][a4][a5] concat=n=6:v=0:a=1 [a]"
-map [a] -strict experimental -fflags +genpts
-flags +global_header -c libfdk_aac -bsf:a aac_adtstoasc
-y /tmp/res.m4aWhyyyy and how to solve it ?
-
Creating GIF from QImages with ffmpeg
17 août 2016, par SierraI would like to generate GIF from QImage, using ffmpeg - all of that programmatically (C++). I’m working with Qt 5.6 and the last build of ffmpeg (build git-0a9e781 (2016-06-10).
I’m already able to convert these QImage in .mp4 and it works. I tried to use the same principle for the GIF, changing format pixel and codec. GIF is generated with two pictures (1 second each), in 15 FPS.
## INITIALIZATION
#####################################################################
// Filepath : "C:/Users/.../qt_temp.Jv7868.gif"
// Allocating an AVFormatContext for an output format...
avformat_alloc_output_context2(formatContext, NULL, NULL, filepath);
...
// Adding the video streams using the default format codecs and initializing the codecs.
stream = avformat_new_stream(formatContext, *codec);
AVCodecContext * codecContext = avcodec_alloc_context3(*codec);
context->codec_id = codecId;
context->bit_rate = 400000;
...
context->pix_fmt = AV_PIX_FMT_BGR8;
...
// Opening the codec...
avcodec_open2(codecContext, codec, NULL);
...
frame = allocPicture(codecContext->width, codecContext->height, codecContext->pix_fmt);
tmpFrame = allocPicture(codecContext->width, codecContext->height, AV_PIX_FMT_RGBA);
...
avformat_write_header(formatContext, NULL);
## ADDING A NEW FRAME
#####################################################################
// Getting in parameter the QImage: newFrame(const QImage & image)
const qint32 width = image.width();
const qint32 height = image.height();
// Converting QImage into AVFrame
for (qint32 y = 0; y < height; y++) {
const uint8_t * scanline = image.scanLine(y);
for (qint32 x = 0; x < width * 4; x++) {
tmpFrame->data[0][y * tmpFrame->linesize[0] + x] = scanline[x];
}
}
...
// Scaling...
if (codec->pix_fmt != AV_PIX_FMT_BGRA) {
if (!swsCtx) {
swsCtx = sws_getContext(codec->width, codec->height,
AV_PIX_FMT_BGRA,
codec->width, codec->height,
codec->pix_fmt,
SWS_BICUBIC, NULL, NULL, NULL);
}
sws_scale(swsCtx,
(const uint8_t * const *)tmpFrame->data,
tmpFrame->linesize,
0,
codec->height,
frame->data,
frame->linesize);
}
frame->pts = nextPts++;
...
int gotPacket = 0;
AVPacket packet = {0};
av_init_packet(&packet);
avcodec_encode_video2(codec, &packet, frame, &gotPacket);
if (gotPacket) {
av_packet_rescale_ts(paket, *codec->time_base, stream->time_base);
paket->stream_index = stream->index;
av_interleaved_write_frame(formatContext, paket);
}But when I’m trying to modify the video codec and pixel format to match with GIF specifications, I’m facing some issues.
I tried several codecs such asAV_CODEC_ID_GIF
andAV_CODEC_ID_RAWVIDEO
but none of them seem to work. During the initialization phase,avcodec_open2()
always returns such kind of errors :Specified pixel format rgb24 is invalid or not supported
Could not open video codec: gifEDIT 17/06/2016
Digging a little bit more,
avcodec_open2()
returns -22 :#define EINVAL 22 /* Invalid argument */
EDIT 22/06/2016
Here are the flags used to compile ffmpeg :
"FFmpeg/Libav configuration: --disable-static --enable-shared --enable-gpl --enable-version3 --disable-w32threads --enable-nvenc --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmfx --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-decklink --enable-zlib"
Did I miss a crucial one for GIF ?
EDIT 27/06/2016
Thanks to Gwen, I have a first output : I setted the
context->pix_fmt
toAV_PIX_FMT_BGR8
. Btw I’m still facing some issues with the generated GIF. It’s not playing and encoding appears to fail.GIF generated in command lines with ffmpeg (left) . . . GIF generated programmatically (right)
It looks like some options are not defined... also may be a wrong conversion between QImage and AVFrame ? I updated the code above. It represents a lot of code, so I tried to stay short. Don’t hesitate to ask more details.
End of EDIT
I’m not really familiar with ffmpeg, any kind of help would be highly appreciated. Thank you.