Tuesday 8 January 2019

Zend Framework modules questions and answers

Zend Framework modules questions and answers

Question: What are the basic steps for create new module?
Suppose you are creating module with name of Album.
  1. Attach module with application.
    Open file i.e /config/application.config.php, Add Blog in array like below:
    return array(
         'modules' => array(
             'Application',
             'Blog'
         ),
         
     );
    
  2. create Album  folder inside the module folder.
  3. After creating the Album folder inside modules, Create below folder structure.
  4. Album/
        Module.php
        autoload_classmap.php
        autoload_function.php
        autoload_register.php
        config/
            module.config.php
        public/
            images/
            css/
            js/
        src/
            Album/
                Controller/
                    AlbumController.php
                Form/
                    AlbumForm.php
                Model/
                    Album.php 
        view/
            album/
                album/
                    index.phtml
            layout/
                layout.phtml
            error
                index.phtml
    



Question: How to attach a module in main application?
Go to File config/application.config.php, and add your module name in modules array.
See example below (We have add a module Album).
return array(
     'modules' => array(
         'Application',
         'Album'
     ),
     
 );



Question: What is Service?
A Service is an object in the module that executes complex logic of the application.
Here we do all difficult logic together and gives you easy to understand results.


Question: What are the basic steps for creating the Service?
  1. Create a folder service in-side the module and path will be similar to below:
    /module/{moduleName}/src/{moduleName}/Service/{Album}Service.php
  2. Create a model in-side the module and path will be similar to below:
    /module/{moduleName}/src/{moduleName}/Model/Post.php
  3. Add Following code in controller where you want to use.
    use {moduleName}\Service\PostServiceInterface;

    Add following in controller (you can use another variable)
    protected $postService;
     public function __construct(PostServiceInterface $postService)
         {
             $this->postService = $postService;
         }

  4. Create the Factory class (path: /module/{moduleName}/src/{moduleName}/Factory/{factoryClass}.php)
  5. Register your service in module.config.php. (Add following code)
            'service_manager' => array(
             'invokables' => array(
                 '{moduleName}\Service\{Service}' => '{moduleName}\Service\{Service}'
             )
             
  6. Register your service from module.config
    (Path: /module/Blog/config/module.config.php)
        'controllers'  => array(
             'factories' => array(
                 '{moduleName}\Controller\List' => '{moduleName}\Factory\{factoryClass}'
             )
          

Question: How to set different Db Connections for each module?
There are different module.config.php file inside each module (module/{moduleName/config/module.config.php}.
In this you you can set the database credentials.
 'db' => array(
         'driver'         => 'Pdo',
         'username'       => 'SECRET_USERNAME',  //edit this
         'password'       => 'SECRET_PASSWORD',  //edit this
         'dsn'            => 'mysql:dbname=blog;host=localhost',
         'driver_options' => array(
             \PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\''
         )
     ),



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);