
Recherche avancée
Autres articles (59)
-
Demande de création d’un canal
12 mars 2010, parEn fonction de la configuration de la plateforme, l’utilisateur peu avoir à sa disposition deux méthodes différentes de demande de création de canal. La première est au moment de son inscription, la seconde, après son inscription en remplissant un formulaire de demande.
Les deux manières demandent les mêmes choses fonctionnent à peu près de la même manière, le futur utilisateur doit remplir une série de champ de formulaire permettant tout d’abord aux administrateurs d’avoir des informations quant à (...) -
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. -
MediaSPIP Core : La Configuration
9 novembre 2010, parMediaSPIP Core fournit par défaut trois pages différentes de configuration (ces pages utilisent le plugin de configuration CFG pour fonctionner) : une page spécifique à la configuration générale du squelettes ; une page spécifique à la configuration de la page d’accueil du site ; une page spécifique à la configuration des secteurs ;
Il fournit également une page supplémentaire qui n’apparait que lorsque certains plugins sont activés permettant de contrôler l’affichage et les fonctionnalités spécifiques (...)
Sur d’autres sites (8352)
-
ffmpeg/libav - how to wirte video files with valid pts
9 mai 2017, par Kai RohmerI’m currently trying the write out a real time rendered video into a h264 encoded file. After reading a lot of (mostly) old samples and the few class references they call a documentation, I manager to write my video file and I’m also able to read it. Unfortunately, I need some metadata for each frame but I’m not having a constant frame rate. So my intension was to start with the presentation timestamps to "frametime" during recoding. But after all I tried I get no pts while reading the the file (pts stays -9223372036854775808). Before wring a lot of code, here are the basics steps I’m doing. I’m probably using the wrong container or I’m missing to set a flag and you will notice it right away.
// open a AVFormatContext
avformat_alloc_output_context2(&m_FormatContext, nullptr, "avi", m_FileName.c_str());
// open a stream
m_VideoStream = avformat_new_stream(m_FormatContext, avcodec_find_encoder(AV_CODEC_ID_H264));
// setup the codec context (including bitrate, frame size, ...)
m_CodecContext = m_VideoStream ->codec;
m_CodecContext->coder_type = FF_CODER_TYPE_VLC;
m_CodecContext->time_base = AVRational{1, 120}; // I expect 20-60 Hz
m_CodecContext->pix_fmt = AV_PIX_FMT_YUV420P;
m_CodecContext->color_range = AVCOL_RANGE_JPEG;
...
av_opt_set(m_CodecContext->priv_data, "preset", "ultrafast", 0);
av_opt_set(m_CodecContext->priv_data, "tune", "zerolatency,fastdecode", 0);
// set the same time_base to the stream
m_VideoStream ->time_base = m_CodecContext->time_base;
// open the codec
avcodec_open2(m_CodecContext, m_CodecContext->codec, nullptr);
// open file and write header
avio_open(&m_FormatContext->pb, m_FileName.c_str(), AVIO_FLAG_WRITE);
avformat_write_header(m_FormatContext, nullptr);
// then in a loop:
// render frame, convert RGBA to YUV frame, set the frames pts (timestamp is double application time in seconds)
frameToEncode.pts = int64_t(timestamp / av_q2d(m_VideoStream->time_base));
av_init_packet(m_EncodedPacket);
avcodec_encode_video2(m_CodecContext, m_EncodedPacket, frameToEncode, &got_output);
// check packet infos
//m_EncodedPacket->pts equals frameToEncode.pts
m_EncodedPacket->dts = AV_NOPTS_VALUE; // also tried incrementing numbers, or zero
m_EncodedPacket->stream_index = m_Stream->index;
m_EncodedPacket->duration = 0;
m_EncodedPacket->pos = -1;
m_EncodedPacket->flags = 0;
m_EncodedPacket->flags |= AV_PKT_FLAG_KEY; // read that somewhere
// write the packet to stream
av_interleaved_write_frame(m_FormatContext, m_EncodedPacket);
// after the loop
// I encode delayed frames and write the trailer
av_write_trailer(m_FormatContext);Thats pretty much it. I’m not getting what is missing. Since I have some meta data per frame I tried to add side data to each package but this data also disapered after reading from file. If decode the packets directly (instead of writing them to file, the data is there)
I’m quite sure the problem is with the encoding. I managed to decode the big buck bunny movie in which case i got valid pts values.
Thanks a lot for your help !
-
ffmpeg quits if one output stream fails - can this be prevented ? [duplicate]
5 décembre 2017, par Caius JardThis question already has an answer here :
I’m responsible for maintaining a device that streams a live webcam feed to a remote relay server, and simultaneously writes a version of the stream to the local disk. It does this by a single instance of ffmpeg that has two outputs - one to the local disk, and one over rtsp to the streaming server
I’m encountering a problem where by if the streaming server disconencts for any reason, ffmpeg quits. I’m not really bothered if the live stream is lost, but it’s a big problem that the local recording is lost also - it’s not a huge detriment to the particular business process if it cannot be watched live, but losing the locally stored copy is a disaster
ffmpeg is started with a command line similar to :
ffmpeg -thread_queue_size 4096 -async 1 -f v4l2
-input_format mjpeg -framerate 30 -video_size 1280x720
-i /dev/video0 -thread_queue_size 4096 -async 1 -f alsa
-i plughw:CARD=Set,DEV=0 -r 30 -c:a aac -b:a 96k -c:v h264 -b:v 983040
-profile:v baseline -preset veryfast -pix_fmt yuv420p
-f tee -map 0:v -map 1:a
[f=matroska]'/var/recordings/yyyy-mm-dd/backup.mkv'|
[f=rtsp:rtsp_transport=tcp]rtsp://streamingserver.com:1234/session.sdp`Is there any way (command line switch etc) that ffmpeg can be made to carry on if an output stream is lost, rather than quitting ?
-
FFMpeg : write h264 stream to mp4 container without changes
3 mars 2017, par BumblebeeGood day.
For brevity, the code omits error handling and memory management.
I want to capture h264 video stream and pack it to mp4 container without changes. Since i don’t control the source of stream, i can not make assumptions about stream structure. In this way i must probe input stream.
AVProbeData probeData;
probeData.buf_size = s->BodySize();
probeData.buf = s->GetBody();
probeData.filename = "";
AVInputFormat* inFormat = av_probe_input_format(&probeData, 1);This code correctly defines h264 stream.
Next, i create input format context,
unsigned char* avio_input_buffer = reinterpret_cast<unsigned> (av_malloc(AVIO_BUFFER_SIZE));
AVIOContext* avio_input_ctx = avio_alloc_context(avio_input_buffer, AVIO_BUFFER_SIZE,
0, this, &read_packet, NULL, NULL);
AVFormatContext* ifmt_ctx = avformat_alloc_context();
ifmt_ctx->pb = avio_input_ctx;
int ret = avformat_open_input(&ifmt_ctx, NULL, inFormat, NULL);
</unsigned>set image size,
ifmt_ctx->streams[0]->codec->width = ifmt_ctx->streams[0]->codec->coded_width = width;
ifmt_ctx->streams[0]->codec->height = ifmt_ctx->streams[0]->codec->coded_height = height;create output format context,
unsigned char* avio_output_buffer = reinterpret_cast<unsigned>(av_malloc(AVIO_BUFFER_SIZE));
AVIOContext* avio_output_ctx = avio_alloc_context(avio_output_buffer, AVIO_BUFFER_SIZE,
1, this, NULL, &write_packet, NULL);
AVFormatContext* ofmt_ctx = nullptr;
avformat_alloc_output_context2(&ofmt_ctx, NULL, "mp4", NULL);
ofmt_ctx->pb = avio_output_ctx;
AVDictionary* dict = nullptr;
av_dict_set(&dict, "movflags", "faststart", 0);
av_dict_set(&dict, "movflags", "frag_keyframe+empty_moov", 0);
AVStream* outVideoStream = avformat_new_stream(ofmt_ctx, nullptr);
avcodec_copy_context(outVideoStream->codec, ifmt_ctx->streams[0]->codec);
ret = avformat_write_header(ofmt_ctx, &dict);
</unsigned>Initialization is done. Further there is a shifting packets from h264 stream to mp4 container. I dont calculate pts and dts, because source packet has AV_NOPTS_VALUE in them.
AVPacket pkt;
while (...)
{
ret = av_read_frame(ifmt_ctx, &pkt);
ret = av_interleaved_write_frame(ofmt_ctx, &pkt);
av_free_packet(&pkt);
}Further i write trailer and free allocated memory. That is all. Code works and i got playable mp4 file.
Now the problem : the stream characteristics of the resulting file is not completely consisent with the characteristics of the source stream. In particular, fps and bitrate is higher than it should be.
As sample, below is output ffplay.exe for source stream
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'd:/movies/source.mp4':0/0
Metadata:
major_brand : isom
minor_version : 1
compatible_brands: isom
creation_time : 2014-04-14T13:03:54.000000Z
Duration: 00:00:58.08, start: 0.000000, bitrate: 12130 kb/s
Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661),yuv420p, 1920x1080, 12129 kb/s, 25 fps, 25 tbr, 25 tbn, 50 tbc (default)
Metadata:
handler_name : VideoHandler
Switch subtitle stream from #-1 to #-1 vq= 1428KB sq= 0B f=0/0
Seek to 49% ( 0:00:28) of total duration ( 0:00:58) B f=0/0
30.32 M-V: -0.030 fd= 87 aq= 0KB vq= 1360KB sq= 0B f=0/0and for resulting stream (contains part of source stream)
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'd:/movies/target.mp4':f=0/0
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1iso6mp41
encoder : Lavf57.56.101
Duration: 00:00:11.64, start: 0.000000, bitrate: 18686 kb/s
Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 1920x1080, 18683 kb/s, 38.57 fps, 40 tbr, 90k tbn, 50 tbc (default)
Metadata:
handler_name : VideoHandler
Switch subtitle stream from #-1 to #-1 vq= 2309KB sq= 0B f=0/0
5.70 M-V: 0.040 fd= 127 aq= 0KB vq= 2562KB sq= 0B f=0/0So there is a question, what i missed when copying stream ? I will be grateful for any help.
Best regards