How To Convert MP4 Video File into FLV Format Using FFMPEG - ffmpeg

i have to Convert MP4 Video File into FLV Format Using FFMPEG which i received from different mobile device. i found most of the stuff to convert flv video into mp4 and all.
can any body help me out to convert mp4 format into flv using FFMPEG. i am using windows 7 64bit machine.

I'm late, but if this can help somebody, it's time well spent.
If I understand correctly, you want to convert MP4 to FLV using FFMPEG. Here are two command lines to help you do that; I'm currently using them myself (you can adjust them to your needs too) :
ffmpeg -i source.mp4 -c:v libx264 -crf 19 destinationfile.flv
and if the first one doesn't work :
ffmpeg -i source.mp4 -c:v libx264 -ar 22050 -crf 28 destinationfile.flv
Please note that -crf XX is the quality of the video you will create. It's between 0 and 51 (but between 17 and 23 is a reasonable range and the lower the number is, the better quality the video is going to be).
The -ar 22050 is for adjusting the audio sample range (audio quality). You can choose 11025, 22050 or 44100.
I suggest you read this Tutorial for FFMPEG . It's really complete and has many useful tips.
Hope this will help you or somebody in the same situation.

Related

FFmpeg raw h.264 set pts value

I am currently using ffmpeg to convert a custom container media format to mp4. It is straightforward to dump all the h.264 frames to one file and the aac audio to another. Then I can combine the two and create an mp4 file with ffmpeg.
The problem is that the video source isn't always perfect. From time to time frames are dropped or late etc. This causes an A/V sync issue since the pts is generated using a constant rate by ffmpeg. The source format I am using has the PTS value but I cant figure out a way to pass it to ffmpeg with the raw h.264 frames.
I suppose it would be possible to create a demuxer for the custom format, but it seems like a lot effort. I looked into ffmpeg's .nut container format thinking that I might be able to convert from the custom container to .nut first. Unfortunately it seems more complex than it looks on the surface.
It seems like there should be an easy way to pass a frame and its PTS value to ffmpeg, but I haven't come across it yet. Any help would be appreciated.
Here is the ffmpeg command I am using
ffmpeg -f s16le -ac 1 -ar 48k -i source.audio -framerate 20 -i source.video -c:a aac -b:a 64k -r 20 -c:v h264_nvenc -rc:v vbr_hq -cq:v 19 -n out.mp4

Playing MP4 file in Powerpoint

I have a huge MP4 file (4GB) an hour long video. I want to extract port of the file. So I used the following command to extract 70 seconds(00:01:10) of video starting from 11 minutes
ffmpeg -i INPUT.mp4 -ss 00:11:00 -t 00:01:10 -c:v copy -c:a copy OUTPUT.mp4
Now I got a small file extracted from Input.MP4
The output.mp4 file size is still big(90 MB). So I used the following command
ffmpeg -i OUTPUT.mp4 -c:v libx264 -crf 30 SmallSizeVideo.avi
I got SmallSizeVideo.avi file which is approximately 6MB.
I am using Powerpoint 2010. I want to insert the video in Powerpoint and play.
Unfortunately when I embed SmallSizeVideo.avi Powerpoint is unable to play
1) Is my approach correct?
2) What is the best way to situation like me to play small portion of clips in powerpoint
Thank you
Last I heard, h.264 in avi was nonstandard. Try instead to output as mp4 and see if that plays in PowerPoint:
ffmpeg -i OUTPUT.mp4 -c:v libx264 -crf 30 SmallSizeVideo.mp4
If it works, I believe it may work in Windows 7 or later and also OS X.
I had the same issue and had to stay for PowerPoint 2010 at Windows 10. Thus, PowerPoint is unable to play MP4, cf. https://support.office.com/en-gb/article/Video-and-audio-file-formats-supported-in-PowerPoint-d8b12450-26db-4c7b-a5c1-593d3418fb59. Finally, I come up with this command:
ffmpeg.exe -i input.mp4 -c:v wmv2 -b:v 12024k -c:a wmav2 -b:a 128k output.wmv
This command based on https://stackoverflow.com/a/34851916/2258393 by Reinhard Behrens.
By means of this command, I am able to archive the same file size and approx. the same quality as with MP4.

How add scale in my ffmpeg command

i want convert video from any format to mp4. so i am using command:
ffmpeg -i ttt.mp4 -vcodec copy -acodec copy test.mp4
this is working perftectly but now i also add scale in this -s 320:240.
There also many other command for convert LIKE :
ffmpeg -i inputfile.avi -s 320x240 outputfile.avi
but after convert by this command video not play in html5 player
BUT this is not working so tell me in my command how i add scale;
So please provide me solution for this .
Thanks in advance.
You have several problems:
In your command, you have -vcodec copy you cannot scale video without reencoding.
In the command you randomly found on the Internet, they are using AVI, which is not HTML5-compatible.
What you should do is:
ffmpeg -i INPUT -s 320x240 -acodec copy OUT.mp4
Adding to Timothy_G:
Video copy will ignore the video filter chain of ffmpeg, so no scaling is available (man ffmpeg is a great source of information that you will not find on Google). Notice that once you start decoding-filtering-encoding (i.e., no copy) the process will be much slower (x100 time slower or even more). The libx264 is recommended if you want compatibility with all browsers.
$ ffmpeg -i INPUT -s 320x240 -threads 4 -c:a copy -c:v libx264 OUT.mp4
vp9 will provide nearly 50% extra bandwidth saving, but only for supported browsers (Firefox/Chrome), and the encoding will much slower compared to libx264 (that itself is much slower that v:c copy):
$ ffmpeg -i INPUT -s 320x240 -c:a copy -c:v vp9 OUT.webm
Notice that there is a set of formats (containers) accepted by browsers (most admit mp4, some also webm, ...) and for each format there is a set of audio/video codecs accepted. For example you can use mp3 or aac with an mp4 file (container), but not with webm files.
http://en.wikipedia.org/wiki/HTML5_video#Supported_video_formats

Using FFMPEG to losslessly convert YUV to another format for editing in Adobe Premier

I have a raw YUV video file that I want to do some basic editing to in Adobe CS6 Premiere, but it won't recognize the file. I thought to use ffmpeg to convert it to something Premiere would take in, but I want this to be lossless because afterwards I will need it in YUV format again. I thought of avi, mov, and prores but I can't seem to figure out the proper command line to ffmpeg and how to ensure it is lossless.
Thanks for your help.
Yes, this is possible. It is normal that you can't open that raw video file since it is just raw data in one giant file, without any headers. So Adobe Premiere doesn't know what the size is, what framerate ect.
First make sure you downloaded the FFmpeg command line tool. Then after installing you can start converting by running a command with parameters. There are some parameters you have to fill in yourself before starting to convert:
What type of the YUV pixel format are you using? The most common format is YUV4:2:0 planar 8-bit (YUV420p). You can type ffmpeg -pix_fmts to get a list of all available formats.
What is the framerate? In my example I will use -r 25 fps.
What encoder do you want to use? The libx264 (H.264) encoder is a great one for lossless compression.
What is your framesize? In my example I will use -s 1920x1080
Then we get this command to do your compression.
ffmpeg -f rawvideo -vcodec rawvideo -s 1920x1080 -r 25 -pix_fmt yuv420p -i inputfile.yuv -c:v libx264 -preset ultrafast -qp 0 output.mp4
A little explanation of all other parameters:
With -f rawvideo you set the input format to a raw video container
With -vcodec rawvideo you set the input file as not compressed
With -i inputfile.yuv you set your input file
With -c:v libx264 you set the encoder to encode the video to libx264.
The -preset ultrafast setting is only speeding up the compression so your file size will be bigger than setting it to veryslow.
With -qp 0 you set the maximum quality. 0 is best, 51 is worst quality in our example.
Then output.mp4 is your new container to store your data in.
After you are done in Adobe Premiere, you can convert it back to a YUV file by inverting allmost all parameters. FFmpeg recognizes what's inside the mp4 container, so you don't need to provide parameters for the input.
ffmpeg -i input.mp4 -f rawvideo -vcodec rawvideo -pix_fmt yuv420p -s 1920x1080 -r 25 rawvideo.yuv

JPG join MP3 to FLV

How to convert image and music to video? I would like YouTube video. I like FFMPEG command or other Ubuntu free software. I would like: *.mp3 + *.jpg = *.flv
Here is an example using a recent ffmpeg syntax:
ffmpeg -loop 1 -i image.jpg -i music.mp3 -shortest -c:v libx264 -crf 20 -tune stillimage -c:a copy output.mkv
This example will copy the audio instead of re-encoding to preserve quality. Adjust quality if desired with the CRF option. See the FFmpeg and x264 Encoding Guide for more information.
Super User (another StackExchange site) is a better place for ffmpeg usage questions since Stack Overflow is programming specific.
Today I was in need of merging an image and an audio file into a video file. Since none of the answers that I found on SO worked for me, I'm leaving here what worked for me after trial and error:
ffmpeg -loop 1 -t 205 -i audio.mp3 -i image.jpg -crf 20 test.flv
Where 205 is the duration of the input mp3 file in seconds -> 3:25 minutes.
(Tested with FFmpeg SVN-r13582)

Resources