Newest 'ffmpeg' Questions - Stack Overflow
Les articles publiés sur le site
-
Retrieving current frame number
2 avril 2015, par SolidusI am doing a project which involves a bit of video recording and editing and I am struggling to find a good C++ library to use. I am using QT as my framework and their video player is not working properly for me to use (seeking crashes some times, e.g.). Also, I need to record video and audio from my camera and QCamera does not work in windows (for recording).
On my program the user can draw on top of the video and I need to store the start frame and the end frame of those drawings.
Right now I've been testing Libvlc which almost does what I want. From what I can see they don't have a way to just jump to a certain frame as this can only be done by time or position.
The first solution that I came up with was to capture the time change event and then calculate the frame using the FPS. The problem is that, as far as I can tell, the interval of this event is around 250ms, which for a 15fps video is almost 4 frames.
So, the second solution was to use libvlc_video_set_callbacks to make my own "lock, unlock and display" and count the frames there. This works for recording from the camera, as there is no going back and the frames go from 0 until the video stops. The problem is when playing a video. Since there is no timestamp, as far as I can tell, there is no way for me to know in which frame number I am (the user can be seeking for example). My "hacky" solution was to have a "lastTime" and "numTimes" on the struct I pass into these callbacks and this is what I do:
lastTime represents the "last new time" received and numTimes represents the number of times lastTime was received.
get_the_current_time calculate_frame_num_with_fps if current_time is equal to lastTime: frameNum += numTimes numTimes++ else lastTime = current_time numTimes = 1
This kinda works but I hate the solution. I'm not sure if when doing seeking the time changes if the difference is less than 250ms. That would maybe be kinda hard for a user to do but I'd prefer not to implement it like that.
So my question is if there is another solution for this? If not, any libraries that could help me on this? I know about FFMPEG which seems would solve me this problem as it's more low level and I could implement this solution. The problem is my deadline is approaching and that would still me take some time (learning the library and doing all the work). So I was thinking of it as a last resort.
Thank you for your time.
-
LibVLC : Retrieving current frame number
2 avril 2015, par SolidusI am doing a project which involves a bit of video recording and editing and I am struggling to find a good C++ library to use. I am using QT as my framework and their video player is not working properly for me to use (seeking crashes some times, e.g.). Also, I need to record video and audio from my camera and QCamera does not work in windows (for recording).
On my program the user can draw on top of the video and I need to store the start frame and the end frame of those drawings.
Right now I've been testing Libvlc which almost does what I want. From what I can see they don't have a way to just jump to a certain frame as this can only be done by time or position.
The first solution that I came up with was to capture the time change event and then calculate the frame using the FPS. The problem is that, as far as I can tell, the interval of this event is around 250ms, which for a 15fps video is almost 4 frames.
So, the second solution was to use libvlc_video_set_callbacks to make my own "lock, unlock and display" and count the frames there. This works for recording from the camera, as there is no going back and the frames go from 0 until the video stops. The problem is when playing a video. Since there is no timestamp, as far as I can tell, there is no way for me to know in which frame number I am (the user can be seeking for example). My "hacky" solution was to have a "lastTime" and "numTimes" on the struct I pass into these callbacks and this is what I do:
lastTime represents the "last new time" received and numTimes represents the number of times lastTime was received.
get_the_current_time calculate_frame_num_with_fps if current_time is equal to lastTime: frameNum += numTimes numTimes++ else lastTime = current_time numTimes = 1
This kinda works but I hate the solution. I'm not sure if when doing seeking the time changes if the difference is less than 250ms. That would maybe be kinda hard for a user to do but I'd prefer not to implement it like that.
So my question is if there is another solution for this? If not, any libraries that could help me on this? I know about FFMPEG which seems would solve me this problem as it's more low level and I could implement this solution. The problem is my deadline is approaching and that would still me take some time (learning the library and doing all the work). So I was thinking of it as a last resort.
Thank you for your time.
-
Can't obtain thumbnail with ffmpeg codeigniter
2 avril 2015, par DMBorgesI have used the following tutorial ( https://www.youtube.com/watch?v=qT4hN5o57hI) to try to obtain a thumbnail from a uploaded video using codeigniter as a framework. As I am new to all this I don't understand if at the end of supposedly uploading my video the code failed to create a thumbnail, if my created thumbnail is somewhere lost in my computer of by some settings reasons ffmpeg is not working.
Where does my $imageFile goes to?
Here is my code.
MY VIEW
<?php echo form_open_multipart('gallery/save/'); ?>Video <?php echo form_upload('pic'); ?> Descrição <?php echo form_input('description'); ?> <?php echo form_submit('upload', 'Guardar', 'class="btn btn-primary"'); ?> MY CONTROLLER
<?php class Gallery extends CI_Controller{ public function index(){ //Load View $data['main_content'] = 'gallery'; $this->load->view('layouts/main', $data); } public function save() { $url = $this->do_upload(); $ffmpeg = "C:\\xampp\\htdocs\\ffmpeg\\bin"; $videoFile = $_FILES["pic"]["tmp_name"]; $imageFile = "1.jpg"; $size = "120x90"; $getFromSecond = 5; $cmd = "$ffmpeg -i $videoFile -an -ss $getFromSecond -s $size $imageFile "; echo $cmd; if(!shell_exec($cmd)){ echo 'thumbnail created!'; } else { echo 'ERROR!'; } /* $config = array( 'source_image' => $url, 'new_image' =>"./assets/images/gallery/thumbs/", 'maintain_ration' => true, 'width' => 150, 'height'=> 100 ); $this -> load -> library('image_lib', $config); $this ->image_lib-> resize(); $description = $_POST["description"]; $user = $this->session->userdata('user_id'); $this->Gallery_model->save($description, $url, $user); redirect('gallery'); */ } private function do_upload() { $type = explode('.', $_FILES["pic"]["name"]); $type = strtolower($type[count($type)-1]); $id = uniqid(rand()); $url = "./assets/images/gallery/".$id.'.'.$type; if(in_array($type, array("wmv", "mp4", "avi", "flv"))) if(is_uploaded_file($_FILES["pic"]["tmp_name"])) if(move_uploaded_file($_FILES["pic"]["tmp_name"],$url)) return $url; return ""; } }
-
FFmpeg keep FLV input stream connection open
1er avril 2015, par MKN Web SolutionsI'm trying to get ffmpeg to stream a constant generated FLV file from another relay. Is there a way to have ffmpeg buffer X seconds and the continually pull from the FLV? The FLV has it's size set to 2GB.
-
FFMPEG HLS stream not buffering in video.js
1er avril 2015, par vedeojunkyI'm using the command below to generate an HLS stream that I'm then playing via video.js This is running on an EC2 instance and I think the output network bandwidth might be pretty low as I can't get the video to play without chugging and stopping every once in a while.
Do you know if there are any other ffmpeg settings I should use to make the streaming better?
Is there any setting in Video.JS that could allow me to setup a buffer time within the player?
Any idea why the buffer setting in FFMPEG is not taken into account in Video.JS?
ffmpeg -f x11grab -s 1280x720 -framerate 60 -r 30 -i :0.0+nomouse -f alsa -ac 2 -i pulse -vcodec libx264 -acodec libfdk_aac -crf 23 -pix_fmt yuv420p -s 640x360 -bufsize 2000k -g 30 -f hls -hls_time 1 -hls_list_size 0 -hls_allow_cache 1 -tune zerolatency index.m3u8