
Recherche avancée
Autres articles (50)
-
Multilang : améliorer l’interface pour les blocs multilingues
18 février 2011, parMultilang est un plugin supplémentaire qui n’est pas activé par défaut lors de l’initialisation de MediaSPIP.
Après son activation, une préconfiguration est mise en place automatiquement par MediaSPIP init permettant à la nouvelle fonctionnalité d’être automatiquement opérationnelle. Il n’est donc pas obligatoire de passer par une étape de configuration pour cela. -
Publier sur MédiaSpip
13 juin 2013Puis-je poster des contenus à partir d’une tablette Ipad ?
Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir -
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.
Sur d’autres sites (9979)
-
Extract audio from video using autogen ffmpeg C# in Unity
5 décembre 2024, par Johan SophieHi I'm using ffmpeg autogen to extract audio from video in Unity, but when I following this code, the file write cannot write, it's 0Kb, so what's issue of this or someone have any examples for extract audio using this library, apologize for my English. This is github of library : 
https://github.com/Ruslan-B/FFmpeg.AutoGen



unsafe void TestExtractAudio()
{

 string inFile = Application.streamingAssetsPath + "/" + strFileName;
 string outFile = Application.streamingAssetsPath + "/" + strFileNameAudio;

 AVOutputFormat* outFormat = null;
 AVFormatContext* inFormatContext = null;
 AVFormatContext* outFormatContext = null;
 AVPacket packet;

 ffmpeg.av_register_all();

 inFormatContext = ffmpeg.avformat_alloc_context();
 outFormatContext = ffmpeg.avformat_alloc_context();

 if (ffmpeg.avformat_open_input(&inFormatContext, inFile, null, null) < 0)
 {
 throw new ApplicationException("Could not open input file.");
 }

 if (ffmpeg.avformat_find_stream_info(inFormatContext, null) < 0)
 {
 throw new ApplicationException("Failed to retrieve input stream info.");
 }

 ffmpeg.avformat_alloc_output_context2(&outFormatContext, null, null, outFile);
 if (outFormatContext == null)
 {
 throw new ApplicationException("Could not create output context");
 }

 outFormat = outFormatContext->oformat;

 AVStream* inStream = inFormatContext->streams[1];
 AVStream* outStream = ffmpeg.avformat_new_stream(outFormatContext, inStream->codec->codec);
 if (outStream == null)
 {
 throw new ApplicationException("Failed to allocate output stream.");
 }

 if (ffmpeg.avcodec_copy_context(outStream->codec, inStream->codec) < 0)
 {
 throw new ApplicationException("Couldn't copy input stream codec context to output stream codec context");
 }

 outFormatContext->audio_codec_id = AVCodecID.AV_CODEC_ID_MP3;

 int retcode = ffmpeg.avio_open(&outFormatContext->pb, outFile, ffmpeg.AVIO_FLAG_WRITE);
 if (retcode < 0)
 {
 throw new ApplicationException("Couldn't open output file");
 }

 int returnCode = ffmpeg.avformat_write_header(outFormatContext, null);

 if (returnCode < 0)
 {
 throw new ApplicationException("Error occurred opening output file.");
 }

 while (true)
 {
 if (ffmpeg.av_read_frame(inFormatContext, &packet) < 0)
 {
 break;
 }

 if (packet.stream_index == 1)
 {

 inStream = inFormatContext->streams[1];
 outStream = outFormatContext->streams[0];

 // TODO: Replicate log packet functionality to print out what's inside the packet.

 packet.pts = ffmpeg.av_rescale_q_rnd(packet.pts, inStream->time_base, outStream->time_base,
 AVRounding.AV_ROUND_NEAR_INF | AVRounding.AV_ROUND_PASS_MINMAX);
 packet.dts = ffmpeg.av_rescale_q_rnd(packet.dts, inStream->time_base, outStream->time_base,
 AVRounding.AV_ROUND_NEAR_INF | AVRounding.AV_ROUND_PASS_MINMAX);

 packet.duration = ffmpeg.av_rescale_q(packet.duration, inStream->time_base, outStream->time_base);

 int returncode = ffmpeg.av_interleaved_write_frame(outFormatContext, &packet);

 }

 ffmpeg.av_packet_unref(&packet);
 }

 ffmpeg.av_write_trailer(outFormatContext);


 ffmpeg.avformat_close_input(&inFormatContext);

 ffmpeg.avformat_free_context(outFormatContext);

 Console.WriteLine("Press any key to continue...");

 Console.ReadKey();
}




the value returnCode return less than 0, so someone can fix this, thanks so much for that


-
avcodec/nvdec : More effort to make vp8 compile with gcc 4.6
27 novembre 2017, par Philip Langdaleavcodec/nvdec : More effort to make vp8 compile with gcc < 4.6
I'm told my prefix work-around wasn't enough to make it compile,
although I'm not sure why ; I did some basic testing and that
approach appeared to work, but I'm not in a position to do a
full compile on CentOS 6 so I can't be sure of anything.I have had it confirmed that the additional change to not use
named initialisers is enough to make it compile, so let's
throw that into the mix too. -
Transcoding audio using xuggler
15 novembre 2017, par amdI am trying to convert an audio file with the header
Opening audio decoder: [pcm] Uncompressed PCM audio decoder
AUDIO: 44100 Hz, 2 ch, s16le, 1411.2 kbit/100.00% (ratio: 176400->176400)
Selected audio codec: [pcm] afm: pcm (Uncompressed PCM)I want to transcode this file to mp3 format. I have following code snippet but its not working well. I have written it using XUGGLER code snippet for transcoding audio and video.
Audio decoder is
audioDecoder = IStreamCoder.make(IStreamCoder.Direction.DECODING, ICodec.findDecodingCodec(ICodec.ID.CODEC_ID_PCM_S16LE));
audioDecoder.setSampleRate(44100);
audioDecoder.setBitRate(176400);
audioDecoder.setChannels(2);
audioDecoder.setTimeBase(IRational.make(1,1000));
if (audioDecoder.open(IMetaData.make(), IMetaData.make()) < 0)
return false;
return true;Audio encoder is
outContainer = IContainer.make();
outContainerFormat = IContainerFormat.make();
outContainerFormat.setOutputFormat("mp3", urlOut, null);
int retVal = outContainer.open(urlOut, IContainer.Type.WRITE, outContainerFormat);
if (retVal < 0) {
System.out.println("Could not open output container");
return false;
}
outAudioCoder = IStreamCoder.make(IStreamCoder.Direction.ENCODING, ICodec.findEncodingCodec(ICodec.ID.CODEC_ID_MP3));
outAudioStream = outContainer.addNewStream(outAudioCoder);
outAudioCoder.setSampleRate(new Integer(44100));
outAudioCoder.setChannels(2);
retVal = outAudioCoder.open(IMetaData.make(), IMetaData.make());
if (retVal < 0) {
System.out.println("Could not open audio coder");
return false;
}
retVal = outContainer.writeHeader();
if (retVal < 0) {
System.out.println("Could not write output FLV header: ");
return false;
}
return true;And here is encode method where i send packets of 32 byte to transcode
public void encode(byte[] audioFrame){
//duration of 1 video frame
long lastVideoPts = 0;
IPacket packet_out = IPacket.make();
int lastPos = 0;
int lastPos_out = 0;
IAudioSamples audioSamples = IAudioSamples.make(48000, audioDecoder.getChannels());
IAudioSamples audioSamples_resampled = IAudioSamples.make(48000, audioDecoder.getChannels());
//we always have 32 bytes/sample
int pos = 0;
int audioFrameLength = audioFrame.length;
int audioFrameCnt = 1;
iBuffer = IBuffer.make(null, audioFrame, 0, audioFrameLength);
IPacket packet = IPacket.make(iBuffer);
//packet.setKeyPacket(true);
packet.setTimeBase(IRational.make(1,1000));
packet.setDuration(20);
packet.setDts(audioFrameCnt*20);
packet.setPts(audioFrameCnt*20);
packet.setStreamIndex(1);
packet.setPosition(lastPos);
lastPos+=audioFrameLength;
int pksz = packet.getSize();
packet.setComplete(true, pksz);
/*
* A packet can actually contain multiple samples
*/
int offset = 0;
int retVal;
while(offset < packet.getSize())
{
int bytesDecoded = audioDecoder.decodeAudio(audioSamples, packet, offset);
if (bytesDecoded < 0)
throw new RuntimeException("got error decoding audio ");
offset += bytesDecoded;
if (audioSamples.isComplete())
{
int samplesConsumed = 0;
while (samplesConsumed < audioSamples.getNumSamples()) {
retVal = outAudioCoder.encodeAudio(packet_out, audioSamples, samplesConsumed);
if (retVal <= 0)
throw new RuntimeException("Could not encode audio");
samplesConsumed += retVal;
if (packet_out.isComplete()) {
packet_out.setPosition(lastPos_out);
packet_out.setStreamIndex(1);
lastPos_out+=packet_out.getSize();
retVal = outContainer.writePacket(packet_out);
if(retVal < 0){
throw new RuntimeException("Could not write data packet");
}
}
}
}
}
}I get an output file but it doesnt get played. I have very little experience of audio encoding and sampling. Thanks in advance.