
Recherche avancée
Médias (3)
-
Elephants Dream - Cover of the soundtrack
17 octobre 2011, par
Mis à jour : Octobre 2011
Langue : English
Type : Image
-
Valkaama DVD Label
4 octobre 2011, par
Mis à jour : Février 2013
Langue : English
Type : Image
-
Publier une image simplement
13 avril 2011, par ,
Mis à jour : Février 2012
Langue : français
Type : Video
Autres articles (111)
-
Personnaliser les catégories
21 juin 2013, parFormulaire de création d’une catégorie
Pour ceux qui connaissent bien SPIP, une catégorie peut être assimilée à une rubrique.
Dans le cas d’un document de type catégorie, les champs proposés par défaut sont : Texte
On peut modifier ce formulaire dans la partie :
Administration > Configuration des masques de formulaire.
Dans le cas d’un document de type média, les champs non affichés par défaut sont : Descriptif rapide
Par ailleurs, c’est dans cette partie configuration qu’on peut indiquer le (...) -
Script d’installation automatique de MediaSPIP
25 avril 2011, parAfin de palier aux difficultés d’installation dues principalement aux dépendances logicielles coté serveur, un script d’installation "tout en un" en bash a été créé afin de faciliter cette étape sur un serveur doté d’une distribution Linux compatible.
Vous devez bénéficier d’un accès SSH à votre serveur et d’un compte "root" afin de l’utiliser, ce qui permettra d’installer les dépendances. Contactez votre hébergeur si vous ne disposez pas de cela.
La documentation de l’utilisation du script d’installation (...) -
Activation de l’inscription des visiteurs
12 avril 2011, parIl est également possible d’activer l’inscription des visiteurs ce qui permettra à tout un chacun d’ouvrir soit même un compte sur le canal en question dans le cadre de projets ouverts par exemple.
Pour ce faire, il suffit d’aller dans l’espace de configuration du site en choisissant le sous menus "Gestion des utilisateurs". Le premier formulaire visible correspond à cette fonctionnalité.
Par défaut, MediaSPIP a créé lors de son initialisation un élément de menu dans le menu du haut de la page menant (...)
Sur d’autres sites (6712)
-
ffmpeg convert any file to any file
28 mai 2015, par VishnuI Want simple command to convert any supported file to any file with little possible video compression.
for example
avi to mp4
mp4 to 3gp
.
.etc..I tried below code
ffmpeg -i infile.flv outfile.3gp
It works for some but for some other like
flv to 3gp
conversion it throws error like below and also output file size is very large than input."Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height"
P:s i compiled with below librareis
./configure --enable-version3 --enable-libopencore-amrnb --enable-libvo-aacenc --enable-libopencore-amrwb --enable-libvpx --enable-libfaac --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-gpl --enable-postproc --enable-nonfree
full response
array(48) {
[0]=>
string(77) "ffmpeg version N-72286-gd9b264b Copyright (c) 2000-2015 the FFmpeg developers"
[1]=>
string(56) " built with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-11)"
[2]=>
string(261) " configuration: --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvpx --enable-libfaac --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-gpl --enable-postproc --enable-nonfree"
[3]=>
string(40) " libavutil 54. 23.101 / 54. 23.101"
[4]=>
string(40) " libavcodec 56. 39.101 / 56. 39.101"
[5]=>
string(40) " libavformat 56. 33.101 / 56. 33.101"
[6]=>
string(40) " libavdevice 56. 4.100 / 56. 4.100"
[7]=>
string(40) " libavfilter 5. 16.101 / 5. 16.101"
[8]=>
string(40) " libswscale 3. 1.101 / 3. 1.101"
[9]=>
string(40) " libswresample 1. 1.100 / 1. 1.100"
[10]=>
string(40) " libpostproc 53. 3.100 / 53. 3.100"
[11]=>
string(32) "Input #0, flv, from 'video.flv':"
[12]=>
string(11) " Metadata:"
[13]=>
string(25) " major_brand : M4V"
[14]=>
string(23) " minor_version : 1"
[15]=>
string(39) " compatible_brands: M4V M4A mp42isom"
[16]=>
string(26) " date : 2008"
[17]=>
string(71) " copyright : © 2008 Blender Foundation | www.bigbuckbunny.org"
[18]=>
string(36) " title : Big Buck Bunny"
[19]=>
string(43) " artist : Peach Open Movie Team"
[20]=>
string(56) " composer : Sacha Goedegebure / Ton Roosendaal"
[21]=>
string(35) " encoder : Lavf55.33.100"
[22]=>
string(59) " Duration: 00:09:56.58, start: 0.058000, bitrate: 663 kb/s"
[23]=>
string(88) " Stream #0:0: Video: h264 (High), yuv420p, 640x360, 24.42 fps, 24 tbr, 1k tbn, 48 tbc"
[24]=>
string(61) " Stream #0:1: Audio: mp3, 44100 Hz, stereo, s16p, 128 kb/s"
[25]=>
string(90) "[h263 @ 0x1ef5f60] The specified picture size of 640x360 is not valid for the H.263 codec."
[26]=>
string(77) "Valid sizes are 128x96, 176x144, 352x288, 704x576, and 1408x1152. Try H.263+."
[27]=>
string(33) "Output #0, 3gp, to 'outfile.3gp':"
[28]=>
string(11) " Metadata:"
[29]=>
string(25) " major_brand : M4V"
[30]=>
string(23) " minor_version : 1"
[31]=>
string(39) " compatible_brands: M4V M4A mp42isom"
[32]=>
string(26) " date : 2008"
[33]=>
string(71) " copyright : © 2008 Blender Foundation | www.bigbuckbunny.org"
[34]=>
string(36) " title : Big Buck Bunny"
[35]=>
string(43) " artist : Peach Open Movie Team"
[36]=>
string(56) " composer : Sacha Goedegebure / Ton Roosendaal"
[37]=>
string(35) " encoder : Lavf55.33.100"
[38]=>
string(60) " Stream #0:0: Video: h263, none, q=2-31, 128 kb/s, 24 fps"
[39]=>
string(13) " Metadata:"
[40]=>
string(42) " encoder : Lavc56.39.101 h263"
[41]=>
string(52) " Stream #0:1: Audio: amr_nb, 0 channels, 128 kb/s"
[42]=>
string(13) " Metadata:"
[43]=>
string(55) " encoder : Lavc56.39.101 libopencore_amrnb"
[44]=>
string(15) "Stream mapping:"
[45]=>
string(54) " Stream #0:0 -> #0:0 (h264 (native) -> h263 (native))"
[46]=>
string(66) " Stream #0:1 -> #0:1 (mp3 (native) -> amr_nb (libopencore_amrnb))"
[47]=>
string(119) "Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height"
} -
How do I use FFMPEG to pipe in a video file and pipe out a converted video file
11 avril 2014, par Ranjit AneeshI have very limited knowledge of FFMPEG.
My use case is that I have a content server with a http url from where I want to pipe in a video file (The video file can be of any format) and I have to convert them to some other format, sometime changing the resolution, and then pipe out and post the video back to the content server.I cannot keep a copy of the video file on the local file system where I run ffmpeg since they can be of large sizes and precious time will get wasted in doing so and then calling ffmpeg for conversion and finally writing back the file to content server. I may have to support both Linux as well as windows
My question is
- Is it possbile for FFMPEG to be able to read a file from an http url
- Is it possbile to pipe in this data in some other way to FFMPEG if 1 is not possible
- Is it possbile to write the data back to a http location by making a ReST put/post call
- If 3 is not possbile is there some other way that ffmpeg can push the data back to the server.
Thanks
-
Encoding YUV file (uncompressed video) to mp4 playable file using H264 encoding with ffmpeg c++ (NOT command line)
20 avril 2023, par devprogMy goal is to encode a yuv file to a playable mp4 file (can be played with VLC) with ffmpeg c++ code.


First I have a source_1920x1080p30.mpg video (compressed) file.
Using ffmpeg CLI I created output_test.yuv file.

ffmpeg -i source_1920x1080p30.mpg -c:v rawvideo -pix_fmt yuv420p output_test.yuv


I used
ffplay -f rawvideo -pixel_format yuv420p -video_size 1920x1080 output_test.yuv
which played well.
Also usedffmpeg -f rawvideo -pix_fmt yuv420p -s:v 1920x1080 -r 30 -i output_test.yuv -c:v libx264 vid.mp4

and the new vid.mp4 was playble.
So I have good yuv file.

I want to encode this output_test.yuv YUV file with ffmpeg by code.
I tested the ffmpeg site encode example ffmpeg site encode example and it was running good.


In that example, the frames are self made inside the code - But I want that the input would be my YUV file.


Becasue I used ffmpeg CLI to convert YUV to mp4 (as noted above) I am sure it can be done by code - but I dont how..


So, I tried to add to their example the use of the methods :
avformat_open_input() & avformat_find_stream_info()


#include 
#include 
#include 

extern "C" {
#include <libavformat></libavformat>avformat.h>
#include <libavcodec></libavcodec>avcodec.h>
 
#include <libavutil></libavutil>opt.h>
#include <libavutil></libavutil>imgutils.h>
} 
// ffmpeg method.
static void encode(AVCodecContext *enc_ctx, AVFrame *frame, AVPacket *pkt,
 FILE *outfile)
{
 int ret;
 
 /* send the frame to the encoder */
 if (frame)
 printf("Send frame %3" PRId64 "\n", frame->pts);
 
 ret = avcodec_send_frame(enc_ctx, frame);
 if (ret < 0) {
 fprintf(stderr, "Error sending a frame for encoding\n");
 exit(1);
 }
 
 while (ret >= 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);
 }
 
 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)
{
 
 int ret;
 char errbuf[100];

 AVFormatContext* ifmt_ctx = avformat_alloc_context();

 AVDictionary* options = NULL;
 //av_dict_set(&options, "framerate", "30", 0);
 av_dict_set(&options, "video_size", "1920x1080", 0);
 av_dict_set(&options,"pixel_format", "yuv420p",0);
 av_dict_set(&options, "vcodec", "rawvideo", 0);

 if ((ret = avformat_open_input(&ifmt_ctx, "output_test.yuv", NULL, &options)) < 0) {
 av_strerror(ret, errbuf, sizeof(errbuf));
 fprintf(stderr, "Unable to open err=%s\n", errbuf);
 }

 const AVCodec *pCodec = avcodec_find_decoder(AV_CODEC_ID_RAWVIDEO); //Get pointer to rawvideo codec.

 AVCodecContext *pCodecContext = avcodec_alloc_context3(pCodec); //Allocate codec context.

 //Fill the codec context based on the values from the codec parameters.
 AVStream *vid_stream = ifmt_ctx->streams[0];
 avcodec_parameters_to_context(pCodecContext, vid_stream->codecpar);

 avcodec_open2(pCodecContext, pCodec, NULL); //Open the codec

 //Allocate memory for packet and frame
 AVPacket *pPacket = av_packet_alloc();
 AVFrame *pFrame = av_frame_alloc();

 // For output use:
 
 const char *filename, *codec_name;
 const AVCodec *codec;
 AVCodecContext *c= NULL;
 int i, x, y;
 FILE *f;
 // origin ffmpeg code - AVFrame *frame;
 AVPacket *pkt;
 uint8_t endcode[] = { 0, 0, 1, 0xb7 };
 
 if (argc <= 2) {
 fprintf(stderr, "Usage: %s <output file="file"> <codec>\n", argv[0]);
 exit(0);
 }
 filename = argv[1];
 codec_name = argv[2];
 
 /* find the mpeg1video encoder */
 codec = avcodec_find_encoder_by_name(codec_name);
 if (!codec) {
 fprintf(stderr, "Codec '%s' not found\n", codec_name);
 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;
 /* resolution must be a multiple of two */
 c->width = 352;
 c->height = 288;
 /* 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: %s\n", av_err2str(ret));
 exit(1);
 }
 
 f = fopen(filename, "wb");
 if (!f) {
 fprintf(stderr, "Could not open %s\n", filename);
 exit(1);
 }
// This is ffmpeg code that I removed 
// 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, 0);
// if (ret < 0) {
// fprintf(stderr, "Could not allocate the video frame data\n");
// exit(1);
// }

 pFrame->format = c->pix_fmt;
 pFrame->width = c->width;
 pFrame->height = c->height;
 

 //Read video frames and pass through the decoder.
 //Note: Since the video is rawvideo, we don't really have to pass it through the decoder.
 while (av_read_frame(ifmt_ctx, pPacket) >= 0) 
 {
 //The video is not encoded - passing through the decoder is simply copy the data.
 avcodec_send_packet(pCodecContext, pPacket); //Supply raw packet data as input to the "decoder".
 avcodec_receive_frame(pCodecContext, pFrame); //Return decoded output data from the "decoder".

 fflush(stdout);
// This is ffmpeg code that I removed 
// /* Make sure the frame data is writable.
// On the first round, the frame is fresh from av_frame_get_buffer()
// and therefore we know it is writable.
// But on the next rounds, encode() will have called
// avcodec_send_frame(), and the codec may have kept a reference to
// the frame in its internal structures, that makes the frame
// unwritable.
// av_frame_make_writable() checks that and allocates a new buffer
// for the frame only if necessary.
// */
// ret = av_frame_make_writable(frame);
// if (ret < 0)
// exit(1);
// 
// /* Prepare a dummy image.
// In real code, this is where you would have your own logic for
// filling the frame. FFmpeg does not care what you put in the
// frame.
// */
// /* Y */
// for (y = 0; y < c->height; y++) {
// for (x = 0; x < c->width; x++) {
// frame->data[0][y * frame->linesize[0] + x] = 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] = 128 + y + i * 2;
// frame->data[2][y * frame->linesize[2] + x] = 64 + x + i * 5;
// }
// }
 
 pFrame->pts = i;
 
 /* encode the image */
 encode(c, pFrame, pkt, f);
 }
 
 /* flush the encoder */
 encode(c, NULL, pkt, f);
 
 /* Add sequence end code to have a real MPEG file.
 It makes only sense because this tiny examples writes packets
 directly. This is called "elementary stream" and only works for some
 codecs. To create a valid file, you usually need to write packets
 into a proper file format or protocol; see mux.c.
 */
 if (codec->id == AV_CODEC_ID_MPEG1VIDEO || codec->id == AV_CODEC_ID_MPEG2VIDEO)
 fwrite(endcode, 1, sizeof(endcode), f);
 fclose(f);
 
 avcodec_free_context(&c);
 av_frame_free(&pFrame);
 av_packet_free(&pkt);
 
 return 0;
}
</codec></output>


EDIT : I added combined code of ffmpeg and reading/decoding from YUV file according @Rotem (thanks). Frame from decoder pushed right to encode() method of ffmpeg. The out video was not good... Should I manipulate the YUV input frame before send it to encode() method ? if yes how to do it ?