
Recherche avancée
Médias (91)
-
Géodiversité
9 septembre 2011, par ,
Mis à jour : Août 2018
Langue : français
Type : Texte
-
USGS Real-time Earthquakes
8 septembre 2011, par
Mis à jour : Septembre 2011
Langue : français
Type : Texte
-
SWFUpload Process
6 septembre 2011, par
Mis à jour : Septembre 2011
Langue : français
Type : Texte
-
La conservation du net art au musée. Les stratégies à l’œuvre
26 mai 2011
Mis à jour : Juillet 2013
Langue : français
Type : Texte
-
Podcasting Legal guide
16 mai 2011, par
Mis à jour : Mai 2011
Langue : English
Type : Texte
-
Creativecommons informational flyer
16 mai 2011, par
Mis à jour : Juillet 2013
Langue : English
Type : Texte
Autres articles (94)
-
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 (10936)
-
How do you convert multiple audio files in different folders using ffmpeg
1er avril 2022, par ankulkaRight now I can use the below code to change all files in a single folder, but I have over 100 folders I need to convert audios for. How do I adjust my code to run through all folders and not just one ?


# files 
lst = glob.glob("*.mp3")
print(lst)
 
for file in lst:
# convert wav to mp3
 os.system(f"""ffmpeg -i {file} -acodec pcm_u8 -ar 22050 {file[:-4]}.wav""") 



-
Decoding HEVC file in C++ with FFmpeg missing one frame
12 avril 2022, par IvanI'm trying to decode my Hevc file in c++ with using FFmpeg. I used Hevc decoder and try to save the frames in ppm format(Almost the whole source code comes from FFmpeg example [decode_video.c] https://ffmpeg.org/doxygen/trunk/decode_video_8c-example.html, what's new is the conversion from yuv to rgb). My Hevc file has 677 frames, which i checked with ffprobe in command window. But i any got 676 frames with my project. Also i have checked with other Hevc files, the results are same, i got always one frame less.
I also tried another FFmpeg example [demuxing_decoding.c] (https://ffmpeg.org/doxygen/trunk/demuxing_decoding_8c-example.html), the result is same, one frame less...


That seems to just happy with H265 and H264 files, is it a bug of FFmpeg ?


Can anybody help me, i post my code here. Sorry, don't know how to attach my project and test files. Thanks a lot !


Best regards,
Ivan


#include <iostream>

extern "C"
{
#include "../Headers/libavcodec/avcodec.h"
#include "../Headers/libavformat/avformat.h"
#include "../Headers/libswscale/swscale.h"
}

#define INBUF_SIZE 4096

//Save RGB image as PPM file format
static void ppm_save(char* filename, AVFrame* frame)
{
 FILE* file;
 int i;

 fopen_s(&file, filename, "wb");
 fprintf(file, "P6\n%d %d\n%d\n", frame->width, frame->height, 255);
 for (i = 0; i < frame->height; i++)
 fwrite(frame->data[0] + i * frame->linesize[0], 1, frame->width * 3, file);
 fclose(file);
}

void decode(AVCodecContext* dec_ctx, AVFrame* frame, AVPacket* pkt, const char* outfilePrefix)
{
 char buf[1024];
 int ret;

 ret = avcodec_send_packet(dec_ctx, pkt);
 if (ret < 0) {
 fprintf(stderr, "Error sending a packet for decoding\n");
 exit(1);
 }

 int sts;
 ////////////////////////////////////////////////////////////////////////////
 //Create SWS Context for converting from decode pixel format (like YUV420) to RGB
 struct SwsContext* sws_ctx = NULL;
 sws_ctx = sws_getContext(dec_ctx->width,
 dec_ctx->height,
 dec_ctx->pix_fmt,
 dec_ctx->width,
 dec_ctx->height,
 AV_PIX_FMT_RGB24,
 SWS_BICUBIC,
 NULL,
 NULL,
 NULL);

 if (sws_ctx == nullptr)
 {
 return; //Error!
 }

 //Allocate frame for storing image converted to RGB.
 AVFrame* pRGBFrame = av_frame_alloc();

 pRGBFrame->format = AV_PIX_FMT_RGB24;
 pRGBFrame->width = dec_ctx->width;
 pRGBFrame->height = dec_ctx->height;
 sts = av_frame_get_buffer(pRGBFrame, 0);

 if (sts < 0)
 {
 goto free;
 //return; //Error!
 }

 while (ret >= 0)
 {
 ret = avcodec_receive_frame(dec_ctx, frame);
 if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
 goto free;
 //return;
 else if (ret < 0) {
 fprintf(stderr, "Error during decoding\n");
 exit(1);
 }

 printf("saving frame %3d\n", dec_ctx->frame_number);//
 fflush(stdout);

 //////////////////////////////////////////////////////////////////////////
 //Convert from input format (e.g YUV420) to RGB and save to PPM:
 sts = sws_scale(sws_ctx, //struct SwsContext* c,
 frame->data, //const uint8_t* const srcSlice[],
 frame->linesize, //const int srcStride[],
 0, //int srcSliceY, 
 frame->height, //int srcSliceH,
 pRGBFrame->data, //uint8_t* const dst[], 
 pRGBFrame->linesize); //const int dstStride[]);

 snprintf(buf, sizeof(buf), "%s-%d.ppm", outfilePrefix, dec_ctx->frame_number);
 ppm_save(buf, pRGBFrame);
 }

free:
 //Free
 ////////////////////////////////////////////////////////////////////////////
 sws_freeContext(sws_ctx);
 av_frame_free(&pRGBFrame);
}

int main()
{
 const char* filename, * outfilePrefix, * seqfilename;
 const AVCodec* codec;
 AVCodecParserContext* parser;
 AVCodecContext* codecContext = NULL;
 FILE* file;
 AVFrame* frame;
 uint8_t inbuf[INBUF_SIZE + AV_INPUT_BUFFER_PADDING_SIZE];
 uint8_t* data;
 size_t data_size;
 int ret;
 AVPacket* pkt;

#ifdef _DEBUG
 filename = "D:\\TestFiles\\sample_1280x720.hevc";
 outfilePrefix = "D:\\TestFiles\\sample_1280x720_output\\output";
#else
 if (argc <= 2) {
 fprintf(stderr, "Usage: %s <input file="file" /> <output file="file">\n"
 "And check your input file is encoded by mpeg1video please.\n", argv[0]);
 exit(0);
 }
 filename = argv[1];
 outfilePrefix = argv[2];
#endif

 pkt = av_packet_alloc();
 if (!pkt)
 exit(1);

 /* set end of buffer to 0 (this ensures that no overreading happens for damaged MPEG streams) */
 memset(inbuf + INBUF_SIZE, 0, AV_INPUT_BUFFER_PADDING_SIZE);

 /* find the HEVC video decoder */
 codec = avcodec_find_decoder(AV_CODEC_ID_HEVC);
 if (!codec) {
 fprintf(stderr, "Codec not found\n");
 exit(1);
 }

 parser = av_parser_init(codec->id);
 if (!parser) {
 fprintf(stderr, "parser not found\n");
 exit(1);
 }

 codecContext = avcodec_alloc_context3(codec);
 if (!codecContext) {
 fprintf(stderr, "Could not allocate video codec context\n");
 exit(1);
 }

 /* For some codecs, such as msmpeg4 and mpeg4, width and height
 MUST be initialized there because this information is not
 available in the bitstream. */

 /* open it */
 if (avcodec_open2(codecContext, codec, NULL) < 0) {
 fprintf(stderr, "Could not open codec\n");
 exit(1);
 }

 fopen_s(&file, filename, "rb");
 if (!file) {
 fprintf(stderr, "Could not open %s\n", filename);
 exit(1);
 }

 frame = av_frame_alloc();
 if (!frame) {
 fprintf(stderr, "Could not allocate video frame\n");
 exit(1);
 }

 while (!feof(file)) {
 /* read raw data from the input file */
 data_size = fread(inbuf, 1, INBUF_SIZE, file);
 if (!data_size)
 break;

 /* use the parser to split the data into frames */
 data = inbuf;
 while (data_size > 0)
 {
 ret = av_parser_parse2(parser, codecContext, &pkt->data, &pkt->size,
 data, data_size, AV_NOPTS_VALUE, AV_NOPTS_VALUE, 0);
 if (ret < 0) {
 fprintf(stderr, "Error while parsing\n");
 exit(1);
 }
 data += ret;
 data_size -= ret;

 if (pkt->size)
 decode(codecContext, frame, pkt, outfilePrefix);
 }
 }

 /* flush the decoder */
 decode(codecContext, frame, NULL, outfilePrefix);

 fclose(file);

 av_parser_close(parser);
 avcodec_free_context(&codecContext);
 av_frame_free(&frame);
 av_packet_free(&pkt);
}
</output></iostream>


-
Increase volume of multiple mp3 files in a directory [closed]
6 mai 2022, par kojow7I am looking for a way to increase the volume of a number of sound bytes in a directory without clipping. I have seen that I can use ffmpeg to pass it through a filter and set volume to a certain level such as 1.5x etc.


However, I would like each file to be moved up to its maximum volume without clipping. How do I do this ?


Some examples show how to do it in 2 passes, by taking values from first pass and manually using them in 2nd pass. But I am trying to automate this in a bash script with hundreds of sound clips.


What is the best way to do this ?


I am ultimately trying to put this into a Bash script on MacOS and preferably using ffmpeg.