I'm not familiar with FFMPEG at all and would like to know how to convert MP4 to OGV format while still keeping the same video and audio quality?
FFmpeg – How to Convert MP4 to OGV While Retaining Quality
ffmpeg
Related Solutions
If you want to just split the video without re-encoding it, use the copy
codec for audio and video. Try this:
ffmpeg -ss 00:00:00 -t 00:50:00 -i largefile.mp4 -acodec copy \
-vcodec copy smallfile.mp4
Note that this only creates the first split. The next one can be done with a command starting with ffmpeg -ss 00:50:00
.
This can be done with a single command:
ffmpeg -i largefile.mp4 -t 00:50:00 -c copy smallfile1.mp4 \
-ss 00:50:00 -c copy smallfile2.mp4
This will create smallfile1.mp4
, ending at 50 minutes into the video of largefile.mp4
, and smallfile2.mp4
, starting at 50 minutes in and ending at the end of largefile.mp4
.
Depending on the codecs used in your FLV you may be able to get away with simply re-wrapping it in an mp4 container. You'll need H.264
or MPEG4 simple profile
video and AAC
audio. You can find out some info on your source file with ffmpeg -i input.flv
I'm not sure whether simply having H.264/MPEG4 Simple + AAC is good enough or if there are specific options to the codecs that are supported. It's easy enough to test:
Try using
ffmpeg -i input.flv -c copy -copyts output.mp4
-copyts
is copy timestamps
it will help audio sync.
If that doesn't work, try forcing audio and video codecs. This will re-encode the file:
ffmpeg -i input.flv -c:v libx264 -crf 23 -c:a aac -b:a 160k output.mp4
If you want to change only the audio or only the video codec, you can use -c:a copy
or -c:v copy
to copy the one you want to keep.
To improve the video quality, you can use a lower CRF value, e.g. anything down to 18. To get a smaller file, use a higher CRF, but note that this will degrade quality.
To inprove the audio quality, choose a higher bitrate (160k in the example above).
With both the audio and video quality, your results will vary depending on the quality of the source.
more info on FFMPEG aac encoding (I've been referring to the "native" encoder described on the ffmpeg site).
Regarding the ffmpeg command suggested in the question...
-ar
refers to the audio sample rate. I recommend not messing with this parameter at all. If you want to play with audio encoding, adjust the bitrate (-b:a 160k
above) and let the encoder choose what to do based on that.
For reference, here's what it means.
CD quality is 44100Hz sampling; typical video uses 48000Hz.
You may note that 22050 in the original question's example is 1/2 the cd quality sample rate. if you are downconverting CD material this is a good choice. If you're starting with 48KHz source i'd use 24Khz instead.
You should get info on the sample rates from the ffmpeg -i
command I suggested at the top.
Best Answer
Basic command is
You'll have to fiddle with the q values for video and audio if the result's not acceptable. Lower values are better but produce bigger files. For libtheora, it's the opposite - higher values are better. Range is 0-10.