I'm using flow player 3.1.1 for streaming videos to my browser.The videos are uploaded by the users and they may upload different formats. What will be solution to stream the videos as mp4 , what ever be the format they upload. I'm currently using ffmpeg commands.
ffmpeg -i "InputFile.mp4" -sameq -vcodec libx264 -r 35 -acodec libfaac -y "OutputFile.mp4"
But video files of more size(say 100mb) are taking a minute more for laoding in to the flowplayer and buffering. I think the problem with my encoding.
Welcome your valuable Suggestions!!!
The problem come from metadata. ffmpeg put this data at the end of file, for a progressive download you must move this data at the begininng. You can use MP4Box or qt-faststart after ffmpeg process.
MP4Box -inter 1000 file.mp4 or qt-faststart in.mp4 out.mp4
Related
I'm trying to record frames that I read from an industrial camera (such as - https://en.ids-imaging.com/store/u3-3680xle.html) in my C# code as bitmaps.
I want to convert those bitmaps to video on the fly.
My solution until now was -> Sending those bitmaps to a virtual camera (e2e soft vcam) and then record the camera with ffmpeg - using this command:
-f dshow -i video=VCam -r 18 -vcodec libx264 Video.mp4
This is not working so well, because there are drop frames and the video is not smooth.
There is another way to use ffmpeg for converting those images to video on the flight?
Thank you!
I am trying to create desktop application to create video from
to capture screen.
to record sound from mic.
to merge 1 with 2 to create video.
or
any easy way to do it in c# or vb.net language.
I used aforg.net which is supporting only video.
I avoid to use third party tools, specially expensive tools.
I use ffmpeg for this, video via screen-capture-recorder (https://trac.ffmpeg.org/wiki/Capture/Desktop). I control the region that screen-capture-recorder records by writing to the registry before i start ffmpeg. I get audio from virtual audio cable (https://vac.muzychenko.net/en/) (but it's because I record a machine that has no sound card) - you should be able to do it with whatever your mic device is called. You could use something like NAudio to enumerate them, or get ffmpeg to enumerate them and parse its output - https://trac.ffmpeg.org/wiki/DirectShow
I capture two audio streams, using the following ffmpeg args
-f dshow -i video="screen-capture-recorder" -thread_queue_size 512 -f dshow -i audio="Line 2 (Virtual Audio Cable)" -f dshow -i audio="Line 3 (Virtual Audio Cable)" -map 0:v -map 1:a -map 2:a -pix_fmt yuv420p -y "{0}"
The C# app is responsible for a lot of things, such as taking a screenshot, looking for the thing I want to record, position the region, start ffmpeg etc.. But ff does the heavy lifting.. You don't even need to write any c# for starters, just get FFmpeg working from the command line and recording nicely with various buffer settings etc, then put it to a c# program with Process.Start(command, arguments)
If I take a .mp4 recorded on my mobile (Samsung S5) and pass it through FFmpeg with the below command, the output file (fileX.avi) is a greyscale bitmap uncompressed video file.
The offset values in fileX.avi (output from FFmpeg) to allow me to locate the video frame data are always 5680 bytes for the file header.
And 62 bytes for the inter frame header.
The data is uncompressed RGB24 so i can easily calculate the size of a video frame from height x width x 3.
So my C# application can access the video frames in fileX.avi always at these above offsets.
(This works great).
My FFmpeg Command is:
ffmpeg.exe -i source.mp4 -b 1150 -r 20.97 -g 120 -an -vf format=gray -f rawvideo -pixfmt gray -s 384x216 -vcodec rawvideo -y fileX.avi
However... I recently took an .mp4 file from a different source (produced by Power Director 14 instead of direct from my mobile phone) and used this as the input source.mp4. But now the structure of fileX.avi differs as the offset values of 5680 + 62 bytes from the start in fileX.avi do not land me at the start of the video data frames.
There seems to be different file formats for .mp4 - and obviously if there are my crude offset approach will not work for them all. I suspected at the time I wrote the code my method was all too easy a solution!
So can anyone advise on the approach I should take now? Should I check the original .mp4 or the output file (fileX.avi) to determine a "file type" to which I can determine the different offsets?
At the very least I need to be able to identify the "type" of .mp4 file that works so I can declare the type that will work with my software.
Hi I am using ffmpeg for windows phone which was found here. With this I am trying to convert a .ts file to .mp3 file but the command that I am using is not working for this type of conversion, I have also noted that it works for certain other format conversions such as ts to wma, ts to ogg e.t.c . The commands that I have tried are
-i sourcewithfullpath.ts destinationwithfullpath.mp3
-i sourcewithfullpath.ts
-f destinationwithfullpath.mp3
-i sourcewithfullpath.ts
-c:a libmp3lame destinationwithfullpath.mp3
-i sourcewithfullpath.ts
-acodec mp3 destinationwithfullpath.mp3
most of these gave me an AccessViolationException while calling ffmpeg.Run()
Any help is appreciated.
I think Mulvya is right MP3 encoding is not included in this FFMPEG build but I figured out another way which does not satisfy the exact need still a good option
-i sourcewithfullpath.ts
-f destinationwithfullpath.mp2
FFMPEG does support mp2 format, the file was converted to mp2 audio and renamed to mp3, it is playable in the windows phone. Please note that the compression ratio of the mp2 format is not that good compared to mp3 format which means that the output file resulted in a much greater size which was almost double.
I have successfully converted avi files to Mpeg using NREco converter http://www.nrecosite.com/video_converter_net.aspx
But, the length (duration) of the converted video is never greater than 2mins, 35 secs.
I tried using ffmpeg command line utility (https://www.ffmpeg.org/download.html or http://ffmpeg.zeranoe.com/builds/ ffmpeg 64 bit static for windows) but the length was always less than or equal to 2mins, 35 seconds.
How to increase the duration of the ffmpeg converted video?
I tried the -t command but couldn't increase the length (duration) of the converted video. Original video is a 14mins 5 sec avi file.
ffmpeg -i inputAVIfilename outputMPEGfilename
ffmpeg -i inputAVIfilename -t 90000 outputMPEGfilename
The video file has only bitmap images. No sound tracks are required.
Please note that my dll would be used with both windows & web applications.
Converting of videos of from one format to other can be done either using software or hardware. In your case you are using ffmpeg which is software based solution. Generally speaking software based solutions are a lot slower, inefficient and has many operating system restrain, and I am suspecting you have reached that limit.
I suggest that you use cloud based solution such as Azure Media service or Elementals.