
Recherche avancée
Médias (91)
-
Chuck D with Fine Arts Militia - No Meaning No
15 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Paul Westerberg - Looking Up in Heaven
15 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Le Tigre - Fake French
15 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Thievery Corporation - DC 3000
15 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Dan the Automator - Relaxation Spa Treatment
15 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Gilberto Gil - Oslodum
15 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
Autres articles (93)
-
Amélioration de la version de base
13 septembre 2013Jolie sélection multiple
Le plugin Chosen permet d’améliorer l’ergonomie des champs de sélection multiple. Voir les deux images suivantes pour comparer.
Il suffit pour cela d’activer le plugin Chosen (Configuration générale du site > Gestion des plugins), puis de configurer le plugin (Les squelettes > Chosen) en activant l’utilisation de Chosen dans le site public et en spécifiant les éléments de formulaires à améliorer, par exemple select[multiple] pour les listes à sélection multiple (...) -
Emballe médias : à quoi cela sert ?
4 février 2011, parCe plugin vise à gérer des sites de mise en ligne de documents de tous types.
Il crée des "médias", à savoir : un "média" est un article au sens SPIP créé automatiquement lors du téléversement d’un document qu’il soit audio, vidéo, image ou textuel ; un seul document ne peut être lié à un article dit "média" ; -
XMP PHP
13 mai 2011, parDixit Wikipedia, XMP signifie :
Extensible Metadata Platform ou XMP est un format de métadonnées basé sur XML utilisé dans les applications PDF, de photographie et de graphisme. Il a été lancé par Adobe Systems en avril 2001 en étant intégré à la version 5.0 d’Adobe Acrobat.
Étant basé sur XML, il gère un ensemble de tags dynamiques pour l’utilisation dans le cadre du Web sémantique.
XMP permet d’enregistrer sous forme d’un document XML des informations relatives à un fichier : titre, auteur, historique (...)
Sur d’autres sites (17848)
-
Creating video from single long audio and single image then created video not playing
25 février 2021, par Mukul KashyapI am creating a video from single audio and single image and it is fine when the audio length less than 10 seconds but when the audio length exceeds 10 seconds then video not playing. I am using FFmpeg to create video using shell_exec().
The video is fine when I directly runs the FFmpeg command on the terminal but the only issue comes with the shell_exec command.


This command I am using -


ffmpeg -loop 1 -f image2 -i $this->img_url -i $this->audio_url -vf scale=1920*1080 -pix_fmt yuv420p -vcodec libx264 -shortest ".$video_local_dir.$video_name ;


Please help me to fix this issue


Thanks.


-
How to reduce time while writing to output stream
9 février 2021, par SummitI am streaming the render ouput of a opengl application using mpegts.The issue that i am facing is that the time taken to encode the frame is quite long.


The application renders at 60 fps with frame size of 1920 X 1080 , the frame data of the application is pushed to a std::queue.


This is the process for ffmpeg.


I initialize the stream like this.

 streamerUpd.InitUPD("udp://127.0.0.1:1234", 1920, 1080, rings_);

int StreamUPD::InitUPD(const char* url, int width, int height, std::shared_ptr<ringbuffer2> rings)
{

 rings_ = rings;
 width_ = width;
 height_ = height;
 filename = url;
 int ret;
 av_dict_set(&opt, "pkt_size", "1316", 0);
 
 
 avformat_alloc_output_context2(&oc, nullptr, "mpegts", filename);
 if (!oc) {
 return 1;
 }

 fmt = oc->oformat;
 /* Add the audio and video streams using the default format codecs
 * and initialize the codecs. */
 if (fmt->video_codec != AV_CODEC_ID_NONE) {
 add_stream(&video_st, oc, &video_codec, fmt->video_codec);
 have_video = 1;
 encode_video = 1;
 }

 /* Write the stream header, if any. */
 ret = avformat_write_header(oc, &opt);
 if (ret < 0) {
 fprintf(stderr, "Error occurred when opening output file: %s\n",
 av_err2str(ret));
 return 1;
 }
 thr = std::thread(&StreamUPD::output_result, this);
 return 0;
}
</ringbuffer2>


////////////////////////////////////////////////////////////////////////////////////////


// Add the output stream


void StreamUPD::add_stream(OutputStream* ost, AVFormatContext* oc, AVCodec** codec, enum AVCodecID codec_id)
{
 AVCodecContext* c;
 int i;
 /* find the encoder */
 *codec = avcodec_find_encoder(codec_id);
 if (!(*codec)) {
 fprintf(stderr, "Could not find encoder for '%s'\n",
 avcodec_get_name(codec_id));
 exit(1);
 }
 ost->st = avformat_new_stream(oc, NULL);
 if (!ost->st) {
 fprintf(stderr, "Could not allocate stream\n");
 exit(1);
 }
 ost->st->id = oc->nb_streams - 1;
 c = avcodec_alloc_context3(*codec);
 if (!c) {
 fprintf(stderr, "Could not alloc an encoding context\n");
 exit(1);
 }
 ost->enc = c;
 switch ((*codec)->type) {
 case AVMEDIA_TYPE_VIDEO:
 c->codec_id = codec_id;
 c->bit_rate = 400000;

 /* Resolution must be a multiple of two. */
 c->width = width_;
 c->height = height_;
 /* timebase: This is the fundamental unit of time (in seconds) in terms
 * of which frame timestamps are represented. For fixed-fps content,
 * timebase should be 1/framerate and timestamp increments should be
 * identical to 1. */
 ost->st->time_base = { 1, STREAM_FRAME_RATE };
 c->time_base = ost->st->time_base;
 c->gop_size = 12; /* emit one intra frame every twelve frames at most */
 c->pix_fmt = STREAM_PIX_FMT;
 
 if (c->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
 /* just for testing, we also add B-frames */
 qDebug() << "This is MPEG2VIDEO Frame";
 c->max_b_frames = 2;
 
 }
 if (c->codec_id == AV_CODEC_ID_MPEG1VIDEO) {
 /* Needed to avoid using macroblocks in which some coeffs overflow.
 * This does not happen with normal video, it just happens here as
 * the motion of the chroma plane does not match the luma plane. */
 c->mb_decision = 2;
 }
 break;
 default:
 break;
 }
 /* Some formats want stream headers to be separate. */
 if (oc->oformat->flags & AVFMT_GLOBALHEADER)
 c->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
}



//////////////////////////////////////////////////////////////////////////////////


// Open the video


void StreamUPD::open_video(AVFormatContext* oc, AVCodec* codec, OutputStream* ost, AVDictionary* opt_arg)
 {
 int ret;
 AVCodecContext* c = ost->enc;
 AVDictionary* opt = NULL;
 av_dict_copy(&opt, opt_arg, 0);
 /* open the codec */
 ret = avcodec_open2(c, codec, &opt);
 av_dict_free(&opt);
 if (ret < 0) {
 fprintf(stderr, "Could not open video codec: %s\n", av_err2str(ret));
 exit(1);
 }
 /* allocate and init a re-usable frame */
 ost->frame = alloc_picture(c->pix_fmt, c->width, c->height);
 if (!ost->frame) {
 fprintf(stderr, "Could not allocate video frame\n");
 exit(1);
 }
 /* If the output format is not YUV420P, then a temporary YUV420P
 * picture is needed too. It is then converted to the required
 * output format. */
 ost->tmp_frame = NULL;
 if (c->pix_fmt != AV_PIX_FMT_YUV420P) {
 ost->tmp_frame = alloc_picture(AV_PIX_FMT_YUV420P, c->width, c->height);
 if (!ost->tmp_frame) {
 fprintf(stderr, "Could not allocate temporary picture\n");
 exit(1);
 }
 }
 /* copy the stream parameters to the muxer */
 ret = avcodec_parameters_from_context(ost->st->codecpar, c);
 if (ret < 0) {
 fprintf(stderr, "Could not copy the stream parameters\n");
 exit(1);
 }
 }



Once i have setup the ffmpeg output stream this is how i am streaming the data.


This function gets the frame data from the std::queue(pixelsQueue) and sends it for encoding.


int StreamUPD::stream_video_frame()
{ 
 ost = &video_st;
 c = ost->enc; 

 /* when we pass a frame to the encoder, it may keep a reference to it
 * internally; make sure we do not overwrite it here */
 if (av_frame_make_writable(ost->frame) < 0)
 exit(1);
 if (!ost->sws_ctx) {
 ost->sws_ctx = sws_getContext(c->width, c->height,
 AV_PIX_FMT_RGB24,
 c->width, c->height,
 c->pix_fmt,
 SWS_FAST_BILINEAR, NULL, NULL, NULL);
 if (!ost->sws_ctx) {
 fprintf(stderr,
 "Could not initialize the conversion context\n");
 exit(1);
 }
 }
 finished_ = true;

 if (pixelsQueue.size() > 0) { 
 if (pixelsQueue.pop(pixels)) {
 fill_yuv_image(ost->sws_ctx, frame_data->pixels_.get(), ost->frame, c->width, c->height);
 ost->frame->pts = ost->next_pts++;
 return write_frame(oc, ost->enc, ost->st, ost->frame);
 }
 }
 return 1;
}



Writing the data to the output stream.


The function avcodec_receive_packet is the one that takes lot of time.


int StreamUPD::write_frame(AVFormatContext* fmt_ctx, AVCodecContext* c,
 AVStream* st, AVFrame* frame)
{
 int ret;
 // send the frame to the encoder
 AVPacket pkt = { 0 };
 ret = avcodec_send_frame(c, frame);
 ret = avcodec_receive_packet(c, &pkt);
 if (ret < 0) {
 fprintf(stderr, "Error sending a frame to the encoder: %s\n",
 av_err2str(ret));
 exit(1);
 }
 
 while (ret >= 0) {
 AVPacket pkt = { 0 };
 ret = avcodec_receive_packet(c, &pkt); // This is the function that takes lot of time
 if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
 break;
 else if (ret < 0) {
 fprintf(stderr, "Error encoding a frame: %s\n", av_err2str(ret));
 exit(1);
 }
 // rescale output packet timestamp values from codec to stream timebase 
 av_packet_rescale_ts(&pkt, c->time_base, st->time_base);
 pkt.stream_index = st->index;
 // Write the compressed frame to the media file. 
 ret = av_interleaved_write_frame(fmt_ctx, &pkt);
 av_packet_unref(&pkt);
 if (ret < 0) {
 fprintf(stderr, "Error while writing output packet: %s\n", av_err2str(ret));
 exit(1);
 }
 }
 return ret == AVERROR_EOF ? 1 : 0;
}



How can i reduce the outputting time while writing the frames to the stream ?


Currently i push more frames in the buffer and the outputting speed is less so the buffer starts to run out of memory in some time.


-
FFMPEG script to merge multiple videos and a background image
3 février 2021, par BitBitI have 30 clips which are different in aspect ratio(like some videos are 10801920(they are vertical) and some are 1280720(horizontal aspect ratio videos). I want to merge all of them but also have a static background image that is of 1920x1080 aspect ratio. The video would be such that all the clips are concatenated but they have a background image(just like those tiktok compilation videos on youtube). Can someone please help me with this program ?