Monday 31 December 2018

17 FFmpeg Commands For Beginners

17 FFmpeg Commands For Beginners

#1 Getting audio/video file information
ffmpeg -i video.mp4

(use -hide_banner flag to hide information such as version, configuration details, copyright notice, build and library options etc.)


#2 Converting video files into AVI
ffmpeg -i video.mp4 video.avi

(use -qscale 0 to preserve the quality of your source video file)


#3 understand comman Abbr
-i filename (i=Input)
-vn  Indicates that we have disabled video recording in the output file.
-ar  Set the audio frequency of the output file. The common values used are 22050, 44100, 48000 Hz.
-ac  Set the number of audio channels.
-ab  Indicates the audio bitrate.
-f  Output file format. In our case, it’s mp3 format.
-b:v 64k (-b:v video bitrate)
-r 24 (change the frame rate)
-vf video filter (vf video filter)
-af audio filter (af audio filter)
-an file name (No audio)
-sn file name (No sub-title)
-dn file name (No data-stream)



#4 Change resolution of video files
ffmpeg -i input.mp4 -filter:v scale=1280:720 -c:a copy output.mp4



#5 Compressing video files
ffmpeg -i input.mp4 -vf scale=1280:-1 -c:v libx264 -preset veryslow -crf 24 output.mp4



#6 Compressing Audio files
ffmpeg -i input.mp3 -ab 128 output.mp3

96kbps
112kbps
128kbps
160kbps
192kbps
256kbps
320kbps


#7 Removing audio stream from a media file
ffmpeg -i input.mp4 -an output.mp4



#8 Removing video stream from a media file
ffmpeg -i input.mp4 -vn output.mp3



#9 Cropping videos
ffmpeg -i input.mp4 -croptop 100 -cropbottom 100 -cropleft 300 -cropright 300 output.mp4



#12 Set the aspect ratio to video
ffmpeg -i input.mp4 -aspect 16:9 output.mp4



#13 Trim a media file using start and stop times
ffmpeg -i input.mp4 -ss 00:00:50 -codec copy -t 50 output.mp4



#14 Changing resolution and Reencoding
ffmpeg -i 1.mp4 -vf scale=1280:720 -acodec aac -vcodec libx264   NewFile.mp4 -hide_banner



#15 Joining multiple video parts into one
ffmpeg -f concat -i join.txt -c copy output.mp4

(join.txt will have path of all videos)


#16 Add subtitles to a video file
fmpeg -i input.mp4 -i subtitle_file.srt -map 0 -map 1 -c copy -c:v libx264 -crf 23 -preset veryfast output.mp4



#17 Increase video playback speed
ffmpeg -i inputvideo.mp4 -vf "setpts=0.5*PTS" outputvideo.mp4





Question: How to execute ssh command in PHP and get the results?
exec("ls",$o);
print_r($o);




Sunday 30 December 2018

Zend Framework 2 Session Management - Add Update Delete Session

Zend Framework 2 Session Management - Add Update Delete Session


Question: What is Zend Session?
A Session is a way to store information (in variables) to be used across multiple pages. It is mainly used to check for login information on browser and track the user activies. Zend Session is Zend libery for Session which helps to manage the session data.


Question: What is difference between Session Manager and Session Container?
Zend\Session\Container instances provide the primary API for manipulating session data. Containers are used to segregate all session data. Zend\Session\SessionManager, is a class that is responsible for all aspects of session management. It is used to initializes and configuration, storage and save handling.


Question: What is difference between Session Manager and Session Container and Session Config in One line each?
Container: The provides the core interface for managing session data.
SessionConfig: Handles setting for session config options.
SessionManager: Handles session management such as session start/exists/write/regenerate id/time-to-live/and destroy and session validation.


Question: Can you store session data in database?
Yes, we can.
For this we need to set the configuration like below:
use Zend\Db\TableGateway\TableGateway;
use Zend\Session\SaveHandler\DbTableGateway;
use Zend\Session\SaveHandler\DbTableGatewayOptions;
use Zend\Session\SessionManager;

$tableGateway = new TableGateway('session', $adapter); //this is table where session will store, you need to create the table and its model also.
$saveHandler  = new DbTableGateway($tableGateway, new DbTableGatewayOptions());
$manager      = new SessionManager();
$manager->setSaveHandler($saveHandler);


Question: How to set the Defualt Session Mangaer for Session Container?
use Zend\Session\Container;
use Zend\Session\SessionManager;

$manager = new SessionManager();
Container::setDefaultManager($manager);



Question: How to create session Object?
use Zend\Session\Container;
$sessionObj = new Container('sessinName');



Question: How to set Session value?
$sessionObj->offsetSet('email', 'email@domain.com');



Question: How to get Session value?
$sessionObj->offsetGet('email');



Question: How to check Session value exist OR Not?
$sessionObj->offsetExists('email');



Question: How to unset the session value?
$sessionObj->offsetUnset('email');