flutter_ffmpeg_example.dart 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644
  1. import 'dart:async';
  2. import 'dart:io';
  3. import 'package:flutter/material.dart';
  4. import 'package:flutter/services.dart';
  5. import 'package:flutter_ffmpeg/flutter_ffmpeg.dart';
  6. import 'package:flutter_ffmpeg/log_level.dart';
  7. import 'package:path/path.dart';
  8. import 'package:path_provider/path_provider.dart';
  9. void main() => runApp(FlutterFFmpegTestApp());
  10. class FlutterFFmpegTestApp extends StatelessWidget {
  11. @override
  12. Widget build(BuildContext context) {
  13. return MaterialApp(
  14. theme: ThemeData(
  15. primaryColor: Color(0xFFF46842),
  16. ),
  17. home: MainPage(),
  18. );
  19. }
  20. }
  21. class MainPage extends StatefulWidget {
  22. @override
  23. FlutterFFmpegTestAppState createState() => new FlutterFFmpegTestAppState();
  24. }
  25. class DecoratedTabBar extends StatelessWidget implements PreferredSizeWidget {
  26. DecoratedTabBar({@required this.tabBar, @required this.decoration});
  27. final TabBar tabBar;
  28. final BoxDecoration decoration;
  29. @override
  30. Size get preferredSize => tabBar.preferredSize;
  31. @override
  32. Widget build(BuildContext context) {
  33. return Stack(
  34. children: [
  35. Positioned.fill(child: Container(decoration: decoration)),
  36. tabBar,
  37. ],
  38. );
  39. }
  40. }
  41. class VideoUtil {
  42. static Future<Directory> get tempDirectory async {
  43. return await getTemporaryDirectory();
  44. }
  45. static Future<File> copyFileAssets(String assetName, String localName) async {
  46. final ByteData assetByteData = await rootBundle.load(assetName);
  47. final List<int> byteList = assetByteData.buffer.asUint8List(assetByteData.offsetInBytes, assetByteData.lengthInBytes);
  48. final String fullTemporaryPath = join((await tempDirectory).path, localName);
  49. return new File(fullTemporaryPath).writeAsBytes(byteList, mode: FileMode.writeOnly, flush: true);
  50. }
  51. static Future<String> assetPath(String assetName) async {
  52. return join((await tempDirectory).path, assetName);
  53. }
  54. static String generateEncodeVideoScript(String image1Path, String image2Path, String image3Path, String videoFilePath, String videoCodec, String customOptions) {
  55. return "-hide_banner -y -loop 1 -i " +
  56. image1Path +
  57. " " +
  58. "-loop 1 -i " +
  59. image2Path +
  60. " " +
  61. "-loop 1 -i " +
  62. image3Path +
  63. " " +
  64. "-filter_complex " +
  65. "[0:v]setpts=PTS-STARTPTS,scale=w=\'if(gte(iw/ih,640/427),min(iw,640),-1)\':h=\'if(gte(iw/ih,640/427),-1,min(ih,427))\',scale=trunc(iw/2)*2:trunc(ih/2)*2,setsar=sar=1/1,split=2[stream1out1][stream1out2];" +
  66. "[1:v]setpts=PTS-STARTPTS,scale=w=\'if(gte(iw/ih,640/427),min(iw,640),-1)\':h=\'if(gte(iw/ih,640/427),-1,min(ih,427))\',scale=trunc(iw/2)*2:trunc(ih/2)*2,setsar=sar=1/1,split=2[stream2out1][stream2out2];" +
  67. "[2:v]setpts=PTS-STARTPTS,scale=w=\'if(gte(iw/ih,640/427),min(iw,640),-1)\':h=\'if(gte(iw/ih,640/427),-1,min(ih,427))\',scale=trunc(iw/2)*2:trunc(ih/2)*2,setsar=sar=1/1,split=2[stream3out1][stream3out2];" +
  68. "[stream1out1]pad=width=640:height=427:x=(640-iw)/2:y=(427-ih)/2:color=#00000000,trim=duration=3,select=lte(n\\,90)[stream1overlaid];" +
  69. "[stream1out2]pad=width=640:height=427:x=(640-iw)/2:y=(427-ih)/2:color=#00000000,trim=duration=1,select=lte(n\\,30)[stream1ending];" +
  70. "[stream2out1]pad=width=640:height=427:x=(640-iw)/2:y=(427-ih)/2:color=#00000000,trim=duration=2,select=lte(n\\,60)[stream2overlaid];" +
  71. "[stream2out2]pad=width=640:height=427:x=(640-iw)/2:y=(427-ih)/2:color=#00000000,trim=duration=1,select=lte(n\\,30),split=2[stream2starting][stream2ending];" +
  72. "[stream3out1]pad=width=640:height=427:x=(640-iw)/2:y=(427-ih)/2:color=#00000000,trim=duration=2,select=lte(n\\,60)[stream3overlaid];" +
  73. "[stream3out2]pad=width=640:height=427:x=(640-iw)/2:y=(427-ih)/2:color=#00000000,trim=duration=1,select=lte(n\\,30)[stream3starting];" +
  74. "[stream2starting][stream1ending]blend=all_expr=\'if(gte(X,(W/2)*T/1)*lte(X,W-(W/2)*T/1),B,A)\':shortest=1[stream2blended];" +
  75. "[stream3starting][stream2ending]blend=all_expr=\'if(gte(X,(W/2)*T/1)*lte(X,W-(W/2)*T/1),B,A)\':shortest=1[stream3blended];" +
  76. "[stream1overlaid][stream2blended][stream2overlaid][stream3blended][stream3overlaid]concat=n=5:v=1:a=0,scale=w=640:h=424,format=yuv420p[video]" +
  77. " -map [video] -vsync 2 -async 1 " +
  78. customOptions +
  79. "-c:v " +
  80. videoCodec +
  81. " -r 30 " +
  82. videoFilePath;
  83. }
  84. }
  85. class FlutterFFmpegTestAppState extends State<MainPage> with TickerProviderStateMixin {
  86. static const String ASSET_1 = "1.jpg";
  87. static const String ASSET_2 = "2.jpg";
  88. static const String ASSET_3 = "3.jpg";
  89. final FlutterFFmpeg _flutterFFmpeg = new FlutterFFmpeg();
  90. TextEditingController _commandController;
  91. TabController _controller;
  92. String _commandOutput;
  93. String _encodeOutput;
  94. String _currentCodec;
  95. List<DropdownMenuItem<String>> _codecDropDownMenuItems;
  96. @override
  97. void initState() {
  98. super.initState();
  99. _commandController = TextEditingController();
  100. _controller = TabController(length: 2, vsync: this);
  101. _commandOutput = "";
  102. _encodeOutput = "";
  103. _codecDropDownMenuItems = _getCodecDropDownMenuItems();
  104. _currentCodec = _codecDropDownMenuItems[0].value;
  105. startupTests();
  106. prepareAssets();
  107. }
  108. void startupTests() {
  109. getFFmpegVersion().then((version) => print("FFmpeg version: $version"));
  110. getPlatform().then((platform) => print("Platform: $platform"));
  111. getLogLevel().then((level) => print("Old log level: " + LogLevel.levelToString(level)));
  112. setLogLevel(LogLevel.AV_LOG_INFO);
  113. getLogLevel().then((level) => print("New log level: " + LogLevel.levelToString(level)));
  114. getPackageName().then((packageName) => print("Package name: $packageName"));
  115. getExternalLibraries().then((packageList) {
  116. packageList.forEach((value) => print("External library: $value"));
  117. });
  118. }
  119. void prepareAssets() {
  120. VideoUtil.copyFileAssets('assets/pyramid.jpg', ASSET_1).then((path) => print('Loaded asset $path.'));
  121. VideoUtil.copyFileAssets('assets/colosseum.jpg', ASSET_2).then((path) => print('Loaded asset $path.'));
  122. VideoUtil.copyFileAssets('assets/tajmahal.jpg', ASSET_3).then((path) => print('Loaded asset $path.'));
  123. }
  124. void testRunCommand() {
  125. getLastReturnCode().then((rc) => print("Last rc: $rc"));
  126. getLastCommandOutput().then((output) => print("Last command output: $output"));
  127. print("Testing COMMAND.");
  128. // ENABLE LOG CALLBACK ON EACH CALL
  129. _flutterFFmpeg.enableLogCallback(commandOutputLogCallback);
  130. _flutterFFmpeg.enableStatisticsCallback(statisticsCallback);
  131. // CLEAR OUTPUT ON EACH EXECUTION
  132. _commandOutput = "";
  133. // COMMENT OPTIONAL TESTS
  134. // VideoUtil.tempDirectory.then((tempDirectory) {
  135. // Map<String, String> mapNameMap = new Map();
  136. // mapNameMap["my_custom_font"] = "my custom font";
  137. // setFontDirectory(tempDirectory.path, null);
  138. // });
  139. VideoUtil.tempDirectory.then((tempDirectory) {
  140. setFontconfigConfigurationPath(tempDirectory.path);
  141. });
  142. // disableRedirection();
  143. // disableLogs();
  144. // enableLogs();
  145. // execute(_commandController.text).then((rc) => print("FFmpeg process exited with rc $rc"));
  146. // executeWithDelimiter(_commandController.text, "_").then((rc) => print("FFmpeg process exited with rc $rc") );
  147. executeWithArguments(_commandController.text.split(" ")).then((rc) => print("FFmpeg process exited with rc $rc"));
  148. setState(() {});
  149. }
  150. void testGetMediaInformation(String mediaPath) {
  151. print("Testing Get Media Information.");
  152. // ENABLE LOG CALLBACK ON EACH CALL
  153. _flutterFFmpeg.enableLogCallback(commandOutputLogCallback);
  154. _flutterFFmpeg.enableStatisticsCallback(null);
  155. // CLEAR OUTPUT ON EACH EXECUTION
  156. _commandOutput = "";
  157. VideoUtil.assetPath(mediaPath).then((image1Path) {
  158. getMediaInformation(image1Path).then((info) {
  159. print('Media Information');
  160. print('Path: ${info['path']}');
  161. print('Format: ${info['format']}');
  162. print('Duration: ${info['duration']}');
  163. print('Start time: ${info['startTime']}');
  164. print('Bitrate: ${info['bitrate']}');
  165. if (info['streams'] != null) {
  166. final streamsInfoArray = info['streams'];
  167. if (streamsInfoArray.length > 0) {
  168. for (var streamsInfo in streamsInfoArray) {
  169. print('Stream id: ${streamsInfo['index']}');
  170. print('Stream type: ${streamsInfo['type']}');
  171. print('Stream codec: ${streamsInfo['codec']}');
  172. print('Stream full codec: ${streamsInfo['fullCodec']}');
  173. print('Stream format: ${streamsInfo['format']}');
  174. print('Stream full format: ${streamsInfo['fullFormat']}');
  175. print('Stream width: ${streamsInfo['width']}');
  176. print('Stream height: ${streamsInfo['height']}');
  177. print('Stream bitrate: ${streamsInfo['bitrate']}');
  178. print('Stream sample rate: ${streamsInfo['sampleRate']}');
  179. print('Stream sample format: ${streamsInfo['sampleFormat']}');
  180. print('Stream channel layout: ${streamsInfo['channelLayout']}');
  181. print('Stream sar: ${streamsInfo['sampleAspectRatio']}');
  182. print('Stream dar: ${streamsInfo['displayAspectRatio']}');
  183. print('Stream average frame rate: ${streamsInfo['averageFrameRate']}');
  184. print('Stream real frame rate: ${streamsInfo['realFrameRate']}');
  185. print('Stream time base: ${streamsInfo['timeBase']}');
  186. print('Stream codec time base: ${streamsInfo['codecTimeBase']}');
  187. final metadataMap = streamsInfo['metadata'];
  188. if (metadataMap != null) {
  189. print('Stream metadata encoder: ${metadataMap['encoder']}');
  190. print('Stream metadata rotate: ${metadataMap['rotate']}');
  191. print('Stream metadata creation time: ${metadataMap['creation_time']}');
  192. print('Stream metadata handler name: ${metadataMap['handler_name']}');
  193. }
  194. final sideDataMap = streamsInfo['sidedata'];
  195. if (sideDataMap != null) {
  196. print('Stream side data displaymatrix: ${sideDataMap['displaymatrix']}');
  197. }
  198. }
  199. }
  200. }
  201. });
  202. });
  203. setState(() {});
  204. }
  205. void testEncodeVideo() {
  206. print("Testing VIDEO.");
  207. // ENABLE LOG CALLBACK ON EACH CALL
  208. _flutterFFmpeg.enableLogCallback(encodeOutputLogCallback);
  209. _flutterFFmpeg.enableStatisticsCallback(statisticsCallback);
  210. // CLEAR OUTPUT ON EACH EXECUTION
  211. _encodeOutput = "";
  212. disableStatistics();
  213. enableStatistics();
  214. VideoUtil.assetPath(ASSET_1).then((image1Path) {
  215. VideoUtil.assetPath(ASSET_2).then((image2Path) {
  216. VideoUtil.assetPath(ASSET_3).then((image3Path) {
  217. final String videoPath = getVideoPath();
  218. final String customOptions = getCustomEncodingOptions();
  219. final String ffmpegCodec = getFFmpegCodecName();
  220. VideoUtil.assetPath(videoPath).then((fullVideoPath) {
  221. execute(VideoUtil.generateEncodeVideoScript(image1Path, image2Path, image3Path, fullVideoPath, ffmpegCodec, customOptions)).then((rc) {
  222. if (rc == 0) {
  223. testGetMediaInformation(fullVideoPath);
  224. }
  225. });
  226. // COMMENT OPTIONAL TESTS
  227. // execute(VideoUtil.generateEncodeVideoScript(image1Path, image2Path, image3Path, videoPath, _currentCodec, "")).timeout(Duration(milliseconds: 1300), onTimeout: () { cancel(); });
  228. // resetStatistics();
  229. getLastReceivedStatistics().then((lastStatistics) {
  230. if (lastStatistics == null) {
  231. print('No last statistics');
  232. } else {
  233. print('Last statistics');
  234. int time = lastStatistics['time'];
  235. int size = lastStatistics['size'];
  236. double bitrate = _doublePrecision(lastStatistics['bitrate'], 2);
  237. double speed = _doublePrecision(lastStatistics['speed'], 2);
  238. int videoFrameNumber = lastStatistics['videoFrameNumber'];
  239. double videoQuality = _doublePrecision(lastStatistics['videoQuality'], 2);
  240. double videoFps = _doublePrecision(lastStatistics['videoFps'], 2);
  241. statisticsCallback(time, size, bitrate, speed, videoFrameNumber, videoQuality, videoFps);
  242. }
  243. });
  244. });
  245. });
  246. });
  247. });
  248. setState(() {});
  249. }
  250. void commandOutputLogCallback(int level, String message) {
  251. _commandOutput += message;
  252. setState(() {});
  253. }
  254. void encodeOutputLogCallback(int level, String message) {
  255. _encodeOutput += message;
  256. setState(() {});
  257. }
  258. void statisticsCallback(int time, int size, double bitrate, double speed, int videoFrameNumber, double videoQuality, double videoFps) {
  259. print("Statistics: time: $time, size: $size, bitrate: $bitrate, speed: $speed, videoFrameNumber: $videoFrameNumber, videoQuality: $videoQuality, videoFps: $videoFps");
  260. }
  261. Future<String> getFFmpegVersion() async {
  262. return await _flutterFFmpeg.getFFmpegVersion();
  263. }
  264. Future<String> getPlatform() async {
  265. return await _flutterFFmpeg.getPlatform();
  266. }
  267. Future<int> executeWithArguments(List arguments) async {
  268. return await _flutterFFmpeg.executeWithArguments(arguments);
  269. }
  270. Future<int> execute(String command) async {
  271. return await _flutterFFmpeg.execute(command);
  272. }
  273. Future<int> executeWithDelimiter(String command, String delimiter) async {
  274. return await _flutterFFmpeg.execute(command, delimiter);
  275. }
  276. Future<void> cancel() async {
  277. return await _flutterFFmpeg.cancel();
  278. }
  279. Future<void> disableRedirection() async {
  280. return await _flutterFFmpeg.disableRedirection();
  281. }
  282. Future<int> getLogLevel() async {
  283. return await _flutterFFmpeg.getLogLevel();
  284. }
  285. Future<void> setLogLevel(int logLevel) async {
  286. return await _flutterFFmpeg.setLogLevel(logLevel);
  287. }
  288. Future<void> enableLogs() async {
  289. return await _flutterFFmpeg.enableLogs();
  290. }
  291. Future<void> disableLogs() async {
  292. return await _flutterFFmpeg.disableLogs();
  293. }
  294. Future<void> enableStatistics() async {
  295. return await _flutterFFmpeg.enableStatistics();
  296. }
  297. Future<void> disableStatistics() async {
  298. return await _flutterFFmpeg.disableStatistics();
  299. }
  300. Future<Map<dynamic, dynamic>> getLastReceivedStatistics() async {
  301. return await _flutterFFmpeg.getLastReceivedStatistics();
  302. }
  303. Future<void> resetStatistics() async {
  304. return await _flutterFFmpeg.resetStatistics();
  305. }
  306. Future<void> setFontconfigConfigurationPath(String path) async {
  307. return await _flutterFFmpeg.setFontconfigConfigurationPath(path);
  308. }
  309. Future<void> setFontDirectory(String fontDirectory, Map<String, String> fontNameMap) async {
  310. return await _flutterFFmpeg.setFontDirectory(fontDirectory, fontNameMap);
  311. }
  312. Future<String> getPackageName() async {
  313. return await _flutterFFmpeg.getPackageName();
  314. }
  315. Future<List<dynamic>> getExternalLibraries() async {
  316. return await _flutterFFmpeg.getExternalLibraries();
  317. }
  318. Future<int> getLastReturnCode() async {
  319. return await _flutterFFmpeg.getLastReturnCode();
  320. }
  321. Future<String> getLastCommandOutput() async {
  322. return await _flutterFFmpeg.getLastCommandOutput();
  323. }
  324. Future<Map<dynamic, dynamic>> getMediaInformation(String path) async {
  325. return await _flutterFFmpeg.getMediaInformation(path);
  326. }
  327. void _changedCodec(String selectedCodec) {
  328. setState(() {
  329. _currentCodec = selectedCodec;
  330. });
  331. }
  332. String getFFmpegCodecName() {
  333. String ffmpegCodec = _currentCodec;
  334. // VIDEO CODEC MENU HAS BASIC NAMES, FFMPEG NEEDS LONGER LIBRARY NAMES.
  335. if (ffmpegCodec == "x264") {
  336. ffmpegCodec = "libx264";
  337. } else if (ffmpegCodec == "x265") {
  338. ffmpegCodec = "libx265";
  339. } else if (ffmpegCodec == "xvid") {
  340. ffmpegCodec = "libxvid";
  341. } else if (ffmpegCodec == "vp8") {
  342. ffmpegCodec = "libvpx";
  343. } else if (ffmpegCodec == "vp9") {
  344. ffmpegCodec = "libvpx-vp9";
  345. }
  346. return ffmpegCodec;
  347. }
  348. String getVideoPath() {
  349. String ffmpegCodec = _currentCodec;
  350. String videoPath;
  351. if ((ffmpegCodec == "vp8") || (ffmpegCodec == "vp9")) {
  352. videoPath = "video.webm";
  353. } else {
  354. // mpeg4, x264, x265, xvid
  355. videoPath = "video.mp4";
  356. }
  357. return videoPath;
  358. }
  359. String getCustomEncodingOptions() {
  360. String videoCodec = _currentCodec;
  361. if (videoCodec == "x265") {
  362. return "-crf 28 -preset fast ";
  363. } else if (videoCodec == "vp8") {
  364. return "-b:v 1M -crf 10 ";
  365. } else if (videoCodec == "vp9") {
  366. return "-b:v 2M ";
  367. } else {
  368. return "";
  369. }
  370. }
  371. List<DropdownMenuItem<String>> _getCodecDropDownMenuItems() {
  372. List<DropdownMenuItem<String>> items = new List();
  373. items.add(new DropdownMenuItem(value: "mpeg4", child: new Text("mpeg4")));
  374. items.add(new DropdownMenuItem(value: "x264", child: new Text("x264")));
  375. items.add(new DropdownMenuItem(value: "x265", child: new Text("x265")));
  376. items.add(new DropdownMenuItem(value: "xvid", child: new Text("xvid")));
  377. items.add(new DropdownMenuItem(value: "vp8", child: new Text("vp8")));
  378. items.add(new DropdownMenuItem(value: "vp9", child: new Text("vp9")));
  379. return items;
  380. }
  381. double _doublePrecision(double value, int precision) {
  382. if (value == null) {
  383. return 0;
  384. } else {
  385. return num.parse(value.toStringAsFixed(precision));
  386. }
  387. }
  388. @override
  389. Widget build(BuildContext context) {
  390. return Scaffold(
  391. appBar: AppBar(
  392. title: Text('FlutterFFmpeg Test'),
  393. centerTitle: true,
  394. ),
  395. bottomNavigationBar: Material(
  396. child: DecoratedTabBar(
  397. tabBar: TabBar(
  398. tabs: <Tab>[
  399. Tab(text: "COMMAND"),
  400. Tab(
  401. text: "VIDEO",
  402. )
  403. ],
  404. controller: _controller,
  405. labelColor: Color(0xFF1e90ff),
  406. unselectedLabelColor: Color(0xFF808080),
  407. ),
  408. decoration: BoxDecoration(
  409. border: Border(
  410. top: BorderSide(
  411. color: Color(0xFF808080),
  412. width: 1.0,
  413. ),
  414. bottom: BorderSide(
  415. width: 0.0,
  416. ),
  417. ),
  418. ),
  419. ),
  420. ),
  421. body: TabBarView(
  422. children: <Widget>[
  423. Column(
  424. crossAxisAlignment: CrossAxisAlignment.center,
  425. children: <Widget>[
  426. Container(
  427. padding: const EdgeInsets.fromLTRB(20, 40, 20, 40),
  428. child: TextField(
  429. controller: _commandController,
  430. decoration: InputDecoration(
  431. border: const OutlineInputBorder(
  432. borderSide: const BorderSide(color: Color(0xFF3498DB)),
  433. borderRadius: const BorderRadius.all(
  434. const Radius.circular(5),
  435. ),
  436. ),
  437. focusedBorder: const OutlineInputBorder(
  438. borderSide: const BorderSide(color: Color(0xFF3498DB)),
  439. borderRadius: const BorderRadius.all(
  440. const Radius.circular(5),
  441. ),
  442. ),
  443. enabledBorder: const OutlineInputBorder(
  444. borderSide: const BorderSide(color: Color(0xFF3498DB)),
  445. borderRadius: const BorderRadius.all(
  446. const Radius.circular(5),
  447. ),
  448. ),
  449. contentPadding: EdgeInsets.fromLTRB(8, 12, 8, 12),
  450. hintStyle: new TextStyle(fontSize: 14, color: Colors.grey[400]),
  451. hintText: "Enter command"),
  452. style: new TextStyle(fontSize: 14, color: Colors.black),
  453. ),
  454. ),
  455. Container(
  456. padding: const EdgeInsets.only(bottom: 20),
  457. child: new InkWell(
  458. onTap: () => testRunCommand(),
  459. child: new Container(
  460. width: 100,
  461. height: 38,
  462. decoration: new BoxDecoration(
  463. color: Color(0xFF2ECC71),
  464. borderRadius: new BorderRadius.circular(5),
  465. ),
  466. child: new Center(
  467. child: new Text(
  468. 'RUN',
  469. style: new TextStyle(fontSize: 14.0, fontWeight: FontWeight.bold, color: Colors.white),
  470. ),
  471. ),
  472. ),
  473. ),
  474. ),
  475. Expanded(
  476. child: Container(
  477. alignment: Alignment(-1.0, -1.0),
  478. margin: EdgeInsets.all(20.0),
  479. padding: EdgeInsets.all(4.0),
  480. decoration: new BoxDecoration(borderRadius: BorderRadius.all(new Radius.circular(5)), color: Color(0xFFF1C40F)),
  481. child: SingleChildScrollView(reverse: true, child: Text(_commandOutput))),
  482. )
  483. ],
  484. ),
  485. Column(
  486. crossAxisAlignment: CrossAxisAlignment.center,
  487. children: <Widget>[
  488. Container(
  489. padding: const EdgeInsets.fromLTRB(20, 40, 20, 40),
  490. child: Container(
  491. width: 200,
  492. alignment: Alignment(0.0, 0.0),
  493. decoration: BoxDecoration(color: Color.fromRGBO(155, 89, 182, 1.0), borderRadius: BorderRadius.circular(5)),
  494. child: DropdownButtonHideUnderline(
  495. child: DropdownButton(
  496. style: new TextStyle(
  497. fontSize: 14,
  498. color: Colors.black,
  499. ),
  500. value: _currentCodec,
  501. items: _codecDropDownMenuItems,
  502. onChanged: _changedCodec,
  503. iconSize: 0,
  504. isExpanded: false,
  505. )),
  506. )),
  507. Container(
  508. padding: const EdgeInsets.only(bottom: 20),
  509. child: new InkWell(
  510. onTap: () => testEncodeVideo(),
  511. child: new Container(
  512. width: 100,
  513. height: 38,
  514. decoration: new BoxDecoration(
  515. color: Color(0xFF2ECC71),
  516. borderRadius: new BorderRadius.circular(5),
  517. ),
  518. child: new Center(
  519. child: new Text(
  520. 'ENCODE',
  521. style: new TextStyle(fontSize: 14.0, fontWeight: FontWeight.bold, color: Colors.white),
  522. ),
  523. ),
  524. ),
  525. ),
  526. ),
  527. Expanded(
  528. child: Container(
  529. alignment: Alignment(-1.0, -1.0),
  530. margin: EdgeInsets.all(20.0),
  531. padding: EdgeInsets.all(4.0),
  532. decoration: new BoxDecoration(borderRadius: BorderRadius.all(new Radius.circular(5)), color: Color(0xFFF1C40F)),
  533. child: SingleChildScrollView(reverse: true, child: Text(_encodeOutput))),
  534. )
  535. ],
  536. ),
  537. ],
  538. controller: _controller,
  539. ));
  540. }
  541. @override
  542. void dispose() {
  543. super.dispose();
  544. _commandController.dispose();
  545. }
  546. }