Thursday, October 18, 2012

create thumbnail using ffmpeg php

/In your ffmpeg.exe file path
$ffmpeg_path = 'ffmpeg';

//In your video file
$video_path = 'video_old.mp4';

// Image destination path
$image = "video_old".time().'.jpg';

// default time to get the image
$second = 1;

// get the duration and a random place within that
$comd = "$ffmpeg_path -i $video_path -deinterlace -an -ss $second -t 00:00:01 -r 1 -y -vcodec mjpeg -f mjpeg $image 2>&1";

shell_exec($comd);

Saturday, March 31, 2012

CodeIgniter - frontend language files editor.

Ref Url: http://blog.codebusters.pl/en/entry/codeigniter-frontend-language-files-editor


CodeIgniter - frontend language files editor

I was looking for frontend language files editor suitable for my needs. Unfortunately I failed to find a solution that suits me ( maybe type-o in keywords ;o) ). Therefore I decided to create my own piece of code.

Hence I present my little contribution to CodeIgniter.

Now you can find this project on github! :o)

Frontend Language Files Editor on github

Basic idea

  • Using Language Class my files for language are stored in /my_application_folder/language/.
  • I want edit all pairs key=>value for languages without opening my file. Add new keys which will be enable for another languages.
  • I want to create new languages, new files and copy structure of file to another language.
  • I want to delete languages or files.
  • I want to delete one key from all files and from database.
  • I want to remove keys from database for file if file does not exist in other languages.
  • I want to create backup file just in case.

50frontned_files_editor_1

So basically keys will be stored in database. If I add new key, save file in which I add it, and then go to edit this file in other language that new key will show up in form. But remember, new key physically will not be in another languages files until you save them.

Requirements

Codeigniter 2.x, jQuery

Installation

Grab it from github and extract to corresponding folders.

Be aware that there is application/core/My_Lang.php file, so if you use i18n for multilanguage most likely you have MY_Lang in that folder already. So be sure that you want to overwrite it.

How it works

49frontned_files_editor_2

You call it by entering address: http://yourdomainhere/language/

The list of languages are created by folder structure in /my_application_folder/language/.

The list of files are created by content in language directory. Only .php files are considered and backup files are excluded.

When you choose some file for the first time (keys are not in database) you will be asked if you want to add them.

If there are some differences between keys in file and keys in database we have two options.

1. Some keys exists in file and not in database - you will be asked if you want to add them. Until than, that keys will not be available in form. Warning! If you save your file before adding those keys, the translation and key will be erased from the file.

2. Some keys exists in database and not in the file - you will see (NEW!) next to key name. You will see that most likely when new key was added to the file in other language.

In case anything goes wrong (I hope not) I added copy function which creates backup file so you can restore last file after crash. Better be save than sorry ;o)

If you delete key from file it is also deleted from other languages and database.

All translations are escaped by addslashes php function. So if you're using $this->lang->line('key') and there was some escaping, remember to use stripslashes before you echo $this... You could also use core/My_Lang.php file which already has it. Then you don't have to worry about that.

If you have CSRF protection on - remember that it has expire time - so don't edit your files too long ;o)

I assume that if you want a line break in your translation, you need to add
tag.

This frontend already use language class. All buttons, information etc are already put into language_lang.php file so you can translate it into your language.

If you have some questions/suggestions/problems feel free to ask.