Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Rafa Castillo Passols
/
Prototipo-Multimedia
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
91360449
authored
Apr 03, 2025
by
Rafa Castillo Passols
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Las bases para getMetadatos ya están. Ahora hay que hacer procesamiento avanzado
parent
d4e46c2c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
7 deletions
lib/modelo/conversor.dart
lib/widgets/action_button.dart
pubspec.yaml
lib/modelo/conversor.dart
View file @
91360449
...
@@ -3,6 +3,7 @@ import 'dart:io';
...
@@ -3,6 +3,7 @@ import 'dart:io';
import
'package:ffmpeg_kit_flutter/ffmpeg_kit.dart'
;
import
'package:ffmpeg_kit_flutter/ffmpeg_kit.dart'
;
import
'package:ffmpeg_kit_flutter/ffmpeg_session.dart'
;
import
'package:ffmpeg_kit_flutter/ffmpeg_session.dart'
;
import
'package:ffmpeg_kit_flutter/return_code.dart'
;
import
'package:ffmpeg_kit_flutter/return_code.dart'
;
import
'package:path_provider/path_provider.dart'
;
import
'package:prueba_multimedia/modelo/modelo.dart'
;
import
'package:prueba_multimedia/modelo/modelo.dart'
;
// TODO: TERMINAR
// TODO: TERMINAR
...
@@ -19,14 +20,38 @@ abstract class Conversor {
...
@@ -19,14 +20,38 @@ abstract class Conversor {
return
returnCode
;
return
returnCode
;
}
}
static
void
getMetadata
(
Archivo
archivo
)
async
{
// https://www.ffmpeg.org/ffmpeg-formats.html#ffmetadata
// ffmpeg -i INPUT -f ffmetadata metadata.ffmeta
String
comando
=
"-i
${archivo.file.path}
-f ffmetadata metadata.ffmeta"
;
// https://www.ffmpeg.org/ffmpeg-formats.html#ffmetadata
/// Devuelve los metadatos del archivo o null si ha habido un problema
static
Future
<
Map
<
String
,
String
>?>
getMetadatos
(
Archivo
archivo
)
async
{
// Creamos archivo metadatos
var
archivoSalida
=
"
${archivo.nombre}
.ffmeta"
;
var
cacheDirectory
=
await
getApplicationCacheDirectory
();
var
pathArchivoSalida
=
"
${cacheDirectory.path}
/
$archivoSalida
"
;
var
comando
=
"-i
${archivo.file.path}
-f ffmetadata
$pathArchivoSalida
"
;
FFmpegSession
session
=
await
FFmpegKit
.
execute
(
comando
);
FFmpegSession
session
=
await
FFmpegKit
.
execute
(
comando
);
// session.getOutput()
// Leemos archivo metadatos
var
returnCode
=
await
session
.
getReturnCode
();
if
(
returnCode
==
null
||
returnCode
.
getValue
()
!=
0
)
{
return
null
;
}
var
archivoMetadatos
=
File
(
pathArchivoSalida
);
var
lineas
=
await
archivoMetadatos
.
readAsLines
();
archivoMetadatos
.
delete
(
recursive:
false
);
// Procesar metadatos
var
metadatos
=
<
String
,
String
>{};
for
(
var
linea
in
lineas
)
{
// Vacio, comentario o indicar sección
if
(
linea
.
isEmpty
||
linea
.
startsWith
(
RegExp
(
"[;#[]"
)))
{
continue
;
}
var
campos
=
linea
.
split
(
"="
);
metadatos
.
putIfAbsent
(
campos
[
0
],
()
=>
campos
[
1
]);
}
return
metadatos
;
}
}
}
}
\ No newline at end of file
lib/widgets/action_button.dart
View file @
91360449
...
@@ -91,8 +91,12 @@ class ActionButton extends StatelessWidget {
...
@@ -91,8 +91,12 @@ class ActionButton extends StatelessWidget {
}
}
void
reemplazarAction
()
{
void
reemplazarAction
()
async
{
// Convertimos los archivos como tal
List
<
Archivo
>
archivos
=
manager
.
seleccionables
.
whereType
<
Archivo
>().
toList
();
for
(
var
archivo
in
archivos
)
{
Conversor
.
getMetadatos
(
archivo
);
}
}
}
}
}
...
...
pubspec.yaml
View file @
91360449
...
@@ -38,6 +38,7 @@ dependencies:
...
@@ -38,6 +38,7 @@ dependencies:
file_picker
:
^9.0.2
file_picker
:
^9.0.2
uuid
:
^4.5.1
uuid
:
^4.5.1
ffmpeg_kit_flutter
:
^6.0.3
ffmpeg_kit_flutter
:
^6.0.3
path_provider
:
^2.1.5
dev_dependencies
:
dev_dependencies
:
flutter_test
:
flutter_test
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment