
Recherche avancée
Autres articles (71)
-
Keeping control of your media in your hands
13 avril 2011, parThe vocabulary used on this site and around MediaSPIP in general, aims to avoid reference to Web 2.0 and the companies that profit from media-sharing.
While using MediaSPIP, you are invited to avoid using words like "Brand", "Cloud" and "Market".
MediaSPIP is designed to facilitate the sharing of creative media online, while allowing authors to retain complete control of their work.
MediaSPIP aims to be accessible to as many people as possible and development is based on expanding the (...) -
Librairies et binaires spécifiques au traitement vidéo et sonore
31 janvier 2010, parLes logiciels et librairies suivantes sont utilisées par SPIPmotion d’une manière ou d’une autre.
Binaires obligatoires FFMpeg : encodeur principal, permet de transcoder presque tous les types de fichiers vidéo et sonores dans les formats lisibles sur Internet. CF ce tutoriel pour son installation ; Oggz-tools : outils d’inspection de fichiers ogg ; Mediainfo : récupération d’informations depuis la plupart des formats vidéos et sonores ;
Binaires complémentaires et facultatifs flvtool2 : (...) -
Support audio et vidéo HTML5
10 avril 2011MediaSPIP utilise les balises HTML5 video et audio pour la lecture de documents multimedia en profitant des dernières innovations du W3C supportées par les navigateurs modernes.
Pour les navigateurs plus anciens, le lecteur flash Flowplayer est utilisé.
Le lecteur HTML5 utilisé a été spécifiquement créé pour MediaSPIP : il est complètement modifiable graphiquement pour correspondre à un thème choisi.
Ces technologies permettent de distribuer vidéo et son à la fois sur des ordinateurs conventionnels (...)
Sur d’autres sites (5677)
-
swr_convert float planar to S16
8 janvier 2020, par Kevin KouketsuHow convert using libav API
AV_SAMPLE_FMT_FLTP
toAV_SAMPLE_FMT_S16
I’m trying to figure out how to resample and encode PCM (captured from Microphone) 44.1KHz to AAC 48.0KHz
That’s my resampler initializer :
void initialize_resampler(SwrContext*& resamplerCtx, AVCodecContext* encoder, AVFrame*& rawResampledAudioFrame, AVStream* audioFormatStream)
{
int nb_samples = (encoder->codec->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE) ? encoder->sample_rate : encoder->frame_size;
int encoderFrameSize = encoder->channels * av_get_bytes_per_sample(encoder->sample_fmt) * encoder->frame_size;
rawResampledAudioFrame = allocate_audioframe(encoder->sample_fmt, encoder->channel_layout, encoder->sample_rate, nb_samples);
// Copy the stream parameters to the muxer
check(avcodec_parameters_from_context(audioFormatStream->codecpar, encoder));
// Create resampler context
resamplerCtx = swr_alloc();
if (resamplerCtx == nullptr)
throw std::runtime_error("Could not allocate resampler context");
// Set options
check(av_opt_set_int(resamplerCtx, "in_channel_count", 2, 0));
check(av_opt_set_int(resamplerCtx, "in_sample_rate", 44100, 0));
check(av_opt_set_sample_fmt(resamplerCtx, "in_sample_fmt", AV_SAMPLE_FMT_S16, 0));
check(av_opt_set_int(resamplerCtx, "out_channel_count", encoder->channels, 0));
check(av_opt_set_int(resamplerCtx, "out_sample_rate", encoder->sample_rate, 0));
check(av_opt_set_sample_fmt(resamplerCtx, "out_sample_fmt", encoder->sample_fmt, 0));
// initialize the resampling context
check(swr_init(resamplerCtx));
}And for resample I’ve this code :
AVPacket pkt{};
while (true)
{
AVPacket input_packet;
av_init_packet(&input_packet);
check(av_read_frame(inputContext, &input_packet));
check(avcodec_send_packet(decoderContext, &input_packet));
check(avcodec_receive_frame(decoderContext, decodedFrame));
// WHAT DO HERE swr_convert(resamplerContext, )
av_packet_unref(&input_packet);
av_init_packet(&pkt);
auto in_stream = inputContext->streams[pkt.stream_index];
auto out_stream = outputContext->streams[pkt.stream_index];
pkt.pts = av_rescale_q_rnd(pkt.pts, in_stream->time_base, out_stream->time_base, (AVRounding)(AV_ROUND_NEAR_INF | AV_ROUND_PASS_MINMAX));
pkt.dts = av_rescale_q_rnd(pkt.dts, in_stream->time_base, out_stream->time_base, (AVRounding)(AV_ROUND_NEAR_INF | AV_ROUND_PASS_MINMAX));
pkt.duration = av_rescale_q(pkt.duration, in_stream->time_base, out_stream->time_base);
pkt.pos = -1;
check(avcodec_send_frame(encoderContext, decodedFrame));
check(avcodec_receive_packet(encoderContext, &pkt));
check(av_interleaved_write_frame(outputContext, &pkt));
av_packet_unref(&pkt);
}REading the docs I can’t figure out what exactly I need to pass to function. I have this code to encode PCM to MP2 (output is
AV_SAMPLE_FMT_S16
)const uint8_t* inPtr[] { const_cast<const>(&pcmData[0]), nullptr, nullptr,nullptr,nullptr,nullptr,nullptr,nullptr };
uint8_t* outPtr[] { &resampledAudioData[0], nullptr, nullptr,nullptr,nullptr,nullptr,nullptr,nullptr };
int resampledSamplesCount{ swr_convert(
resamplerCtx,
outPtr,
maxResampledSamplesCount,
inPtr,
inputSampleCount) };
// Negativo indica erro.
check(resampledSamplesCount);
</const>pcmData is raw data from input
AVPacket
(PCM)What I get here is : MP2 isn’t planar so it uses the same outPtr[0] different from plannar which needs two valid pointers to same writable data. But what I need to pass to inPtr, for example ?
When I try to use the same code, ffmpeg try to write on outPtr[1] which is nullptr.
-
Grab frame from video (as Inputstream) using JavaCV in Java
23 janvier 2020, par Praveen GopalI am using JavaCV to grab frame from Video.
I can grab if video is in absolute path. But if video is in HTTP than JavaCV throw error.
url = new URL("http://www.sample-videos.com/video/mp4/720/SampleVideo.mp4");
urlConnection = (HttpURLConnection) url.openConnection();
InputStream inputStream = urlConnection.getInputStream();
Java2DFrameConverter bimConverter = new Java2DFrameConverter();
FFmpegFrameGrabber frameGrabber = new FFmpegFrameGrabber(inputStream);
String output = "C:\\Users\\xxxx\\Downloads\\Test";
frameGrabber.start();
Frame frame;
double frameRate=frameGrabber.getFrameRate();
int imgNum=5;
System.out.println("Video has "+frameGrabber.getFrameRate()+" frames and has frame rate of "+frameRate);
try {
frameGrabber.setFrameNumber(1000);
frame = frameGrabber.grabKeyFrame();
BufferedImage bi = bimConverter.convert(frame);
String path = output+File.separator+imgNum+".jpg";
ImageIO.write(bi,"png", new File(path));
frameGrabber.stop();
frameGrabber.close();
frameGrabber.flush();
} catch (Exception e) {
e.printStackTrace();
}Any help would be helpful.
Thanks in advance. -
Grab frame from video using JavaCV
26 août 2020, par Praveen GopalI am using JavaCV to grab frame from Video.


I can grab if video is in absolute path. But if video is in HTTP than JavaCV throw error.


url = new URL("http://www.sample-videos.com/video/mp4/720/SampleVideo.mp4");
 urlConnection = (HttpURLConnection) url.openConnection();
 InputStream inputStream = urlConnection.getInputStream();
 Java2DFrameConverter bimConverter = new Java2DFrameConverter();

 FFmpegFrameGrabber frameGrabber = new FFmpegFrameGrabber(inputStream);

 String output = "C:\\Users\\xxxx\\Downloads\\Test";
 frameGrabber.start();
 Frame frame; 
 double frameRate=frameGrabber.getFrameRate(); 
 int imgNum=5; 
 System.out.println("Video has "+frameGrabber.getFrameRate()+" frames and has frame rate of "+frameRate); 
 try { 
 frameGrabber.setFrameNumber(1000);
 frame = frameGrabber.grabKeyFrame(); 
 BufferedImage bi = bimConverter.convert(frame); 
 String path = output+File.separator+imgNum+".jpg"; 
 ImageIO.write(bi,"png", new File(path));
 frameGrabber.stop(); 
 frameGrabber.close();
 frameGrabber.flush(); 
 } catch (Exception e) { 
 e.printStackTrace(); 
 }