Jump to content

How to use ffmpeg converting video without decreasing of quality


hno

Recommended Posts

HI every one .

This is how I convert videoes to flv but the quality is decreasing very much .

passthru("$ffmpegpath -i uploads/$video_name -ar 22050 -ab 32k -f flv -s 480x800 uploads/vid.flv");

 

How can I convert videos without any decrease of quality ?

 

Thanks

Link to comment
Share on other sites

Don't you set what encoder to use?

 

You can try setting the bitrate to somewhere around -b 400k , and see how it does.

 

If neither -b:v nor -crf are set, the encoder will use a low default bitrate and your result will probably be poor. Always supply one of these options—ideally both.

 

If this helps you at all, I created a casting script in linux that returns extremely nice quality.

Granted I capture my screen and send this to a host, but you can modify it and also save as file.

 

I guess one reason am showing you this is to show that default is not always best, should have more parameters and tell it exactly what you want as a result.

#!bin/bash
#settings can adjust
#list of stream hosts
SecureSaw="rtmp://flash.sawlive.tv:2139/flash/stream_key";
Saw="rtmp://publish.sawlive.tv/flash/stream_key";
JTV="rtmp://live.justin.tv/app/stream_key";
Ucaster="rtmp://ucaster.eu/live/username?key=stream_key";
Mips="rtmp://mips.tv/live/username?key=stream_key&id=id";
Ustream="rtmp://1.16711620.fme.ustream.tv/ustreamVideo/stream_key";
Zecast="rtmp://live.zecast.tv/zecast/username";#http://zecast.tv/channel.php?id=username
Veemi="rtmp://live.veemi.com/live?u=username&p=stream_key/username";#http://www.veemi.com/watch?v=username
Cast7="rtmp://xxx.cast7.eu/onlive?key=stream_key/username";#http://cast7.eu/index/stream/name/username&sid=id
#select which stream host to use
StreamHost="$SecureSaw";
#video capture in and out
#keep in 8px increments or makes encoder do lots of extra work
VideoInWidth="1024"
VideoInHeight="768"
VideoOutWidth="1024"
VideoOutHeight="768"
WidthOffset="0"
HeightOffset="0"
#video cropping
CropTotalWidth="1024"
CropTotalHeight="576"
WidthCrop="0"
HeightCrop="104"

VideoFramesPerSecond="30" #suggest 24-30
VideoQuality="10" # suggest 10-30 , range is 0-68 , lower number is better quality
KeyFrames="2" #suggest 1-2
NumberAudioChannels="2" #suggest 2 stereo , 1 mono
NumberCPUcores="4" #count your logical cores
VideoBitrate="450k" #try 500k ,varies your upload speed and quality of video/audio sending
AudioBitrate="96k" #suggest 64,96,128
 
#STOP RIGHT THERE!!!
#you should not change anything below unless know what they all do
VideoInResolution="$VideoInWidth"x"$VideoInHeight"
VideoOutResolution="$VideoOutWidth"x"$VideoOutHeight"
avconv \
-f x11grab -y -s "$VideoInResolution" -g "$KeyFrames" -r:v "$VideoFramesPerSecond" -i :"$WidthOffset"."$HeightOffset" \
-f alsa -ac "$NumberAudioChannels" -i pulse -vol 1024 \
-c:a libmp3lame -ar 44100 -threads "$NumberCPUcores" \
-b:a "$AudioBitrate" \
-c:v libx264 -pix_fmt yuv420p -vsync 1 -crf "$VideoQuality" -s "$VideoOutResolution" \
-vf crop="$CropTotalWidth":"$CropTotalHeight":"$WidthCrop":"$HeightCrop" \
-b:v "$VideoBitrate" -minrate "$VideoBitrate" -maxrate "$VideoBitrate" -bufsize "$VideoBitrate" \
-y -f flv "$StreamHost" \
Edited by QuickOldCar
Link to comment
Share on other sites

Take a look here, explains and shows example codes, it really depends what the purpose is.

https://trac.ffmpeg.org/wiki/x264EncodingGuidehttps://trac.ffmpeg.org/wiki/x264EncodingGuide

 

Is a lot of older ffmpeg codes out there, they were changed a few years ago.

 

 

ffmpeg -i input -vcodec libx264 -preset fast -tune film -profile main -crf 22 -threads 0 output
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.