
Recherche avancée
Autres articles (73)
-
Use, discuss, criticize
13 avril 2011, parTalk to people directly involved in MediaSPIP’s development, or to people around you who could use MediaSPIP to share, enhance or develop their creative projects.
The bigger the community, the more MediaSPIP’s potential will be explored and the faster the software will evolve.
A discussion list is available for all exchanges between users. -
Le profil des utilisateurs
12 avril 2011, parChaque utilisateur dispose d’une page de profil lui permettant de modifier ses informations personnelle. Dans le menu de haut de page par défaut, un élément de menu est automatiquement créé à l’initialisation de MediaSPIP, visible uniquement si le visiteur est identifié sur le site.
L’utilisateur a accès à la modification de profil depuis sa page auteur, un lien dans la navigation "Modifier votre profil" est (...) -
Configurer la prise en compte des langues
15 novembre 2010, parAccéder à la configuration et ajouter des langues prises en compte
Afin de configurer la prise en compte de nouvelles langues, il est nécessaire de se rendre dans la partie "Administrer" du site.
De là, dans le menu de navigation, vous pouvez accéder à une partie "Gestion des langues" permettant d’activer la prise en compte de nouvelles langues.
Chaque nouvelle langue ajoutée reste désactivable tant qu’aucun objet n’est créé dans cette langue. Dans ce cas, elle devient grisée dans la configuration et (...)
Sur d’autres sites (7696)
-
FFmpeg avcodec_find_encoder problem
13 novembre 2012, par netI'm newbie in ffmpeg.
my problem is "avcodec_find_encoder(CODEC_ID_H264) ;" func always returning null.
ffmpeg configure is below on my ubuntu system.
./ffmpeg
FFmpeg version SVN-r26306, Copyright (c) 2000-2011 the FFmpeg developers
built on Jan 11 2011 10:34:49 with gcc 4.4.5
configuration: --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxvid --enable-x11grab
libavutil 50.36. 0 / 50.36. 0
libavcore 0.16. 0 / 0.16. 0
libavcodec 52.108. 0 / 52.108. 0
libavformat 52.92. 0 / 52.92. 0
libavdevice 52. 2. 3 / 52. 2. 3
libavfilter 1.72. 0 / 1.72. 0
libswscale 0.12. 0 / 0.12. 0
libpostproc 51. 2. 0 / 51. 2. 0as you can see, configuration contains —enable-libx264
so I think avcodec_find_encoder(CODEC_ID_H264) ; have to return something not null...
please let me know how to solve this problem ?ps) I call avcodec_init() and av_register_all() in my program.
when I compile my test program, using below
gcc -o test test.c -lavutil -lavformat -lavcodec -lx264 -lz -lm
thanks
-
How to drop P-Frames for Datamosh effect using FFMpeg
22 mai 2016, par Shillo Ben DavidI’m trying to achieve the Datamosh effect on video.
I know that in general what I need to the video is to delete all i-Frames but I have no idea how to achieve that using ffmpeg.
-
FFMPEG MP3 decode and encode audio distortion
5 avril 2016, par user3450380I’m trying to make a program that successfully decodes MP3 to PCM. To test this I’ve been re-encoding to MP3 to see if the audio matches up. The problem is when I play the re-encoded audio the songs are 30 seconds shorter than the original and at a noticeably higher pitch. However, if I decode and encode this new audio (the distorted one I just encoded), I get the exact same audio. The only thing I can think of is maybe I’m missing something in the header ? Thanks for any help ! Sorry for the weird code blocks, the trying to tab to make code blocks skipped across the web page.
#define AUDIO_INBUF_SIZE 20480
#define AUDIO_REFILL_THRESH 4096
#define STD_SAMPLE_RATE 44100
//check if given sample format is accepted by given codec
static int check_sample_format(AVCodec* avco, enum AVSampleFormat sample_fmt)
{
const enum AVSampleFormat* p = avco->sample_fmts;
while(*p != AV_SAMPLE_FMT_NONE)
{
if(*p == sample_fmt)
{
return 1;
}
p++;
}
return 0;
}
//if no sample rates in codec, selects the standard rate of 44100.
//otherwise, highest suported sample rate is chosen
static int select_sample_rate(AVCodec* avco)
{
const int* p;
int best_sample_rate = 0;
if(!(avco->supported_samplerates))
{
return STD_SAMPLE_RATE;
}
p = avco->supported_samplerates;
while(*p)
{
best_sample_rate = FFMAX(*p, best_sample_rate);
p++;
}
return best_sample_rate;
}//select layout with the highest channel count
static int select_channel_layout(AVCodec* codec)
{
const uint64_t* p;
uint64_t best_ch_layout = 0;
int best_nb_channels = 0;
if(!codec->channel_layouts)
{
return AV_CH_LAYOUT_STEREO;
}
p = codec->channel_layouts;
while(*p)
{
int nb_channels = av_get_channel_layout_nb_channels(*p);
if(nb_channels > best_nb_channels)
{
best_ch_layout = *p;
best_nb_channels = nb_channels;
}
p++;
}
return best_ch_layout;}
static int file_format_check(AVFormatContext* pFormatCtx, const char* song_path, FILE* infile)
{
AVCodecContext* codecCtx = NULL;
AVCodec* inputCodec = NULL;
int audioStreamIndex, i = 0;
//open audio file
if(avformat_open_input(&pFormatCtx, song_path, NULL, NULL) != 0)
{
return -1;
}
//open binary file for reading
infile = fopen(song_path, "rb");
if(!infile)
{
fprintf(stderr, "Input file not opened!");
return -1;
}
if(avformat_find_stream_info(pFormatCtx, NULL))
{
fprintf(stderr, "Stream info not found!");
return -1;
}
//dumps info about format context to standard error
av_dump_format(pFormatCtx, 0, /*argv[1]*/0, 0);
//find audio stream
for(i = 0; i < pFormatCtx->nb_streams; i++){
if(pFormatCtx->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO)
{
audioStreamIndex = i;
printf("Audio Stream Found!\n");
break;
}
}
if(audioStreamIndex == -1)
{
return -1;
}
//set codec context pointer to codec context of audio stream
codecCtx = pFormatCtx->streams[audioStreamIndex]->codec;
//find decodeder for audio stream
inputCodec = avcodec_find_decoder(codecCtx->codec_id);
if (inputCodec == NULL)
{
fprintf(stderr, "Unsupported codec!\n");
return -1;
}
//open codec
if(avcodec_open2(codecCtx, inputCodec, NULL) < 0)
{
fprintf(stderr, "Codec could not be opened!");
return -1;
}
return audioStreamIndex;}
int main(int argc, const char * argv[])
{
//refister all available file formats and codecs
av_register_all();
FILE *infile, *outfile;
int i, len, ret, audioStreamIndex = -1;
const char* song_path = "/Users/timothyrice/Dropbox/audio-experimentation/audio_playground/audio_playground/Monsters.mp3";
const char* new_format_path = "/Users/timothyrice/Dropbox/audio-experimentation/audio_playground/audio_playground/new_audio.mp3";
AVFormatContext* inputFormat = avformat_alloc_context();
AVFormatContext* outputFormat = avformat_alloc_context();
AVCodecContext* decodeCodecCtx;
AVPacket decodingPacket;
AVFrame* decodedFrame = NULL;
AVCodec* encodeCodec = NULL;
AVCodecContext* encodeCodecCtx = NULL;
AVPacket encodingPacket;
audioStreamIndex = file_format_check(inputFormat, song_path, infile);
if(audioStreamIndex < 0)
{
return -1;
}
av_init_packet(&decodingPacket);
//allocate frame
if(!decodedFrame)
{
if(!(decodedFrame = av_frame_alloc()))
{
fprintf(stderr, "Could not allocate audio frame\n");
return -1;
}
}
//set decoding codec context to audio stream index's codec
decodeCodecCtx = inputFormat->streams[audioStreamIndex]->codec;
//set up encoding audio codec
encodeCodec = avcodec_find_encoder(AV_CODEC_ID_MP3);
if(!encodeCodec)
{
fprintf(stderr, "Could not find encoder codec!\n");
return -1;
}
encodeCodecCtx = avcodec_alloc_context3(encodeCodec);
encodeCodecCtx->bit_rate = decodeCodecCtx->bit_rate;
encodeCodecCtx->sample_fmt = decodeCodecCtx->sample_fmt;
encodeCodecCtx->frame_size = decodeCodecCtx->frame_size;
if(!check_sample_format(encodeCodec, encodeCodecCtx->sample_fmt))
{
fprintf(stderr, "Sample format %s not supported by encoding codec!\n", av_get_sample_fmt_name(encodeCodecCtx->sample_fmt));
return -1;
}
//encoder codec context setup
encodeCodecCtx->sample_rate = select_sample_rate(encodeCodec);
encodeCodecCtx->channel_layout = select_channel_layout(encodeCodec);
encodeCodecCtx->channels = av_get_channel_layout_nb_channels(encodeCodecCtx->channel_layout);
if(avcodec_open2(encodeCodecCtx, encodeCodec, 0) < 0)
{
fprintf(stderr, "Could not open encoder codec\n");
return -1;
}
outfile = fopen(new_format_path, "wb");
if(!outfile)
{
fprintf(stderr, "Output file not opened!\n");
return -1;
}
//printf("Outside function format-duration = %lld\n", inputFormat->duration);
int c = 0, sum = 0;// max = 0;
while (av_read_frame(inputFormat, &decodingPacket) == 0)
{
//CHECK LATER:# of samples decoded = # encoded?
//PLANAR????
int ch, got_frame, got_packet = 0;
int j = 0;
//printf("Frame #%d\n", ++c);
//make sure stream indexes match, rarely necessary but can prevent a crash
if(decodingPacket.stream_index == audioStreamIndex)
{
int bl = 0; //temporary to see performance of while loop
while (decodingPacket.size > 0) {
got_frame = 0;
if(bl++ > 1)
{
printf("while loop repeat!!!!\n\n\n");
}
//decodes next frame from stream inside decodingPacket and stores it in decodedFrame
//len < 0 if the decoding didn't work
len = avcodec_decode_audio4(decodeCodecCtx, decodedFrame, &got_frame, &decodingPacket);
if(got_frame && len >= 0)
{
ret = avcodec_encode_audio2(encodeCodecCtx, &encodingPacket, decodedFrame, &got_packet);
if(ret < 0)
{
fprintf(stderr, "Error encoding raw audio frame!\n");
return -1;
}
if(got_packet)
{
fwrite(encodingPacket.data, 1, encodingPacket.size, outfile);
av_free_packet(&encodingPacket);
//if encoder needs to be flushed
if(encodeCodecCtx->codec->capabilities == CODEC_CAP_DELAY)
{
av_init_packet(&encodingPacket);
got_frame = 0;
while(avcodec_encode_audio2(encodeCodecCtx, &encodingPacket, NULL, &got_packet) >= 0 && got_frame)
{
fwrite(encodingPacket.data, 1, encodingPacket.size, outfile);
av_free_packet(&encodingPacket);
}
}
}
//if decoder needs to be flushed
if(decodeCodecCtx->codec->capabilities == CODEC_CAP_DELAY)
{
av_init_packet(&decodingPacket);
got_frame = 0;
while(avcodec_decode_audio4(decodeCodecCtx, decodedFrame, &got_frame, &decodingPacket) >= 0 && got_frame)
{
av_free_packet(&decodingPacket);
}
}
}
else
{
fprintf(stderr, "Error while decoding\n");
return -1;
}
decodingPacket.size -= len;
decodingPacket.data += len;
decodingPacket.dts = AV_NOPTS_VALUE;
decodingPacket.pts = AV_NOPTS_VALUE;
}
av_free_packet(&decodingPacket);
}
}
//open audio file
if(avformat_open_input(&outputFormat, new_format_path, NULL, NULL) != 0)
{
return -1;
}
//open binary file for reading
outfile = fopen(new_format_path, "rb");
if(!outfile)
{
fprintf(stderr, "Input file not opened!");
return -1;
}
if(avformat_find_stream_info(outputFormat, NULL))
{
fprintf(stderr, "Stream info not found!");
return -1;
}
//dumps info about format context to standard error
av_dump_format(outputFormat, 0, /*argv[1]*/0, 0);
fclose(infile);
fclose(outfile);
avcodec_close(decodeCodecCtx);
av_free(decodeCodecCtx);
av_frame_free(&decodedFrame);
return 0;}