Newest 'ffmpeg' Questions - Stack Overflow
Les articles publiés sur le site
-
How to convert video to audio in paperclip [closed]
7 mai 2014, par jonas_bringI upload video files from iOS and need to convert the original file to audio using ffmpeg, but the convert options needed is somewhat over my head. Does anyone know how to do it? Thanks!
Clarification: How do I write the convert_options for paperclip-ffmpeg to convert a video to audio?
-
ffmpeg probesize and analyzeduration flags
7 mai 2014, par XerphielCould someone explain to me in simple terms what these flags/options do?
Running "ffmpeg -h full | grep probesize/analyzeduration" yields the following documentation:
-probesize
.D.... set probing size (from 32 to INT_MAX) (default 5e+06) -analyzeduration .D.... specify how many microseconds are analyzed to probe the input (from 0 to INT_MAX) (default 5e+06) This is beyond my understanding, so am hoping for a simpler explanation.
All the discussions on this subject I've found via googling do not describe the basic function of the options.
Any help is appreciated.
Thank you.
-
How to stream video from Node.js
7 mai 2014, par Sunrisingi am trying to request a video stored on server and receive a stream of data to show in a html tag
From the client i request the streaming of a particular file i know exists in my server
Then in node i use this:
function streamvideo(response, request) { // here i simply read from the response the path and the name of the file i want var queryparts = url.parse(request.url, true).query; var path = queryparts.query; var path = 'tmp/' + path , stat = fs.statSync(path) , total = stat.size; var origin = (request.headers.origin || "*"); // still not sure it is correct to manage range this way but it works // if i request a range.... if (request.headers['range']) { var range = request.headers.range , parts = range.replace(/bytes=/, "").split("-") , partialstart = parts[0] , partialend = parts[1] , start = parseInt(partialstart, 10) , end = partialend ? parseInt(partialend, 10) : total - 1 , chunksize = (end - start) + 1; console.log('RANGE: ' + start + ' - ' + end + ' = ' + chunksize + "\n") response.writeHead( 206 , { 'Access-Control-Allow-Credentials': true, 'Access-Control-Allow-Origin': origin, 'Content-Range': 'bytes ' + start + '-' + end + '/' + total, 'Accept-Ranges': 'bytes', 'Content-Length': chunksize, 'Content-Type': 'video/mp4' }); } else { // if i request all the video console.log('ALL: ' + total); response.writeHead( 200, { 'Access-Control-Allow-Credentials': true, 'Access-Control-Allow-Origin': origin, 'Content-Length': total, 'Content-Type': 'video/mp4' } ); } // on-the-fly encoding var ffmpeg = child_process.spawn("ffmpeg",[ "-i", path, // path "-b:v" , "64k", // bitrate to 64k "-bufsize", "64k", "pipe:1" // Output to STDOUT ]); //pack-up everything and send back the response with the stream var file = fs.createReadStream(path); file.pipe(response);
it may be not the best code ever but it works because i receive on the client a stream of something! BUT how can i verify this? how can i actually 'see' the video in the page?
now in the client page i have a tag like this:
but i can only see a black screen in my player...
Why?
Thanks!
(feel free to correct any imprecision you see)
-
If I kill ffmpeg command its video lenght is 5 seconds shorter then the actual length ?
7 mai 2014, par Sumit JasujaI am using ffmpeg to capture screen. output is in mp4 format. when I kill ffmpeg command its video length is 5 seconds shorter then the actual length.
Process killed using following code :
foreach (Process pr in Process.GetProcessesByName("ffmpeg")) { pr.Kill(); }
-
Audio encoding using avcodec_fill_audio_frame() and memory leaks
7 mai 2014, par praks411As a part of encoding decoded audio packets, I'm using avcodec_fill_audio_frame(). I'm passing allocated AVFrame pointer to along with buffer containing the decoded samples and other parameters number of channels, sample format, buffer size. Though the encoding is working fine I'm not able to completely eliminate the memory leaks. I've taken care of most of things but still I'm not able detect the leakage. Below is the function which I'm using for encoding. Please suggest something. AudioSample contains decoded data and it is completely managed in different class(free in class destructor). I'm freeing the AVFrame in FFmpegEncoder destructor and AVPacket is freed every time using av_free_packet() with av_packet_destruct enabled. What more do I need to free?
void FfmpegEncoder::WriteAudioSample(AudioSample *audS) { int num_audio_frame = 0; AVCodecContext *c = NULL; // AVFrame *frame; AVPacket pkt; av_init_packet(&pkt); pkt.destruct = av_destruct_packet; pkt.data = NULL; pkt.size = 0; int ret = 0, got_packet = 0; c = m_out_aud_strm->codec; static int64_t aud_pts_in = -1; if((audS != NULL) && (audS->GetSampleLength() > 0) ) { int byte_per_sample = av_get_bytes_per_sample(c->sample_fmt); PRINT_VAL("Byte Per Sample ", byte_per_sample) m_frame->nb_samples = (audS->GetSampleLength())/(c->channels*av_get_bytes_per_sample(c->sample_fmt)); if(m_frame->nb_samples == c->frame_size) { #if 1 if(m_need_resample && (c->channels >= 2)) { uint8_t * t_buff1 = new uint8_t[audS->GetSampleLength()]; if(t_buff1 != NULL) { for(int64_t i = 0; i< m_frame->nb_samples; i++) { memcpy(t_buff1 + i*byte_per_sample, (uint8_t*)((uint8_t*)audS->GetAudioSampleData() + i*byte_per_sample*c->channels), byte_per_sample); memcpy(t_buff1 + (audS->GetSampleLength())/2 + i*byte_per_sample, (uint8_t*)((uint8_t*)audS->GetAudioSampleData() + i*byte_per_sample*c->channels+ byte_per_sample), byte_per_sample); } audS->FillAudioSample(t_buff1, audS->GetSampleLength()); delete[] t_buff1; } } #endif ret = avcodec_fill_audio_frame(m_frame, c->channels, c->sample_fmt, (uint8_t*)audS->GetAudioSampleData(),m_frame->nb_samples*byte_per_sample*c->channels, 0); //ret = avcodec_fill_audio_frame(&frame, c->channels, c->sample_fmt, t_buff,frame.nb_samples*byte_per_sample*c->channels, 0); if(ret != 0) { PRINT_MSG("Avcodec Fill Audio Failed ") } else { got_packet = 0; ret = avcodec_encode_audio2(c, &pkt, m_frame, &got_packet); if(ret < 0 || got_packet == 0) { PRINT_MSG("failed to encode audio ") } else { PRINT_MSG("Audio Packet Encoded "); aud_pts_in++; pkt.pts = aud_pts_in; pkt.dts = pkt.pts; pkt.stream_index = m_out_aud_strm->index; ret = av_interleaved_write_frame(oc, &pkt); if(ret != 0) { PRINT_MSG("Error Write Audio PKT ") } else { PRINT_MSG("Audio PKT Writen ") } } } } avcodec_flush_buffers(c); // avcodec_free_frame(&frame); } av_free_packet(&pkt); }
Thanks, Pradeep