Posted in Frameworks, Java

FFmpeg – A complete, cross-platform solution to record, convert and stream audio and video.

java_logo_100ffmpeg

Nowaday, the Audio and Video are so popular. As a developer, you have many works to process them such as record, convert, stream, etc.

Actually, if you are an Java-er, C#-er, etc, it is really difficult to find the way to do that with pure language programming.

Today, I want to introduce one powerful ‘tool’ which can do these tasks quickly. It is FFMPEG.

FFMPEG is a complete, cross-platform solution to record, convert and stream audio and video. After using it, I found that converting video and audio has never been so easy ! You only use commands and option which are supported, only one line command ! Wow

Please find detail at below website:

http://www.ffmpeg.org/

Look at below commant to converting a .mp4 file to .avi file:

ffmpeg -i input.mp4 output.avi

Run it and Done ! You have a AVI file. How it is easy !

Because the FFMPEG is a cross-platform, so you can use it in any popular OS today such as Window, Linux, MAC OS, etc.

Beside running pure FFMPEG command directly, you can use it in your project using Java, C#, etc.

For Java, you only define a certain FFMPEG command and run it using Process object like below code:

String exeCommand = “ffmpeg -i your_input_file your_output_file”

// Run FFMPEG command
Process process = Runtime.getRuntime().exec(exeCommand);

Done. You can find the demo JAVA code using FFMPEG at Github here.

Share this topic if it is helpful 🙂

Thank you

 

Advertisements
Posted in Java

[Java] Java instruction for Beginner.

java_logo_100

Hi Java beginner :), if you are a Java newcomer, I think you will have many questions such as: where should I begin ? How to learn Java ? Where are good Java lession ? etc.

So, I will list some items from low to high for you. They are tools, forums, framework, design, etc. I will update this topic with new other items day-by-day and I hope it can help you :). Ok, let start:

  1. IDE tool for Java programming: eclipse, Netbean, (I like using Eclipse than Netbean 🙂 )
  2. Java Forums: java_on_stackoverflow
  3. Helpful Java frameworks: JavaFX, Springs, Hibernate, etc
  4. OO Design: http://www.oodesign.com/
  5. Basic Java tutorial: http://www.w3schools.in/java-tutorial/intro/

Share this topic if it is helpful 🙂

Posted in Cloud, JavaScript

[Cloud] Kii Cloud – helpfull script Server Code

kii

Kii Cloud is one of powerful cloud for developer. It provides a helpful data storage solution. So, the developer donot need to care the way store data.

The Kii Cloud also provide one strong feature that is Server Code. When you create a new project on Kii cloud, a Server Code for that project is created. You can make your own Server Code then deploy it to your project. I worked with Server Code for some projects, I used it to create triggers, scheduler, etc.

For example: you can create a trigger for a certain record which is inserted into one bucket (table), then Server Code will call your trigger function to do something automatically.

For Server Code implementation, please refer this guide

I created some useful script (for Window system) to help working on Server Code more convenient. I hope it is helpful for person who work on Server Code of Kii Cloud.

The script for Window system has 3 main part:

Part 1: define configuration for Kii project:

set kiiDeveloperLogFodder=%cd%\Kii_Logger
set KiiLogFile=”D:\KiiLogFile.txt”
set ServerCodeFilePath=”D:\your_server_code_path\servercode.js”
set HookConfigFilePath=”D:\your_hookConfig_path\hookConfig\hookConfig.json”

echo %kiiDeveloperLogFodder%

del %KiiLogFile%

set APP_ID=your_app_id
set APP_KEY=your_app_key
set CLIENT_ID=your_client_id
set CLIENT_SECRET=your_client_secret

set KiiSite=jp
set dateFrom=2015-11-18
set dateTo=2018-11-18
set codeVersion=your_code_version
set userId=your_user_id

set expectedLogLinesNumber=1500

set appKeys=–site %KiiSite% –app-id %APP_ID% –app-key %APP_KEY% –client-id %CLIENT_ID% –client-secret %CLIENT_SECRET%
set fromDateToDate=–date-from %dateFrom% –date-to %dateTo%
set userIdCommand=–user-id %userId%
set expectedLogLinesCommand=–num %expectedLogLinesNumber%
set infoLevelCommand=–level INFO
set debugLevelCommand=–level DEBUG
set errorLevelCommand=–level ERROR

Part 2: define Option for each script

set option_1=”Get Kii log”
set option_2=”Deploy Server Code”
set option_3=”List the Available Versions”
set option_4=”Get your Server Code”
set option_5=”Get Server Hook Config File”
set option_6=”List Server Code Execution Results”
set option_7=”Get the Detailed Execution Result”
set option_8=”NA”
set option_9=”NA”

ECHO 1) %option_1%
ECHO 2) %option_2%
ECHO 3) %option_3%
ECHO 4) %option_4%
ECHO 5) %option_5%
ECHO 6) %option_6%
ECHO 7) %option_7%
ECHO 8) %option_8%
ECHO 9) %option_9%

ECHO.

CHOICE /C 123456789 /M “Enter your choice:”

:: Note – list ERRORLEVELS in decreasing order
IF ERRORLEVEL 9 GOTO option_9
IF ERRORLEVEL 8 GOTO option_8
IF ERRORLEVEL 7 GOTO option_7
IF ERRORLEVEL 6 GOTO option_6
IF ERRORLEVEL 5 GOTO option_5
IF ERRORLEVEL 4 GOTO option_4
IF ERRORLEVEL 3 GOTO option_3
IF ERRORLEVEL 2 GOTO option_2
IF ERRORLEVEL 1 GOTO option_1

Part 3: define script contents to run for options which are defined at Part 2

:option_1
ECHO %option_1%
rem Get Kii log
node bin/kii-logs.js -t %appKeys% > %KiiLogFile%
GOTO End

:option_2
ECHO %option_2%
rem Deploy Server Code ==> Make sure that you update 2 files: KiiServerCode/servercode.js & KiiHookConfig/hookConfig.json
node bin/kii-servercode.js deploy-file –file ../KiiServerCode/servercode.js %appKeys% –hook-config ../KiiHookConfig/hookConfig.json
GOTO End

Result:

kii_servercode_script_result

PS: You also find full of scripts from my Github at KiiCloudServerCodeScript (Remember read README file before running scripts)

Share this topic if it is helpful 🙂