The simplest mobile-based FFmpeg example: IOS video transcoding

Source: Internet
Author: User

This document records the FFmpeg-based video transcoding device under the iOS platform. The transcoding is actually ported from the FFMPEG.C source code in the FFmpeg project. For FFMPEG.C source code can refer to the article "FFMPEG.C function structure simple analysis (Drawing)", here will not repeat the record.


Source

The directory structure of the project.


The following C language files are copied from the FFmpeg source code:

CMDUTILS.C
Cmdutils.h
Cmdutils_common_opts.h
Config.h
Ffmpeg.h
Ffmpeg_filter.c
ffmpeg_opt.c

In addition to compiling the FFMPEG.C, you need to copy the following header files from the source code in addition to the header files in the FFmpeg SDK.

Libavformat/ffm.h
Libavformat/network.h
Libavformat/os_support.h
Libavformat/url.h
Libavutil/libm.h

FMPEG_MOD.C is the modified ffmpeg.c file. FFMPEG.C itself is a program used by the command line, so you need to make some changes to the source code when you change to a class library call. For example, remove some exit (0), release some variables, and the main () function is renamed Ffmpegmain ().

The code that OBJECTIVE-C calls FFmpeg is in the viewcontroller.m file, as shown in the following.
/** * Simplest FFmpeg-based transcoding-ios * simplest FFmpeg IOS transcoder * * Lei hua Lei Xiaohua * [email protected] * ma xiaoyu ma Xiaoyu * [email protected] * Communication University/Digital TV Technology * Communication University of China/digital TV technology * Http://blog.csdn.net /LEIXIAOHUA1020 * * This program is a transcoding device under the iOS platform. It is ported to the FFMPEG.C command-line tool. * * This software are a transcoder in IOS. It is transplanted from FFMPEG.C * command line tools. */#import "ViewController.h" #include "ffmpeg.h" int ffmpegmain (int argc, char **argv); @interface Viewcontroller () @    End@implementation viewcontroller-(void) viewdidload {[Super viewdidload]; Do any additional setup after loading the view, typically from a nib.}    -(void) didreceivememorywarning {[Super didreceivememorywarning]; Dispose of any resources the can be recreated.}        -(Ibaction) Clickrunbutton: (ID) sender {char command_str_full[1024]={0};    NSString *command_str= [NSString stringwithformat:@ "%@", Self.command.text]; Nsarray *argv_array=[command_str ComponentsseparatEdbystring: (@ "")];    int argc=argv_array.count;    char** argv= (char**) malloc (sizeof (char*) *ARGC);        for (int i=0;i<argc;i++) {argv[i]= (char*) malloc (sizeof (char) *1024);    strcpy (Argv[i],[[argv_array objectatindex:i] utf8string]);        } ffmpegmain (argc, argv);    for (int. i=0;i<argc;i++) Free (argv[i]);  Free (argv); } @end

Run results

The app runs on the phone as shown in the results.


After clicking the "Run" button, the program will transcode according to the command you entered. For example, the/users/leixiaohua1020/desktop/test.mp4 will be transcoded to/users/leixiaohua1020/desktop/test.mov. The resulting video file is as shown in.

Download
simplest ffmpeg mobile

Project Home

Github:https://github.com/leixiaohua1020/simplest_ffmpeg_mobile

Open source China: https://git.oschina.net/leixiaohua1020/simplest_ffmpeg_mobile


CSDN Project: http://download.csdn.net/detail/leixiaohua1020/8924391


This solution contains various examples of using FFMPEG to process multimedia on the mobile side:
[Android]
Simplest_android_player: Android interface-based video player
Simplest_ffmpeg_android_helloworld: FFmpeg-based HelloWorld program under Android platform
Simplest_ffmpeg_android_decoder: The simplest ffmpeg-based video decoder on the Android platform
Simplest_ffmpeg_android_decoder_onelib: The simplest ffmpeg-based video decoder on the Android Platform-Library edition
Simplest_ffmpeg_android_streamer: The simplest ffmpeg-based push-to-flow device under the Android platform
Simplest_ffmpeg_android_transcoder: FFmpeg command-line tool ported under Android platform
Simplest_sdl_android_helloworld: The simplest program for porting SDL to the Android platform
[IOS]
Simplest_ios_player: Video player based on iOS interface
HelloWorld program based on FFmpeg under the Simplest_ffmpeg_ios_helloworld:ios platform
The simplest ffmpeg-based video decoder under the Simplest_ffmpeg_ios_decoder:ios platform
The simplest ffmpeg based on the Simplest_ffmpeg_ios_streamer:ios platform
FFMPEG.C command-line tool ported under Simplest_ffmpeg_ios_transcoder:ios Platform

Simplest_sdl_ios_helloworld: The simplest program to migrate SDL to the iOS platform


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Simplest FFmpeg Mobile-based example: IOS video transcoding

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.