
Recherche avancée
Médias (91)
-
Collections - Formulaire de création rapide
19 février 2013, par
Mis à jour : Février 2013
Langue : français
Type : Image
-
Les Miserables
4 juin 2012, par
Mis à jour : Février 2013
Langue : English
Type : Texte
-
Ne pas afficher certaines informations : page d’accueil
23 novembre 2011, par
Mis à jour : Novembre 2011
Langue : français
Type : Image
-
The Great Big Beautiful Tomorrow
28 octobre 2011, par
Mis à jour : Octobre 2011
Langue : English
Type : Texte
-
Richard Stallman et la révolution du logiciel libre - Une biographie autorisée (version epub)
28 octobre 2011, par
Mis à jour : Octobre 2011
Langue : English
Type : Texte
-
Rennes Emotion Map 2010-11
19 octobre 2011, par
Mis à jour : Juillet 2013
Langue : français
Type : Texte
Autres articles (89)
-
Le profil des utilisateurs
12 avril 2011, parChaque utilisateur dispose d’une page de profil lui permettant de modifier ses informations personnelle. Dans le menu de haut de page par défaut, un élément de menu est automatiquement créé à l’initialisation de MediaSPIP, visible uniquement si le visiteur est identifié sur le site.
L’utilisateur a accès à la modification de profil depuis sa page auteur, un lien dans la navigation "Modifier votre profil" est (...) -
Configurer la prise en compte des langues
15 novembre 2010, parAccéder à la configuration et ajouter des langues prises en compte
Afin de configurer la prise en compte de nouvelles langues, il est nécessaire de se rendre dans la partie "Administrer" du site.
De là, dans le menu de navigation, vous pouvez accéder à une partie "Gestion des langues" permettant d’activer la prise en compte de nouvelles langues.
Chaque nouvelle langue ajoutée reste désactivable tant qu’aucun objet n’est créé dans cette langue. Dans ce cas, elle devient grisée dans la configuration et (...) -
La sauvegarde automatique de canaux SPIP
1er avril 2010, parDans le cadre de la mise en place d’une plateforme ouverte, il est important pour les hébergeurs de pouvoir disposer de sauvegardes assez régulières pour parer à tout problème éventuel.
Pour réaliser cette tâche on se base sur deux plugins SPIP : Saveauto qui permet une sauvegarde régulière de la base de donnée sous la forme d’un dump mysql (utilisable dans phpmyadmin) mes_fichiers_2 qui permet de réaliser une archive au format zip des données importantes du site (les documents, les éléments (...)
Sur d’autres sites (12027)
-
Resize the video
8 juin 2016, par Android devI have a requirement for video size before upload on the server and would like to resize the video to make sure it will not go the threshold.
So far I ended up with this command :
ffmpeg -y -i E:\test3.mp4 -s 640*480 -r 15 -aspect 3:4 -ab 12288 -vcodec mpeg4 -b 2097152 E:\debug_video.mp4
The issues with this command :
- is it changes aspect ratio of the video
- it works too slow (30 seconds for 12 seconds 24mb video on Nexus 5)The best solution so far for the first issue is to check the video resolution first and only than run the ffmpeg.
Do you know how to do that with help of ffmpeg as two separate commands or as a single one ? Do you know how to make it faster ? Thank you in advance
UPDATE
The console output is below. Please let me know if you would like to get console output foronProgress
callbackadb -s 07f0f4ac01897da5 logcat "ffmpeg:*" "*:S"
06-08 17:43:29.589 20835 20835 D ffmpeg : FFmpeg:onProgress: ffmpeg version n3.
0.1 Copyright (c) 2000-2016 the FFmpeg developers
06-08 17:43:29.589 20835 20835 D ffmpeg : FFmpeg:onProgress: built with gcc 4
.8 (GCC)
06-08 17:43:29.592 20835 20835 D ffmpeg : FFmpeg:onProgress: configuration: -
-target-os=linux --cross-prefix=/home/vagrant/SourceCode/ffmpeg-android/toolchai
n-android/bin/arm-linux-androideabi- --arch=arm --cpu=cortex-a8 --enable-runtime
-cpudetect --sysroot=/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/s
ysroot --enable-pic --enable-libx264 --enable-libass --enable-libfreetype --enab
le-libfribidi --enable-libmp3lame --enable-fontconfig --enable-pthreads --disabl
e-debug --disable-ffserver --enable-version3 --enable-hardcoded-tables --disable
-ffplay --disable-ffprobe --enable-gpl --enable-yasm --disable-doc --disable-sha
red --enable-static --pkg-config=/home/vagrant/SourceCode/ffmpeg-android/ffmpeg-
pkg-config --prefix=/home/vagrant/SourceCode/ffmpeg-android/build/armeabi-v7a --
extra-cflags='-I/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/includ
e -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fno-strict-overflow -fstack-protector-a
ll' --extra-ldflags='-L/home/vagrant/SourceCode/ffmpeg-android/toolchain-android
/lib -Wl,-z,relro -Wl,-z,now -pie' --extra-libs='-lpng -lexpat -lm' --extra-cxxf
lags=
06-08 17:43:29.600 20835 20835 D ffmpeg : FFmpeg:onProgress: libavutil 5
5. 17.103 / 55. 17.103
06-08 17:43:29.600 20835 20835 D ffmpeg : FFmpeg:onProgress: libavcodec 5
7. 24.102 / 57. 24.102
06-08 17:43:29.600 20835 20835 D ffmpeg : FFmpeg:onProgress: libavformat 5
7. 25.100 / 57. 25.100
06-08 17:43:29.600 20835 20835 D ffmpeg : FFmpeg:onProgress: libavdevice 5
7. 0.101 / 57. 0.101
06-08 17:43:29.600 20835 20835 D ffmpeg : FFmpeg:onProgress: libavfilter
6. 31.100 / 6. 31.100
06-08 17:43:29.600 20835 20835 D ffmpeg : FFmpeg:onProgress: libswscale
4. 0.100 / 4. 0.100
06-08 17:43:29.600 20835 20835 D ffmpeg : FFmpeg:onProgress: libswresample
2. 0.101 / 2. 0.101
06-08 17:43:29.600 20835 20835 D ffmpeg : FFmpeg:onProgress: libpostproc 5
4. 0.100 / 54. 0.100
06-08 17:43:29.885 20835 20835 D ffmpeg : FFmpeg:onProgress: Input #0, mov,mp4,
m4a,3gp,3g2,mj2, from '/storage/emulated/0/Pictures/test2.mp4':
06-08 17:43:29.885 20835 20835 D ffmpeg : FFmpeg:onProgress: Metadata:
06-08 17:43:29.885 20835 20835 D ffmpeg : FFmpeg:onProgress: major_brand
: mp42
06-08 17:43:29.885 20835 20835 D ffmpeg : FFmpeg:onProgress: minor_version
: 0
06-08 17:43:29.885 20835 20835 D ffmpeg : FFmpeg:onProgress: compatible_bra
nds: isommp42
06-08 17:43:29.886 20835 20835 D ffmpeg : FFmpeg:onProgress: creation_time
: 2016-06-02 09:20:58
06-08 17:43:29.886 20835 20835 D ffmpeg : FFmpeg:onProgress: com.android.ve
rsion: 6.0.1
06-08 17:43:29.886 20835 20835 D ffmpeg : FFmpeg:onProgress: Duration: 00:00:
12.03, start: 0.000000, bitrate: 17234 kb/s
06-08 17:43:29.886 20835 20835 D ffmpeg : FFmpeg:onProgress: Stream #0:0(en
g): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p, 1920x1080, 16902 kb/s,
SAR 1:1 DAR 16:9, 29.81 fps, 29.85 tbr, 90k tbn, 180k tbc (default)
06-08 17:43:29.886 20835 20835 D ffmpeg : FFmpeg:onProgress: Metadata:
06-08 17:43:29.890 20835 20835 D ffmpeg : FFmpeg:onProgress: rotate
: 90
06-08 17:43:29.890 20835 20835 D ffmpeg : FFmpeg:onProgress: creation_tim
e : 2016-06-02 09:20:58
06-08 17:43:29.891 20835 20835 D ffmpeg : FFmpeg:onProgress: handler_name
: VideoHandle
06-08 17:43:29.891 20835 20835 D ffmpeg : FFmpeg:onProgress: Side data:
06-08 17:43:29.891 20835 20835 D ffmpeg : FFmpeg:onProgress: displaymatri
x: rotation of -90.00 degrees
06-08 17:43:29.892 20835 20835 D ffmpeg : FFmpeg:onProgress: Stream #0:1(en
g): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 96 kb/s (default)
06-08 17:43:29.892 20835 20835 D ffmpeg : FFmpeg:onProgress: Metadata:
06-08 17:43:29.893 20835 20835 D ffmpeg : FFmpeg:onProgress: creation_tim
e : 2016-06-02 09:20:58
06-08 17:43:29.893 20835 20835 D ffmpeg : FFmpeg:onProgress: handler_name
: SoundHandle
06-08 17:43:29.893 20835 20835 D ffmpeg : FFmpeg:onProgress: Please use -b:a or
-b:v, -b is ambiguous
06-08 17:43:29.894 20835 20835 D ffmpeg : FFmpeg:onProgress: Codec AVOption pre
set (Set the encoding preset (cf. x264 --fullhelp)) specified for output file #0
(/storage/emulated/0/Pictures/scaled_video.mp4) has not been used for any strea
m. The most likely reason is either wrong type (e.g. a video option with no vide
o streams) or that it is a private option of some encoder which was not actually
used for any stream.
06-08 17:43:29.939 20835 20835 D ffmpeg : FFmpeg:onProgress: [mpeg4 @ 0xb5c4440
0] Invalid pixel aspect ratio 5121/5120, limit is 255/255 reducing
06-08 17:43:29.996 20835 20835 D ffmpeg : FFmpeg:onProgress: Output #0, mp4, to
'/storage/emulated/0/Pictures/scaled_video.mp4':
06-08 17:43:29.998 20835 20835 D ffmpeg : FFmpeg:onProgress: Metadata:
06-08 17:43:29.999 20835 20835 D ffmpeg : FFmpeg:onProgress: major_brand
: mp42
06-08 17:43:30.000 20835 20835 D ffmpeg : FFmpeg:onProgress: minor_version
: 0
06-08 17:43:30.000 20835 20835 D ffmpeg : FFmpeg:onProgress: compatible_bra
nds: isommp42
06-08 17:43:30.001 20835 20835 D ffmpeg : FFmpeg:onProgress: com.android.ve
rsion: 6.0.1
06-08 17:43:30.002 20835 20835 D ffmpeg : FFmpeg:onProgress: encoder
: Lavf57.25.100
06-08 17:43:30.003 20835 20835 D ffmpeg : FFmpeg:onProgress: Stream #0:0(en
g): Video: mpeg4 ( [0][0][0] / 0x0020), yuv420p, 640x1138 [SAR 1:1 DAR 320:569],
q=2-31, 2097 kb/s, SAR 5121:5120 DAR 9:16, 15 fps, 15360 tbn, 15 tbc (default)
06-08 17:43:30.004 20835 20835 D ffmpeg : FFmpeg:onProgress: Metadata:
06-08 17:43:30.005 20835 20835 D ffmpeg : FFmpeg:onProgress: handler_name
: VideoHandle
06-08 17:43:30.006 20835 20835 D ffmpeg : FFmpeg:onProgress: creation_tim
e : 2016-06-02 09:20:58
06-08 17:43:30.007 20835 20835 D ffmpeg : FFmpeg:onProgress: encoder
: Lavc57.24.102 mpeg4
06-08 17:43:30.008 20835 20835 D ffmpeg : FFmpeg:onProgress: Side data:
06-08 17:43:30.008 20835 20835 D ffmpeg : FFmpeg:onProgress: unknown side
data type 10 (24 bytes)
06-08 17:43:30.008 20835 20835 D ffmpeg : FFmpeg:onProgress: Stream #0:1(en
g): Audio: aac (LC) ([64][0][0][0] / 0x0040), 48000 Hz, mono, fltp, 12 kb/s (def
ault)
06-08 17:43:30.008 20835 20835 D ffmpeg : FFmpeg:onProgress: Metadata:
06-08 17:43:30.008 20835 20835 D ffmpeg : FFmpeg:onProgress: creation_tim
e : 2016-06-02 09:20:58
06-08 17:43:30.008 20835 20835 D ffmpeg : FFmpeg:onProgress: handler_name
: SoundHandle
06-08 17:43:30.009 20835 20835 D ffmpeg : FFmpeg:onProgress: encoder
: Lavc57.24.102 aac
06-08 17:43:30.009 20835 20835 D ffmpeg : FFmpeg:onProgress: Stream mapping:
06-08 17:43:30.009 20835 20835 D ffmpeg : FFmpeg:onProgress: Stream #0:0 -> #
0:0 (h264 (native) -> mpeg4 (native))
06-08 17:43:30.009 20835 20835 D ffmpeg : FFmpeg:onProgress: Stream #0:1 -> #
0:1 (aac (native) -> aac (native))
06-08 17:43:30.010 20835 20835 D ffmpeg : FFmpeg:onProgress: Press [q] to stop,
[?] for help
06-08 17:43:30.730 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 2 fps=0.
0 q=2.0 size= 129kB time=00:00:01.00 bitrate=1056.4kbits/s speed=1.66x
06-08 17:43:31.350 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 5 fps=4.
0 q=2.0 size= 314kB time=00:00:01.00 bitrate=2566.0kbits/s dup=0 drop=1 spee
d=0.809x
06-08 17:43:31.842 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 8 fps=4.
6 q=7.5 size= 404kB time=00:00:01.00 bitrate=3302.5kbits/s dup=0 drop=4 spee
d=0.573x
06-08 17:43:32.367 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 10 fps=4.
4 q=8.7 size= 431kB time=00:00:01.00 bitrate=3523.1kbits/s dup=0 drop=6 spee
d=0.441x
06-08 17:43:32.873 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 13 fps=4.
7 q=9.0 size= 518kB time=00:00:01.00 bitrate=4230.9kbits/s dup=0 drop=9 spee
d=0.361x
06-08 17:43:33.392 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 15 fps=4.
5 q=11.6 size= 536kB time=00:00:01.00 bitrate=4381.7kbits/s dup=0 drop=11 sp
eed=0.303x
06-08 17:43:34.011 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 17 fps=4.
3 q=11.7 size= 558kB time=00:00:02.00 bitrate=2279.7kbits/s dup=0 drop=13 sp
eed=0.512x
06-08 17:43:34.621 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 20 fps=4.
4 q=12.5 size= 598kB time=00:00:02.00 bitrate=2444.5kbits/s dup=0 drop=16 sp
eed=0.443x
06-08 17:43:35.207 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 23 fps=4.
5 q=11.3 size= 630kB time=00:00:02.00 bitrate=2574.3kbits/s dup=0 drop=19 sp
eed=0.394x
06-08 17:43:35.726 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 26 fps=4.
6 q=10.1 size= 689kB time=00:00:02.00 bitrate=2815.3kbits/s dup=0 drop=22 sp
eed=0.357x
06-08 17:43:36.252 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 28 fps=4.
6 q=9.6 size= 707kB time=00:00:02.00 bitrate=2888.7kbits/s dup=0 drop=24 spe
ed=0.327x
06-08 17:43:36.749 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 31 fps=4.
7 q=9.5 size= 726kB time=00:00:02.06 bitrate=2879.6kbits/s dup=0 drop=27 spe
ed=0.311x
06-08 17:43:37.341 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 33 fps=4.
6 q=9.3 size= 767kB time=00:00:03.00 bitrate=2089.4kbits/s dup=0 drop=29 spe
ed=0.417x
06-08 17:43:37.872 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 35 fps=4.
5 q=9.4 size= 791kB time=00:00:03.00 bitrate=2154.3kbits/s dup=0 drop=31 spe
ed=0.386x
06-08 17:43:38.447 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 38 fps=4.
6 q=9.2 size= 854kB time=00:00:03.00 bitrate=2324.7kbits/s dup=0 drop=34 spe
ed=0.361x
06-08 17:43:39.005 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 41 fps=4.
6 q=8.2 size= 883kB time=00:00:03.00 bitrate=2404.7kbits/s dup=0 drop=36 spe
ed=0.338x
06-08 17:43:39.507 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 43 fps=4.
6 q=9.0 size= 918kB time=00:00:03.00 bitrate=2499.3kbits/s dup=0 drop=38 spe
ed=0.32x
06-08 17:43:40.065 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 46 fps=4.
6 q=9.6 size= 948kB time=00:00:03.06 bitrate=2531.5kbits/s dup=0 drop=41 spe
ed=0.307x
06-08 17:43:40.602 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 48 fps=4.
6 q=9.3 size= 990kB time=00:00:04.01 bitrate=2021.2kbits/s dup=0 drop=43 spe
ed=0.381x
06-08 17:43:41.189 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 51 fps=4.
6 q=7.3 size= 1025kB time=00:00:04.01 bitrate=2094.5kbits/s dup=0 drop=46 spe
ed=0.361x
06-08 17:43:41.744 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 54 fps=4.
6 q=6.9 size= 1064kB time=00:00:04.01 bitrate=2173.0kbits/s dup=0 drop=49 spe
ed=0.345x
06-08 17:43:42.288 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 56 fps=4.
6 q=6.1 size= 1082kB time=00:00:04.01 bitrate=2209.5kbits/s dup=0 drop=51 spe
ed=0.329x
06-08 17:43:42.872 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 59 fps=4.
6 q=4.5 size= 1107kB time=00:00:04.01 bitrate=2260.3kbits/s dup=0 drop=54 spe
ed=0.314x
06-08 17:43:43.292 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 61 fps=4.
6 q=3.2 size= 1152kB time=00:00:04.26 bitrate=2212.2kbits/s dup=0 drop=56 spe
ed=0.321x
06-08 17:43:43.986 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 64 fps=4.
6 q=3.9 size= 1178kB time=00:00:05.01 bitrate=1924.7kbits/s dup=0 drop=59 spe
ed=0.361x
06-08 17:43:44.518 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 66 fps=4.
6 q=3.6 size= 1196kB time=00:00:05.01 bitrate=1953.9kbits/s dup=0 drop=61 spe
ed=0.347x
06-08 17:43:45.104 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 69 fps=4.
6 q=3.4 size= 1232kB time=00:00:05.01 bitrate=2013.0kbits/s dup=0 drop=64 spe
ed=0.334x
06-08 17:43:45.687 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 72 fps=4.
6 q=4.9 size= 1263kB time=00:00:05.01 bitrate=2063.4kbits/s dup=0 drop=67 spe
ed=0.321x
06-08 17:43:46.262 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 75 fps=4.
6 q=3.5 size= 1307kB time=00:00:05.01 bitrate=2135.1kbits/s dup=0 drop=70 spe
ed=0.31x
06-08 17:43:46.840 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 77 fps=4.
6 q=3.1 size= 1334kB time=00:00:06.01 bitrate=1816.5kbits/s dup=0 drop=72 spe
ed=0.359x
06-08 17:43:47.354 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 80 fps=4.
6 q=3.5 size= 1380kB time=00:00:06.01 bitrate=1878.6kbits/s dup=0 drop=75 spe
ed=0.349x
06-08 17:43:47.826 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 82 fps=4.
6 q=3.6 size= 1412kB time=00:00:06.01 bitrate=1923.2kbits/s dup=0 drop=77 spe
ed=0.339x
06-08 17:43:48.346 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 85 fps=4.
7 q=3.5 size= 1476kB time=00:00:06.01 bitrate=2009.8kbits/s dup=0 drop=80 spe
ed=0.33x
06-08 17:43:48.911 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 88 fps=4.
7 q=3.5 size= 1524kB time=00:00:06.01 bitrate=2074.7kbits/s dup=0 drop=83 spe
ed=0.32x
06-08 17:43:49.496 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 91 fps=4.
7 q=3.8 size= 1556kB time=00:00:06.06 bitrate=2101.5kbits/s dup=0 drop=86 spe
ed=0.313x
06-08 17:43:50.100 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 93 fps=4.
7 q=4.1 size= 1616kB time=00:00:07.01 bitrate=1886.0kbits/s dup=0 drop=88 spe
ed=0.352x
06-08 17:43:50.598 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 95 fps=4.
6 q=4.3 size= 1652kB time=00:00:07.01 bitrate=1928.4kbits/s dup=0 drop=90 spe
ed=0.342x
06-08 17:43:51.182 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 98 fps=4.
7 q=4.7 size= 1728kB time=00:00:07.01 bitrate=2017.1kbits/s dup=0 drop=93 spe
ed=0.333x
06-08 17:43:51.693 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 100 fps=4.
6 q=4.6 size= 1763kB time=00:00:07.01 bitrate=2057.5kbits/s dup=0 drop=95 spe
ed=0.325x
06-08 17:43:52.272 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 103 fps=4.
6 q=4.6 size= 1812kB time=00:00:07.01 bitrate=2115.1kbits/s dup=0 drop=98 spe
ed=0.317x
06-08 17:43:52.839 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 106 fps=4.
7 q=4.2 size= 1845kB time=00:00:07.06 bitrate=2138.7kbits/s dup=0 drop=101 sp
eed=0.311x
06-08 17:43:53.383 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 108 fps=4.
6 q=4.1 size= 1886kB time=00:00:08.02 bitrate=1925.7kbits/s dup=0 drop=103 sp
eed=0.344x
06-08 17:43:53.966 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 111 fps=4.
7 q=3.5 size= 1940kB time=00:00:08.02 bitrate=1981.0kbits/s dup=0 drop=106 sp
eed=0.336x
06-08 17:43:54.472 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 113 fps=4.
6 q=3.1 size= 1968kB time=00:00:08.02 bitrate=2010.1kbits/s dup=0 drop=108 sp
eed=0.329x
06-08 17:43:55.129 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 116 fps=4.
6 q=3.3 size= 2016kB time=00:00:08.02 bitrate=2058.5kbits/s dup=0 drop=111 sp
eed=0.321x
06-08 17:43:55.624 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 119 fps=4.
7 q=3.2 size= 2052kB time=00:00:08.02 bitrate=2096.0kbits/s dup=0 drop=114 sp
eed=0.314x
06-08 17:43:56.082 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 121 fps=4.
6 q=2.7 size= 2119kB time=00:00:08.06 bitrate=2152.0kbits/s dup=0 drop=116 sp
eed=0.309x
06-08 17:43:56.729 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 124 fps=4.
7 q=4.0 size= 2172kB time=00:00:09.02 bitrate=1971.5kbits/s dup=0 drop=119 sp
eed=0.339x
06-08 17:43:57.292 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 127 fps=4.
7 q=3.5 size= 2210kB time=00:00:09.02 bitrate=2006.0kbits/s dup=0 drop=122 sp
eed=0.332x
06-08 17:43:57.793 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 129 fps=4.
7 q=3.3 size= 2234kB time=00:00:09.02 bitrate=2028.1kbits/s dup=0 drop=124 sp
eed=0.326x
06-08 17:43:58.431 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 132 fps=4.
7 q=3.3 size= 2275kB time=00:00:09.02 bitrate=2065.6kbits/s dup=0 drop=127 sp
eed=0.319x
06-08 17:43:58.986 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 135 fps=4.
7 q=3.4 size= 2344kB time=00:00:09.02 bitrate=2127.5kbits/s dup=0 drop=130 sp
eed=0.313x
06-08 17:43:59.374 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 136 fps=4.
6 q=3.2 size= 2356kB time=00:00:09.10 bitrate=2119.0kbits/s dup=0 drop=131 sp
eed=0.31x
06-08 17:43:59.986 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 139 fps=4.
6 q=2.9 size= 2392kB time=00:00:10.02 bitrate=1954.2kbits/s dup=0 drop=133 sp
eed=0.335x
06-08 17:44:00.582 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 142 fps=4.
7 q=2.8 size= 2428kB time=00:00:10.02 bitrate=1983.5kbits/s dup=0 drop=136 sp
eed=0.329x
06-08 17:44:01.158 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 145 fps=4.
7 q=3.0 size= 2516kB time=00:00:10.02 bitrate=2055.4kbits/s dup=0 drop=139 sp
eed=0.323x
06-08 17:44:01.691 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 148 fps=4.
7 q=4.6 size= 2583kB time=00:00:10.02 bitrate=2110.7kbits/s dup=0 drop=142 sp
eed=0.317x
06-08 17:44:02.168 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 150 fps=4.
7 q=4.8 size= 2626kB time=00:00:10.02 bitrate=2145.1kbits/s dup=0 drop=144 sp
eed=0.312x
06-08 17:44:02.587 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 152 fps=4.
7 q=5.0 size= 2668kB time=00:00:10.32 bitrate=2117.0kbits/s dup=0 drop=146 sp
eed=0.317x
06-08 17:44:03.209 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 154 fps=4.
6 q=5.0 size= 2709kB time=00:00:11.02 bitrate=2012.4kbits/s dup=0 drop=148 sp
eed=0.333x
06-08 17:44:03.815 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 157 fps=4.
7 q=3.7 size= 2770kB time=00:00:11.02 bitrate=2057.2kbits/s dup=0 drop=151 sp
eed=0.327x
06-08 17:44:04.402 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 160 fps=4.
7 q=3.3 size= 2800kB time=00:00:11.02 bitrate=2079.7kbits/s dup=0 drop=154 sp
eed=0.321x
06-08 17:44:04.965 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 163 fps=4.
7 q=3.0 size= 2835kB time=00:00:11.02 bitrate=2105.7kbits/s dup=0 drop=157 sp
eed=0.316x
06-08 17:44:05.505 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 166 fps=4.
7 q=3.1 size= 2880kB time=00:00:11.06 bitrate=2131.8kbits/s dup=0 drop=160 sp
eed=0.313x
06-08 17:44:06.094 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 169 fps=4.
7 q=3.3 size= 2880kB time=00:00:11.26 bitrate=2093.9kbits/s dup=0 drop=163 sp
eed=0.313x
06-08 17:44:06.603 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 171 fps=4.
7 q=3.8 size= 2880kB time=00:00:11.40 bitrate=2069.5kbits/s dup=0 drop=165 sp
eed=0.312x
06-08 17:44:07.192 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 174 fps=4.
7 q=3.6 size= 2880kB time=00:00:11.60 bitrate=2033.8kbits/s dup=0 drop=168 sp
eed=0.313x
06-08 17:44:07.772 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 177 fps=4.
7 q=3.3 size= 2880kB time=00:00:11.80 bitrate=1999.3kbits/s dup=0 drop=171 sp
eed=0.313x
06-08 17:44:08.287 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 180 fps=4.
7 q=3.2 size= 2880kB time=00:00:12.00 bitrate=1966.0kbits/s dup=0 drop=174 sp
eed=0.314x
06-08 17:44:08.900 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 182 fps=4.
7 q=3.5 size= 3118kB time=00:00:12.13 bitrate=2105.2kbits/s dup=0 drop=176 sp
eed=0.313x
06-08 17:44:08.915 20835 20835 D ffmpeg : FFmpeg:onProgress: frame= 182 fps=4.
7 q=3.5 Lsize= 3205kB time=00:00:12.13 bitrate=2163.7kbits/s dup=0 drop=176 s
peed=0.312x
06-08 17:44:08.915 20835 20835 D ffmpeg : FFmpeg:onProgress: video:3177kB audio
:21kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.19565
3%
06-08 17:44:08.946 20835 20835 D ffmpeg : FFmpeg:onProgress: [aac @ 0xb5c44c00]
Qavg: 137.182
06-08 17:44:08.963 20835 20835 D ffmpeg : FFmpeg:onSuccess: ffmpeg version n3.0
.1 Copyright (c) 2000-2016 the FFmpeg developers
06-08 17:44:08.963 20835 20835 D ffmpeg : built with gcc 4.8 (GCC)
06-08 17:44:08.963 20835 20835 D ffmpeg : configuration: --target-os=linux --
cross-prefix=/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/bin/arm-l
inux-androideabi- --arch=arm --cpu=cortex-a8 --enable-runtime-cpudetect --sysroo
t=/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/sysroot --enable-pic
--enable-libx264 --enable-libass --enable-libfreetype --enable-libfribidi --ena
ble-libmp3lame --enable-fontconfig --enable-pthreads --disable-debug --disable-f
fserver --enable-version3 --enable-hardcoded-tables --disable-ffplay --disable-f
fprobe --enable-gpl --enable-yasm --disable-doc --disable-shared --enable-static
--pkg-config=/home/vagrant/SourceCode/ffmpeg-android/ffmpeg-pkg-config --prefix
=/home/vagrant/SourceCode/ffmpeg-android/build/armeabi-v7a --extra-cflags='-I/ho
me/vagrant/SourceCode/ffmpeg-android/toolchain-android/include -U_FORTIFY_SOURCE
-D_FORTIFY_SOURCE=2 -fno-strict-overflow -fstack-protector-all' --extra-ldflags
='-L/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/lib -Wl,-z,relro -
Wl,-z,now -pie' --extra-libs='-lpng -lexpat -lm' --extra-cxxflags=
06-08 17:44:08.963 20835 20835 D ffmpeg : libavutil 55. 17.103 / 55. 17.
103
06-08 17:44:08.963 20835 20835 D ffmpeg : libavcodec 57. 24.102 / 57. 24.
102
06-08 17:44:08.963 20835 20835 D ffmpeg : libavformat 57. 25.100 / 57. 25.
100
06-08 17:44:08.963 20835 20835 D ffmpeg : libavdevice 57. 0.101 / 57. 0.
101
06-08 17:44:08.963 20835 20835 D ffmpeg : libavfilter 6. 31.100 / 6. 31.
100
06-08 17:44:08.963 20835 20835 D ffmpeg : libswscale 4. 0.100 / 4. 0.
100
06-08 17:44:08.963 20835 20835 D ffmpeg : libswresample 2. 0.101 / 2. 0.
101
06-08 17:44:08.963 20835 20835 D ffmpeg : libpostproc 54. 0.100 / 54. 0.
100
06-08 17:44:08.963 20835 20835 D ffmpeg : Input #0, mov,mp4,m4a,3gp,3g2,mj2, fr
om '/storage/emulated/0/Pictures/test2.mp4':
06-08 17:44:08.963 20835 20835 D ffmpeg : Metadata:
06-08 17:44:08.963 20835 20835 D ffmpeg : major_brand : mp42
06-08 17:44:08.963 20835 20835 D ffmpeg : minor_version : 0
06-08 17:44:08.963 20835 20835 D ffmpeg : compatible_brands: isommp42
06-08 17:44:08.963 20835 20835 D ffmpeg : creation_time : 2016-06-02 09:2
0:58
06-08 17:44:08.963 20835 20835 D ffmpeg : com.android.version: 6.0.1
06-08 17:44:08.963 20835 20835 D ffmpeg : Duration: 00:00:12.03, start: 0.000
000, bitrate: 17234 kb/s
06-08 17:44:08.963 20835 20835 D ffmpeg : Stream #0:0(eng): Video: h264 (Ba
seline) (avc1 / 0x31637661), yuv420p, 1920x1080, 16902 kb/s, SAR 1:1 DAR 16:9, 2
9.81 fps, 29.85 tbr, 90k tbn, 180k tbc (default)
06-08 17:44:08.963 20835 20835 D ffmpeg : Metadata:
06-08 17:44:08.963 20835 20835 D ffmpeg : rotate : 90
06-08 17:44:08.963 20835 20835 D ffmpeg : creation_time : 2016-06-02 09
:20:58
06-08 17:44:08.963 20835 20835 D ffmpeg : handler_name : VideoHandle
06-08 17:44:08.963 20835 20835 D ffmpeg : Side data:
06-08 17:44:08.963 20835 20835 D ffmpeg : displaymatrix: rotation of -90.
00 degrees
06-08 17:44:08.963 20835 20835 D ffmpeg : Stream #0:1(eng): Audio: aac (LC)
(mp4a / 0x6134706D), 48000 Hz, mono, fltp, 96 kb/s (default)
06-08 17:44:08.963 20835 20835 D ffmpeg : Metadata:
06-08 17:44:08.963 20835 20835 D ffmpeg : creation_time : 2016-06-02 09
:20:58
06-08 17:44:08.963 20835 20835 D ffmpeg : handler_name : SoundHandle
06-08 17:44:08.963 20835 20835 D ffmpeg : Please use -b:a or -b:v, -b is ambigu
ous
06-08 17:44:08.963 20835 20835 D ffmpeg : Codec AVOption preset (Set the encodi
ng preset (cf. x264 --fullhelp)) specified for output file #0 (/storage/emulated
/0/Pictures/scaled_video.mp4) has not been used for any stream. The most likely
reason is either wrong type (e.g. a video option with no video streams) or that
it is a private option of some encoder which was not actually used for any strea
m.
06-08 17:44:08.963 20835 20835 D ffmpeg : [mpeg4 @ 0xb5c44400] Invalid pixel as
pect ratio 5121/5120, limit is 255/255 reducing
06-08 17:44:08.963 20835 20835 D ffmpeg : Output #0, mp4, to '/storage/emulated
/0/Pictures/scaled_video.mp4':
06-08 17:44:08.963 20835 20835 D ffmpeg : Metadata:
06-08 17:44:08.963 20835 20835 D ffmpeg : major_brand : mp42
06-08 17:44:08.963 20835 20835 D ffmpeg : minor_version : 0
06-08 17:44:08.963 20835 20835 D ffmpeg : compatible_brands: isommp42
06-08 17:44:08.963 20835 20835 D ffmpeg : com.android.version: 6.0.1
06-08 17:44:08.963 20835 20835 D ffmpeg : encoder : Lavf57.25.100
06-08 17:44:08.963 20835 20835 D ffmpeg : Stream #0:0(eng): Video: mpeg4 (
[0][0][0] / 0x0020), yuv420p, 640x1138 [SAR 1:1 DAR 320:569], q=2-31, 2097 kb/s,
SAR 5121:5120 DAR 9:16, 15 fps, 15360 tbn, 15 tbc (default)
06-08 17:44:08.963 20835 20835 D ffmpeg : Metadata:
06-08 17:44:08.963 20835 20835 D ffmpeg : handler_name : VideoHandle
06-08 17:44:08.963 20835 20835 D ffmpeg : creation_time : 2016-06-02 09
:20:58
06-08 17:44:08.963 20835 20835 D ffmpeg : encoder : Lavc57.24.102
mpeg4
06-08 17:44:08.963 20835 20835 D ffmpeg : Side data:
06-08 17:44:08.963 20835 20835 D ffmpeg : unknown side data type 10 (24 b
ytes)
06-08 17:44:08.963 20835 20835 D ffmpeg : Stream #0:1(eng): Audio: aac (LC)
([64][0][0][0] / 0x0040), 48000 Hz, mono, fltp, 12 kb/s (default)
06-08 17:44:08.963 20835 20835 D ffmpeg : Metadata:
06-08 17:44:08.963 20835 20835 D ffmpeg : creation_time : 2016-06-02 09
:20:58
06-08 17:44:08.963 20835 20835 D ffmpeg : handler_name : SoundHandle
06-08 17:44:08.963 20835 20835 D ffmpeg : encoder : Lavc57.24.102
aac
06-08 17:44:08.963 20835 20835 D ffmpeg : Stream mapping:
06-08 17:44:08.963 20835 20835 D ffmpeg : Stream #0:0 -> #0:0 (h264 (native)
-> mpeg4 (native))
06-08 17:44:08.963 20835 20835 D ffmpeg : Stream #0:1 -> #0:1 (aac (native) -
> aac (native))
06-08 17:44:08.963 20835 20835 D ffmpeg : Press [q] to stop, [?] for help
06-08 17:44:08.963 20835 20835 D ffmpeg : frame= 2 fps=0.0 q=2.0 size= 1
29kB time=00:00:01.00 bitrate=1056.4kbits/s speed=1.66x
06-08 17:44:08.963 20835 20835 D ffmpeg : frame= 5 fps=4.0 q=2.0 size= 3
14kB time=00:00:01.00 bitrate=2566.0kbits/s dup=0 drop=1 speed=0.809x
06-08 17:44:08.963 20835 20835 D ffmpeg : frame= 8
06-08 17:44:08.963 20835 20835 D ffmpeg : FFmpeg:onFinish: -
Encoding Exception during Transcode with audio files
6 mai 2016, par Hakop ZakaryanI am attempting to transcode using an FFMPEG Wrapper Library called JAVE on Mac OSX 10.11.3 using Eclipse 4.50
My Converter.java class looks something like this :
package matador;
import it.sauronsoftware.jave.AudioAttributes;
import it.sauronsoftware.jave.EncodingAttributes;
import it.sauronsoftware.jave.EncoderException;
import it.sauronsoftware.jave.InputFormatException;
import it.sauronsoftware.jave.Encoder;
import java.io.*;
public class Converter {
public static void main(String[] args) throws InputFormatException, EncoderException {
File source = new File("Classic.m4a");
File target = new File("target.mp3");
AudioAttributes audio = new AudioAttributes();
audio.setCodec("libmp3lame");
audio.setBitRate(new Integer(128000));
audio.setChannels(new Integer(2));
audio.setSamplingRate(new Integer(44100));
EncodingAttributes attrs = new EncodingAttributes();
attrs.setFormat("mp3");
attrs.setAudioAttributes(audio);
Encoder encoder = new Encoder(new MyFFMPEGExecutableLocator());
try {
encoder.encode(source, target, attrs, null);
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (InputFormatException e) {
e.printStackTrace();
} catch (EncoderException e) {
e.printStackTrace();
}
}
}The problem I am running into is that with specific audio files (regardless of format) give me this EncoderException :
it.sauronsoftware.jave.EncoderException: Metadata:
at it.sauronsoftware.jave.Encoder.encode(Encoder.java:863)
at matador.Converter.main(Converter.java:32)I have looked through Encoder.java and the EncoderException on line 863 is this specific code :
} else if (!line.startsWith("Output #0")) {
throw new EncoderException(line);I have been unable to figure out why this may be occurring but specific audio files (WAV/AAC/etc) do encode yet a majority just give this exception.
Thank you for the help !
Edit : As per request for possibly being able to help me further, here is the entirety of the Encoder.java code :
package it.sauronsoftware.jave;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.StringTokenizer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Encoder {
private static final Pattern FORMAT_PATTERN = Pattern
.compile("^\\s*([D ])([E ])\\s+([\\w,]+)\\s+.+$");
private static final Pattern ENCODER_DECODER_PATTERN = Pattern.compile(
"^\\s*([D ])([E ])([AVS]).{3}\\s+(.+)$", Pattern.CASE_INSENSITIVE);
private static final Pattern PROGRESS_INFO_PATTERN = Pattern.compile(
"\\s*(\\w+)\\s*=\\s*(\\S+)\\s*", Pattern.CASE_INSENSITIVE);
private static final Pattern SIZE_PATTERN = Pattern.compile(
"(\\d+)x(\\d+)", Pattern.CASE_INSENSITIVE);
private static final Pattern FRAME_RATE_PATTERN = Pattern.compile(
"([\\d.]+)\\s+(?:fps|tb\\(r\\))", Pattern.CASE_INSENSITIVE);
private static final Pattern BIT_RATE_PATTERN = Pattern.compile(
"(\\d+)\\s+kb/s", Pattern.CASE_INSENSITIVE);
private static final Pattern SAMPLING_RATE_PATTERN = Pattern.compile(
"(\\d+)\\s+Hz", Pattern.CASE_INSENSITIVE);
private static final Pattern CHANNELS_PATTERN = Pattern.compile(
"(mono|stereo)", Pattern.CASE_INSENSITIVE);
private static final Pattern SUCCESS_PATTERN = Pattern.compile(
"^\\s*video\\:\\S+\\s+audio\\:\\S+\\s+global headers\\:\\S+.*$",
Pattern.CASE_INSENSITIVE);
private FFMPEGLocator locator;
public Encoder() {
this.locator = new DefaultFFMPEGLocator();
}
public Encoder(FFMPEGLocator locator) {
this.locator = locator;
}
public String[] getAudioDecoders() throws EncoderException {
ArrayList res = new ArrayList();
FFMPEGExecutor ffmpeg = locator.createExecutor();
ffmpeg.addArgument("-formats");
try {
ffmpeg.execute();
RBufferedReader reader = null;
reader = new RBufferedReader(new InputStreamReader(ffmpeg
.getInputStream()));
String line;
boolean evaluate = false;
while ((line = reader.readLine()) != null) {
if (line.trim().length() == 0) {
continue;
}
if (evaluate) {
Matcher matcher = ENCODER_DECODER_PATTERN.matcher(line);
if (matcher.matches()) {
String decoderFlag = matcher.group(1);
String audioVideoFlag = matcher.group(3);
if ("D".equals(decoderFlag)
&& "A".equals(audioVideoFlag)) {
String name = matcher.group(4);
res.add(name);
}
} else {
break;
}
} else if (line.trim().equals("Codecs:")) {
evaluate = true;
}
}
} catch (IOException e) {
throw new EncoderException(e);
} finally {
ffmpeg.destroy();
}
int size = res.size();
String[] ret = new String[size];
for (int i = 0; i < size; i++) {
ret[i] = (String) res.get(i);
}
return ret;
}
public String[] getAudioEncoders() throws EncoderException {
ArrayList res = new ArrayList();
FFMPEGExecutor ffmpeg = locator.createExecutor();
ffmpeg.addArgument("-formats");
try {
ffmpeg.execute();
RBufferedReader reader = null;
reader = new RBufferedReader(new InputStreamReader(ffmpeg
.getInputStream()));
String line;
boolean evaluate = false;
while ((line = reader.readLine()) != null) {
if (line.trim().length() == 0) {
continue;
}
if (evaluate) {
Matcher matcher = ENCODER_DECODER_PATTERN.matcher(line);
if (matcher.matches()) {
String encoderFlag = matcher.group(2);
String audioVideoFlag = matcher.group(3);
if ("E".equals(encoderFlag)
&& "A".equals(audioVideoFlag)) {
String name = matcher.group(4);
res.add(name);
}
} else {
break;
}
} else if (line.trim().equals("Codecs:")) {
evaluate = true;
}
}
} catch (IOException e) {
throw new EncoderException(e);
} finally {
ffmpeg.destroy();
}
int size = res.size();
String[] ret = new String[size];
for (int i = 0; i < size; i++) {
ret[i] = (String) res.get(i);
}
return ret;
}
public String[] getVideoDecoders() throws EncoderException {
ArrayList res = new ArrayList();
FFMPEGExecutor ffmpeg = locator.createExecutor();
ffmpeg.addArgument("-formats");
try {
ffmpeg.execute();
RBufferedReader reader = null;
reader = new RBufferedReader(new InputStreamReader(ffmpeg
.getInputStream()));
String line;
boolean evaluate = false;
while ((line = reader.readLine()) != null) {
if (line.trim().length() == 0) {
continue;
}
if (evaluate) {
Matcher matcher = ENCODER_DECODER_PATTERN.matcher(line);
if (matcher.matches()) {
String decoderFlag = matcher.group(1);
String audioVideoFlag = matcher.group(3);
if ("D".equals(decoderFlag)
&& "V".equals(audioVideoFlag)) {
String name = matcher.group(4);
res.add(name);
}
} else {
break;
}
} else if (line.trim().equals("Codecs:")) {
evaluate = true;
}
}
} catch (IOException e) {
throw new EncoderException(e);
} finally {
ffmpeg.destroy();
}
int size = res.size();
String[] ret = new String[size];
for (int i = 0; i < size; i++) {
ret[i] = (String) res.get(i);
}
return ret;
}
public String[] getVideoEncoders() throws EncoderException {
ArrayList res = new ArrayList();
FFMPEGExecutor ffmpeg = locator.createExecutor();
ffmpeg.addArgument("-formats");
try {
ffmpeg.execute();
RBufferedReader reader = null;
reader = new RBufferedReader(new InputStreamReader(ffmpeg
.getInputStream()));
String line;
boolean evaluate = false;
while ((line = reader.readLine()) != null) {
if (line.trim().length() == 0) {
continue;
}
if (evaluate) {
Matcher matcher = ENCODER_DECODER_PATTERN.matcher(line);
if (matcher.matches()) {
String encoderFlag = matcher.group(2);
String audioVideoFlag = matcher.group(3);
if ("E".equals(encoderFlag)
&& "V".equals(audioVideoFlag)) {
String name = matcher.group(4);
res.add(name);
}
} else {
break;
}
} else if (line.trim().equals("Codecs:")) {
evaluate = true;
}
}
} catch (IOException e) {
throw new EncoderException(e);
} finally {
ffmpeg.destroy();
}
int size = res.size();
String[] ret = new String[size];
for (int i = 0; i < size; i++) {
ret[i] = (String) res.get(i);
}
return ret;
}
public String[] getSupportedEncodingFormats() throws EncoderException {
ArrayList res = new ArrayList();
FFMPEGExecutor ffmpeg = locator.createExecutor();
ffmpeg.addArgument("-formats");
try {
ffmpeg.execute();
RBufferedReader reader = null;
reader = new RBufferedReader(new InputStreamReader(ffmpeg
.getInputStream()));
String line;
boolean evaluate = false;
while ((line = reader.readLine()) != null) {
if (line.trim().length() == 0) {
continue;
}
if (evaluate) {
Matcher matcher = FORMAT_PATTERN.matcher(line);
if (matcher.matches()) {
String encoderFlag = matcher.group(2);
if ("E".equals(encoderFlag)) {
String aux = matcher.group(3);
StringTokenizer st = new StringTokenizer(aux, ",");
while (st.hasMoreTokens()) {
String token = st.nextToken().trim();
if (!res.contains(token)) {
res.add(token);
}
}
}
} else {
break;
}
} else if (line.trim().equals("File formats:")) {
evaluate = true;
}
}
} catch (IOException e) {
throw new EncoderException(e);
} finally {
ffmpeg.destroy();
}
int size = res.size();
String[] ret = new String[size];
for (int i = 0; i < size; i++) {
ret[i] = (String) res.get(i);
}
return ret;
}
public String[] getSupportedDecodingFormats() throws EncoderException {
ArrayList res = new ArrayList();
FFMPEGExecutor ffmpeg = locator.createExecutor();
ffmpeg.addArgument("-formats");
try {
ffmpeg.execute();
RBufferedReader reader = null;
reader = new RBufferedReader(new InputStreamReader(ffmpeg
.getInputStream()));
String line;
boolean evaluate = false;
while ((line = reader.readLine()) != null) {
if (line.trim().length() == 0) {
continue;
}
if (evaluate) {
Matcher matcher = FORMAT_PATTERN.matcher(line);
if (matcher.matches()) {
String decoderFlag = matcher.group(1);
if ("D".equals(decoderFlag)) {
String aux = matcher.group(3);
StringTokenizer st = new StringTokenizer(aux, ",");
while (st.hasMoreTokens()) {
String token = st.nextToken().trim();
if (!res.contains(token)) {
res.add(token);
}
}
}
} else {
break;
}
} else if (line.trim().equals("File formats:")) {
evaluate = true;
}
}
} catch (IOException e) {
throw new EncoderException(e);
} finally {
ffmpeg.destroy();
}
int size = res.size();
String[] ret = new String[size];
for (int i = 0; i < size; i++) {
ret[i] = (String) res.get(i);
}
return ret;
}
public MultimediaInfo getInfo(File source) throws InputFormatException,
EncoderException {
FFMPEGExecutor ffmpeg = locator.createExecutor();
ffmpeg.addArgument("-i");
ffmpeg.addArgument(source.getAbsolutePath());
try {
ffmpeg.execute();
} catch (IOException e) {
throw new EncoderException(e);
}
try {
RBufferedReader reader = null;
reader = new RBufferedReader(new InputStreamReader(ffmpeg
.getErrorStream()));
return parseMultimediaInfo(source, reader);
} finally {
ffmpeg.destroy();
}
}
private MultimediaInfo parseMultimediaInfo(File source,
RBufferedReader reader) throws InputFormatException,
EncoderException {
Pattern p1 = Pattern.compile("^\\s*Input #0, (\\w+).+$\\s*",
Pattern.CASE_INSENSITIVE);
Pattern p2 = Pattern.compile(
"^\\s*Duration: (\\d\\d):(\\d\\d):(\\d\\d)\\.(\\d).*$",
Pattern.CASE_INSENSITIVE);
Pattern p3 = Pattern.compile(
"^\\s*Stream #\\S+: ((?:Audio)|(?:Video)|(?:Data)): (.*)\\s*$",
Pattern.CASE_INSENSITIVE);
MultimediaInfo info = null;
try {
int step = 0;
while (true) {
String line = reader.readLine();
if (line == null) {
break;
}
if (step == 0) {
String token = source.getAbsolutePath() + ": ";
if (line.startsWith(token)) {
String message = line.substring(token.length());
throw new InputFormatException(message);
}
Matcher m = p1.matcher(line);
if (m.matches()) {
String format = m.group(1);
info = new MultimediaInfo();
info.setFormat(format);
step++;
}
} else if (step == 1) {
Matcher m = p2.matcher(line);
if (m.matches()) {
long hours = Integer.parseInt(m.group(1));
long minutes = Integer.parseInt(m.group(2));
long seconds = Integer.parseInt(m.group(3));
long dec = Integer.parseInt(m.group(4));
long duration = (dec * 100L) + (seconds * 1000L)
+ (minutes * 60L * 1000L)
+ (hours * 60L * 60L * 1000L);
info.setDuration(duration);
step++;
} else {
step = 3;
}
} else if (step == 2) {
Matcher m = p3.matcher(line);
if (m.matches()) {
String type = m.group(1);
String specs = m.group(2);
if ("Video".equalsIgnoreCase(type)) {
VideoInfo video = new VideoInfo();
StringTokenizer st = new StringTokenizer(specs, ",");
for (int i = 0; st.hasMoreTokens(); i++) {
String token = st.nextToken().trim();
if (i == 0) {
video.setDecoder(token);
} else {
boolean parsed = false;
// Video size.
Matcher m2 = SIZE_PATTERN.matcher(token);
if (!parsed && m2.find()) {
int width = Integer.parseInt(m2
.group(1));
int height = Integer.parseInt(m2
.group(2));
video.setSize(new VideoSize(width,
height));
parsed = true;
}
// Frame rate.
m2 = FRAME_RATE_PATTERN.matcher(token);
if (!parsed && m2.find()) {
try {
float frameRate = Float
.parseFloat(m2.group(1));
video.setFrameRate(frameRate);
} catch (NumberFormatException e) {
;
}
parsed = true;
}
// Bit rate.
m2 = BIT_RATE_PATTERN.matcher(token);
if (!parsed && m2.find()) {
int bitRate = Integer.parseInt(m2
.group(1));
video.setBitRate(bitRate);
parsed = true;
}
}
}
info.setVideo(video);
} else if ("Audio".equalsIgnoreCase(type)) {
AudioInfo audio = new AudioInfo();
StringTokenizer st = new StringTokenizer(specs, ",");
for (int i = 0; st.hasMoreTokens(); i++) {
String token = st.nextToken().trim();
if (i == 0) {
audio.setDecoder(token);
} else {
boolean parsed = false;
// Sampling rate.
Matcher m2 = SAMPLING_RATE_PATTERN
.matcher(token);
if (!parsed && m2.find()) {
int samplingRate = Integer.parseInt(m2
.group(1));
audio.setSamplingRate(samplingRate);
parsed = true;
}
// Channels.
m2 = CHANNELS_PATTERN.matcher(token);
if (!parsed && m2.find()) {
String ms = m2.group(1);
if ("mono".equalsIgnoreCase(ms)) {
audio.setChannels(1);
} else if ("stereo"
.equalsIgnoreCase(ms)) {
audio.setChannels(2);
}
parsed = true;
}
// Bit rate.
m2 = BIT_RATE_PATTERN.matcher(token);
if (!parsed && m2.find()) {
int bitRate = Integer.parseInt(m2
.group(1));
audio.setBitRate(bitRate);
parsed = true;
}
}
}
info.setAudio(audio);
}
} else {
step = 3;
}
}
if (step == 3) {
reader.reinsertLine(line);
break;
}
}
} catch (IOException e) {
throw new EncoderException(e);
}
if (info == null) {
throw new InputFormatException();
}
return info;
}
private Hashtable parseProgressInfoLine(String line) {
Hashtable table = null;
Matcher m = PROGRESS_INFO_PATTERN.matcher(line);
while (m.find()) {
if (table == null) {
table = new Hashtable();
}
String key = m.group(1);
String value = m.group(2);
table.put(key, value);
}
return table;
}
public void encode(File source, File target, EncodingAttributes attributes)
throws IllegalArgumentException, InputFormatException,
EncoderException {
encode(source, target, attributes, null);
}
public void encode(File source, File target, EncodingAttributes attributes,
EncoderProgressListener listener) throws IllegalArgumentException,
InputFormatException, EncoderException {
String formatAttribute = attributes.getFormat();
Float offsetAttribute = attributes.getOffset();
Float durationAttribute = attributes.getDuration();
AudioAttributes audioAttributes = attributes.getAudioAttributes();
VideoAttributes videoAttributes = attributes.getVideoAttributes();
if (audioAttributes == null && videoAttributes == null) {
throw new IllegalArgumentException(
"Both audio and video attributes are null");
}
target = target.getAbsoluteFile();
target.getParentFile().mkdirs();
FFMPEGExecutor ffmpeg = locator.createExecutor();
if (offsetAttribute != null) {
ffmpeg.addArgument("-ss");
ffmpeg.addArgument(String.valueOf(offsetAttribute.floatValue()));
}
ffmpeg.addArgument("-i");
ffmpeg.addArgument(source.getAbsolutePath());
if (durationAttribute != null) {
ffmpeg.addArgument("-t");
ffmpeg.addArgument(String.valueOf(durationAttribute.floatValue()));
}
if (videoAttributes == null) {
ffmpeg.addArgument("-vn");
} else {
String codec = videoAttributes.getCodec();
if (codec != null) {
ffmpeg.addArgument("-vcodec");
ffmpeg.addArgument(codec);
}
String tag = videoAttributes.getTag();
if (tag != null) {
ffmpeg.addArgument("-vtag");
ffmpeg.addArgument(tag);
}
Integer bitRate = videoAttributes.getBitRate();
if (bitRate != null) {
ffmpeg.addArgument("-b");
ffmpeg.addArgument(String.valueOf(bitRate.intValue()));
}
Integer frameRate = videoAttributes.getFrameRate();
if (frameRate != null) {
ffmpeg.addArgument("-r");
ffmpeg.addArgument(String.valueOf(frameRate.intValue()));
}
VideoSize size = videoAttributes.getSize();
if (size != null) {
ffmpeg.addArgument("-s");
ffmpeg.addArgument(String.valueOf(size.getWidth()) + "x"
+ String.valueOf(size.getHeight()));
}
}
if (audioAttributes == null) {
ffmpeg.addArgument("-an");
} else {
String codec = audioAttributes.getCodec();
if (codec != null) {
ffmpeg.addArgument("-acodec");
ffmpeg.addArgument(codec);
}
Integer bitRate = audioAttributes.getBitRate();
if (bitRate != null) {
ffmpeg.addArgument("-ab");
ffmpeg.addArgument(String.valueOf(bitRate.intValue()));
}
Integer channels = audioAttributes.getChannels();
if (channels != null) {
ffmpeg.addArgument("-ac");
ffmpeg.addArgument(String.valueOf(channels.intValue()));
}
Integer samplingRate = audioAttributes.getSamplingRate();
if (samplingRate != null) {
ffmpeg.addArgument("-ar");
ffmpeg.addArgument(String.valueOf(samplingRate.intValue()));
}
Integer volume = audioAttributes.getVolume();
if (volume != null) {
ffmpeg.addArgument("-vol");
ffmpeg.addArgument(String.valueOf(volume.intValue()));
}
}
ffmpeg.addArgument("-f");
ffmpeg.addArgument(formatAttribute);
ffmpeg.addArgument("-y");
ffmpeg.addArgument(target.getAbsolutePath());
try {
ffmpeg.execute();
} catch (IOException e) {
throw new EncoderException(e);
}
try {
String lastWarning = null;
long duration;
long progress = 0;
RBufferedReader reader = null;
reader = new RBufferedReader(new InputStreamReader(ffmpeg
.getErrorStream()));
MultimediaInfo info = parseMultimediaInfo(source, reader);
if (durationAttribute != null) {
duration = (long) Math
.round((durationAttribute.floatValue() * 1000L));
} else {
duration = info.getDuration();
if (offsetAttribute != null) {
duration -= (long) Math
.round((offsetAttribute.floatValue() * 1000L));
}
}
if (listener != null) {
listener.sourceInfo(info);
}
int step = 0;
String line;
while ((line = reader.readLine()) != null) {
if (step == 0) {
if (line.startsWith("WARNING: ")) {
if (listener != null) {
listener.message(line);
}
} else if (!line.startsWith("Output #0")) {
throw new EncoderException(line);
} else {
step++;
}
} else if (step == 1) {
if (!line.startsWith(" ")) {
step++;
}
}
if (step == 2) {
if (!line.startsWith("Stream mapping:")) {
throw new EncoderException(line);
} else {
step++;
}
} else if (step == 3) {
if (!line.startsWith(" ")) {
step++;
}
}
if (step == 4) {
line = line.trim();
if (line.length() > 0) {
Hashtable table = parseProgressInfoLine(line);
if (table == null) {
if (listener != null) {
listener.message(line);
}
lastWarning = line;
} else {
if (listener != null) {
String time = (String) table.get("time");
if (time != null) {
int dot = time.indexOf('.');
if (dot > 0 && dot == time.length() - 2
&& duration > 0) {
String p1 = time.substring(0, dot);
String p2 = time.substring(dot + 1);
try {
long i1 = Long.parseLong(p1);
long i2 = Long.parseLong(p2);
progress = (i1 * 1000L)
+ (i2 * 100L);
int perm = (int) Math
.round((double) (progress * 1000L)
/ (double) duration);
if (perm > 1000) {
perm = 1000;kMDItemAudioEncodingApplication = "Lavf57.26.100"
}
listener.progress(perm);
} catch (NumberFormatException e) {
;
}
}
}
}
lastWarning = null;
}
}
}
}
if (lastWarning != null) {
if (!SUCCESS_PATTERN.matcher(lastWarning).matches()) {
throw new EncoderException(lastWarning);
}
}
} catch (IOException e) {
throw new EncoderException(e);
} finally {
ffmpeg.destroy();
}
}
} -
MediaPlayer within TextureView not working as intended
15 mars 2016, par RussieeI’ve put in a MediaPlayer within a TextureView, which itself is located inside a ListView.
Yesterday, the MediaPlayer worked as intended with a test .mp4 clip.
Today, the MediaPlayer tries doing some kind of FFmpeg Extractor, for which i’ve been unable to find any kind of information about.This is the stack trace :
03-14 13:43:00.076 477-16532/? V/FFmpegExtractor: SniffFFMPEG
03-14 13:43:00.076 477-16532/? I/FFmpegExtractor: android-source:0xafcff040
03-14 13:43:00.077 477-16532/? D/FFMPEG: android source begin open
03-14 13:43:00.077 477-16532/? D/FFMPEG: android open, url: android-source:0xafcff040
03-14 13:43:00.077 477-16532/? D/FFMPEG: ffmpeg open android data source success, source ptr: 0xafcff040
03-14 13:43:00.077 477-16532/? D/FFMPEG: android source open success
03-14 13:43:00.149 477-16532/? I/FFMPEG: Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'android-source:0xafcff040':
03-14 13:43:00.149 477-16532/? I/FFMPEG: Metadata:
03-14 13:43:00.149 477-16532/? I/FFMPEG: major_brand : qt
03-14 13:43:00.149 477-16532/? I/FFMPEG: minor_version : 0
03-14 13:43:00.149 477-16532/? I/FFMPEG: compatible_brands: qt
03-14 13:43:00.149 477-16532/? I/FFMPEG: creation_time : 2016-03-13 19:24:58
03-14 13:43:00.149 477-16532/? I/FFMPEG: Duration: 00:00:10.88, start: 0.000000, bitrate: 11209 kb/s
03-14 13:43:00.149 477-16532/? I/FFMPEG: Stream #0:0(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 86 kb/s (default)
03-14 13:43:00.149 477-16532/? I/FFMPEG: Metadata:
03-14 13:43:00.149 477-16532/? I/FFMPEG: creation_time : 2016-03-13 19:24:58
03-14 13:43:00.149 477-16532/? I/FFMPEG: handler_name : Core Media Data Handler
03-14 13:43:00.149 477-16532/? I/FFMPEG: Stream #0:1(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 11113 kb/s, 29.98 fps, 29.97 tbr, 600 tbn, 50 tbc (default)
03-14 13:43:00.149 477-16532/? I/FFMPEG: Metadata:
03-14 13:43:00.149 477-16532/? I/FFMPEG: creation_time : 2016-03-13 19:24:58
03-14 13:43:00.149 477-16532/? I/FFMPEG: handler_name : Core Media Data Handler
03-14 13:43:00.149 477-16532/? I/FFMPEG: encoder : H.264
03-14 13:43:00.149 477-16532/? I/FFMPEG: Stream #0:2(und): Data: none (mebx / 0x7862656D), 1 kb/s (default)
03-14 13:43:00.149 477-16532/? I/FFMPEG: Metadata:
03-14 13:43:00.149 477-16532/? I/FFMPEG: creation_time : 2016-03-13 19:24:58
03-14 13:43:00.149 477-16532/? I/FFMPEG: handler_name : Core Media Data Handler
03-14 13:43:00.149 477-16532/? I/FFMPEG: Stream #0:3(und): Data: none (mebx / 0x7862656D), 0 kb/s (default)
03-14 13:43:00.149 477-16532/? I/FFMPEG: Metadata:
03-14 13:43:00.149 477-16532/? I/FFMPEG: creation_time : 2016-03-13 19:24:58
03-14 13:43:00.149 477-16532/? I/FFMPEG: handler_name : Core Media Data Handler
03-14 13:43:00.149 477-16532/? I/FFmpegExtractor: FFmpegExtrator, url: android-source:0xafcff040, format_name: mov,mp4,m4a,3gp,3g2,mj2, format_long_name: QuickTime / MOV
03-14 13:43:00.149 477-16532/? I/FFmpegExtractor: list the formats suppoted by ffmpeg:
03-14 13:43:00.149 477-16532/? I/FFmpegExtractor: ========================================
03-14 13:43:00.149 477-16532/? V/FFmpegExtractor: format_names[00]: mpeg
03-14 13:43:00.149 477-16532/? V/FFmpegExtractor: format_names[01]: mpegts
03-14 13:43:00.149 477-16532/? V/FFmpegExtractor: format_names[02]: mov,mp4,m4a,3gp,3g2,mj2
03-14 13:43:00.149 477-16532/? V/FFmpegExtractor: format_names[03]: matroska,webm
03-14 13:43:00.149 477-16532/? V/FFmpegExtractor: format_names[04]: asf
03-14 13:43:00.149 477-16532/? V/FFmpegExtractor: format_names[05]: rm
03-14 13:43:00.149 477-16532/? V/FFmpegExtractor: format_names[06]: flv
03-14 13:43:00.149 477-16532/? V/FFmpegExtractor: format_names[07]: swf
03-14 13:43:00.149 477-16532/? V/FFmpegExtractor: format_names[08]: avi
03-14 13:43:00.149 477-16532/? V/FFmpegExtractor: format_names[09]: ape
03-14 13:43:00.149 477-16532/? V/FFmpegExtractor: format_names[10]: dts
03-14 13:43:00.149 477-16532/? V/FFmpegExtractor: format_names[11]: flac
03-14 13:43:00.149 477-16532/? V/FFmpegExtractor: format_names[12]: ac3
03-14 13:43:00.149 477-16532/? V/FFmpegExtractor: format_names[13]: wav
03-14 13:43:00.149 477-16532/? V/FFmpegExtractor: format_names[14]: ogg
03-14 13:43:00.149 477-16532/? V/FFmpegExtractor: format_names[15]: vc1
03-14 13:43:00.149 477-16532/? V/FFmpegExtractor: format_names[16]: hevc
03-14 13:43:00.149 477-16532/? I/FFmpegExtractor: ========================================
03-14 13:43:00.149 477-16532/? V/FFmpegExtractor: major_brand tag is:qt
03-14 13:43:00.149 477-16532/? I/FFmpegExtractor: [mp4]format is mov, confidence should be larger than mpeg4
03-14 13:43:00.149 477-16532/? D/FFMPEG: android source close
03-14 13:43:00.149 477-16532/? I/FFmpegExtractor: sniff through BetterSniffFFMPEG success
03-14 13:43:00.149 477-16532/? D/FFmpegExtractor: ffmpeg detected media content as 'video/mp4' with confidence 0.41
03-14 13:43:00.149 477-16532/? I/MediaExtractor: Use extended extractor for the special mime(video/mp4) or codec
03-14 13:43:00.149 477-16532/? V/FFmpegExtractor: FFmpegExtractor::FFmpegExtractor
03-14 13:43:00.149 477-16532/? V/FFmpegExtractor: mFilename: android-source:0xafcff040
03-14 13:43:00.150 477-16532/? D/FFMPEG: android source begin open
03-14 13:43:00.150 477-16532/? D/FFMPEG: android open, url: android-source:0xafcff040
03-14 13:43:00.150 477-16532/? D/FFMPEG: ffmpeg open android data source success, source ptr: 0xafcff040
03-14 13:43:00.150 477-16532/? D/FFMPEG: android source open success
03-14 13:43:00.230 477-16532/? V/FFmpegExtractor: file startTime: 0
03-14 13:43:00.230 477-16532/? I/FFmpegExtractor: the duration is 00:00:10.87
03-14 13:43:00.230 477-16532/? I/FFmpegExtractor: stream_index: 0
03-14 13:43:00.230 477-16532/? I/FFmpegExtractor: support the codec(aac)
03-14 13:43:00.230 477-16532/? V/FFmpegExtractor: Tag mp4a/0x6134706d with codec(aac)
03-14 13:43:00.230 477-16532/? V/FFmpegExtractor: audio stream extradata(2):
03-14 13:43:00.230 477-16532/? V/codec_utils: AAC
03-14 13:43:00.230 477-16532/? V/codec_utils: aac profile: 1, sf_index: 4, channel: 1
03-14 13:43:00.230 477-16532/? I/FFmpegExtractor: bit_rate: 86249, sample_rate: 44100, channels: 1, bits_per_coded_sample: 16, block_align:0
03-14 13:43:00.230 477-16532/? I/FFmpegExtractor: the time is 00:00:10.93
03-14 13:43:00.230 477-16532/? V/FFmpegExtractor: audio startTime:0
03-14 13:43:00.230 477-16532/? V/FFmpegExtractor: create a audio track
03-14 13:43:00.230 477-16532/? I/FFmpegExtractor: stream_index: 1
03-14 13:43:00.230 477-16532/? I/FFmpegExtractor: support the codec(h264)
03-14 13:43:00.230 477-16532/? V/FFmpegExtractor: Tag avc1/0x31637661 with codec(h264)
03-14 13:43:00.230 477-16532/? V/FFmpegExtractor: video stream extradata:
03-14 13:43:00.230 477-16532/? V/codec_utils: AVC
03-14 13:43:00.230 477-16532/? I/FFmpegExtractor: width: 1920, height: 1080, bit_rate: 11113682
03-14 13:43:00.230 477-16532/? I/FFmpegExtractor: the time is 00:00:10.87
03-14 13:43:00.230 477-16532/? V/FFmpegExtractor: video startTime:0
03-14 13:43:00.230 477-16532/? V/FFmpegExtractor: create a video track
03-14 13:43:00.230 477-16532/? V/FFmpegExtractor: the stream is AVC, the length of a NAL unit: 4
03-14 13:43:00.230 477-16532/? V/FFmpegExtractor: Starting reader thread
03-14 13:43:00.230 477-16532/? D/FFmpegExtractor: Reader thread started
03-14 13:43:00.231 477-16532/? V/FFmpegExtractor: mProbePkts: 0, mEOF: 0, pb->error(if has): 0, mDefersToCreateVideoTrack: 0, mDefersToCreateAudioTrack: 0
03-14 13:43:00.231 477-16532/? D/FFmpegExtractor: supported mime: video/mp4
03-14 13:43:00.231 477-16532/? V/FFmpegExtractor: FFmpegExtractor::getMetaData
03-14 13:43:00.231 477-16537/? V/FFmpegExtractor: FFmpegExtractor enter thread(readerEntry)
03-14 13:43:00.231 477-16532/? V/FFmpegExtractor: FFmpegExtractor::getTrack[0]
03-14 13:43:00.231 477-16532/? V/FFmpegExtractor: FFmpegExtractor::getTrackMetaData[0]
03-14 13:43:00.231 477-16532/? V/FFmpegExtractor: FFmpegExtractor::getTrack[1]
03-14 13:43:00.231 477-16532/? V/FFmpegExtractor: FFmpegExtractor::getTrackMetaData[1]
03-14 13:43:00.232 10973-10973/com.hobbyte.touringandroid E/MediaPlayer: Should have subtitle controller already setUpon trying to play the video file, I get this log :
03-14 13:52:06.133 743-821/system_process W/AudioTrack: AUDIO_OUTPUT_FLAG_FAST denied by client
03-14 13:52:06.133 477-477/? D/NuPlayerDriver: start(0xb0f05040)
03-14 13:52:06.133 477-16531/? I/GenericSource: start
03-14 13:52:06.133 477-16531/? V/FFmpegExtractor: FFmpegExtractor::Track::start audio
03-14 13:52:06.133 477-16531/? V/FFmpegExtractor: FFmpegExtractor::Track::start video
03-14 13:52:06.133 477-16532/? V/FFmpegExtractor: read audio flush pkt
03-14 13:52:06.133 477-16532/? V/FFmpegExtractor: read video flush pkt
03-14 13:52:06.139 477-24743/? D/SoftFFmpegAudio: SoftFFmpegAudio component: OMX.ffmpeg.aac.decoder mMode: 1
03-14 13:52:06.141 477-24743/? V/SoftFFmpegAudio: get pcm params, nChannels:4294967295, nSamplingRate:4294967295
03-14 13:52:06.141 477-24743/? V/SoftFFmpegAudio: set OMX_IndexParamAudioPcm, nChannels:1, nSampleRate:44100, nBitsPerSample:16
03-14 13:52:06.141 477-24743/? V/SoftFFmpegAudio: set OMX_IndexParamAudioAac, nChannels:1, nSampleRate:44100
03-14 13:52:06.141 477-24743/? E/OMXNodeInstance: setParameter(1866465283) ERROR: 0x8000101a
03-14 13:52:06.141 477-24743/? V/SoftFFmpegAudio: get pcm params, nChannels:1, nSamplingRate:44100
03-14 13:52:06.147 477-24744/? E/OMXNodeInstance: OMX_GetExtensionIndex OMX.google.android.index.storeMetaDataInBuffers failed
03-14 13:52:06.147 477-24744/? E/ACodec: [OMX.google.h264.decoder] storeMetaDataInBuffers failed w/ err -2147483648
03-14 13:52:06.149 477-24745/? I/SoftFFmpegAudio: got extradata, ignore: 0, size: 2
03-14 13:52:06.150 477-24745/? I/SoftFFmpegAudio: extradata is ready, size: 2
03-14 13:52:06.150 477-24745/? D/SoftFFmpegAudio: begin to open ffmpeg audio decoder(aac), mCtx sample_rate: 44100, channels: 1, , sample_fmt: (null)
03-14 13:52:06.154 477-24745/? D/SoftFFmpegAudio: open ffmpeg audio decoder(aac) success, mCtx sample_rate: 44100, channels: 1, sample_fmt: fltp
03-14 13:52:06.154 477-24745/? I/SoftFFmpegAudio: Create sample rate converter for conversion of 44100 Hz fltp 1 channels(mono) to 44100 Hz s16 1 channels(mono)!
03-14 13:52:06.154 477-24743/? V/SoftFFmpegAudio: get pcm params, nChannels:1, nSamplingRate:44100
03-14 13:52:06.155 477-24739/? D/AudioSink: bufferCount (8) is too small and increased to 12
03-14 13:52:06.162 477-24747/? E/SoftAVC: Decoder failed: -2
03-14 13:52:06.162 477-24744/? E/ACodec: [OMX.google.h264.decoder] ERROR(0x80001001)
03-14 13:52:06.162 477-24744/? E/ACodec: signalError(omxError 0x80001001, internalError -2147483648)
03-14 13:52:06.163 477-24741/? E/MediaCodec: Codec reported err 0x80001001, actionCode 0, while in state 6
03-14 13:52:06.167 477-24740/? E/NuPlayerDecoder: Failed to queue input buffer for OMX.google.h264.decoder (err=-38)
03-14 13:52:06.167 477-16531/? E/NuPlayer: received error(0xffffffda) from video decoder, flushing(0), now shutting down
03-14 13:52:06.168 10973-11040/com.hobbyte.touringandroid E/MediaPlayer: error (1, -38)
03-14 13:52:06.168 10973-10973/com.hobbyte.touringandroid E/MediaPlayer: Error (1,-38)
03-14 13:52:06.168 477-24740/? E/NuPlayerDecoder: failed to flush OMX.google.h264.decoder (err=-38)
03-14 13:52:06.168 477-16531/? E/NuPlayer: received error(0xffffffda) from video decoder, flushing(2), now shutting down
03-14 13:52:06.169 10973-10989/com.hobbyte.touringandroid E/MediaPlayer: error (1, -38)
03-14 13:52:06.170 10973-10973/com.hobbyte.touringandroid E/MediaPlayer: Error (1,-38)For reference, here is my class file :
package com.hobbyte.touringandroid.ui.adapter;
import android.content.Context;
import android.graphics.SurfaceTexture;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.util.DisplayMetrics;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.Surface;
import android.view.TextureView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.SeekBar;
import android.widget.TextView;
import com.google.android.exoplayer.ExoPlayer;
import com.google.android.exoplayer.FrameworkSampleSource;
import com.google.android.exoplayer.MediaCodecVideoTrackRenderer;
import com.google.android.exoplayer.SampleSource;
import com.google.android.exoplayer.TrackRenderer;
import com.hobbyte.touringandroid.App;
import com.hobbyte.touringandroid.tourdata.ListViewItem;
import com.hobbyte.touringandroid.internet.LoadImageFromURL;
import com.hobbyte.touringandroid.R;
import java.io.File;
import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* @author Nikita
*/
public class PoiContentAdapter extends ArrayAdapter<listviewitem> {
private static final String TAG = "PoiContentAdapter";
public static final int HEADER = 0;
public static final int BODY = 1;
public static final int IMAGE = 2;
public static final int VIDEO = 3;
private static Pattern namePattern;
private static final String FILE_NAME_PATTERN = "https?:\\/\\/[-\\w\\.\\/]*\\/(.+\\.(jpe?g|png|mp4))";
private ListViewItem[] items;
private String keyID;
private TextureView textureView;
private MediaPlayer player;
private AudioManager audio;
private ImageButton play;
private ImageButton replay;
private ImageButton mute;
private ImageButton max;
private SeekBar volume;
private String filePath;
@Override
public int getViewTypeCount() {
return 4;
}
@Override
public int getItemViewType(int position) {
return items[position].getType();
}
public PoiContentAdapter(Context context, ListViewItem[] content, String keyID) {
super(context, 0, content);
this.keyID = keyID;
items = content;
namePattern = Pattern.compile(FILE_NAME_PATTERN);
}
/**
* Inflates a certain view depending on the type of ListViewItem (Normal text or Image URL)
* @param position Position of item in the ItemList
* @param view View
* @param parent ParentView
* @return the view in question
*/
@Override
public View getView(int position, View view, ViewGroup parent) {
ListViewItem listViewItem = items[position];
int listViewItemType = getItemViewType(position);
String filename = null;
TextView contentView;
if (listViewItem.getUrl() != null) {
Matcher m = namePattern.matcher(listViewItem.getUrl());
if (m.matches()) {
filename = m.group(1);
}
}
if (view == null) {
if (listViewItemType == IMAGE) {
view = LayoutInflater.from(getContext()).inflate(R.layout.poi_image, parent, false);
} else if(listViewItemType == VIDEO) {
view = LayoutInflater.from(getContext()).inflate(R.layout.poi_video, parent, false);
} else {
view = LayoutInflater.from(getContext()).inflate(R.layout.poi_content, parent, false);
}
}
switch (listViewItemType) {
case IMAGE:
ImageView imageView = (ImageView) view.findViewById(R.id.poiContentImageView);
TextView textView = (TextView) view.findViewById(R.id.poiContentImageDesc);
textView.setText(listViewItem.getText());
if (filename != null) {
new LoadImageFromURL(imageView, App.context).execute(filename, keyID); //Load image in a separate thread
}
return view;
case VIDEO:
filePath = getContext().getFilesDir() + "/" + String.format("%s/video/%s", keyID, filename);
File file = new File(filePath);
if(!file.exists()) {
view = LayoutInflater.from(getContext()).inflate(R.layout.poi_content, parent, false);
contentView = (TextView) view.findViewById(R.id.poiContentTextView);
contentView.setText("This contains a video." + "\n" + "Download this tour with Media to see this Video!" + "\n");
contentView.setGravity(Gravity.CENTER_HORIZONTAL);
} else {
System.out.println(filePath);
textureView = (TextureView) view.findViewById(R.id.poiContentVideoView);
DisplayMetrics metrics = App.context.getResources().getDisplayMetrics();
int height = metrics.heightPixels / 2;
int width = metrics.widthPixels;
textureView.setMinimumHeight(height);
textureView.setMinimumWidth(width);
play = (ImageButton) view.findViewById(R.id.playButton);
replay = (ImageButton) view.findViewById(R.id.replayButtoon);
mute = (ImageButton) view.findViewById(R.id.muteButton);
max = (ImageButton) view.findViewById(R.id.maxVolButton);
volume = (SeekBar) view.findViewById(R.id.volumeControl);
audio = (AudioManager) App.context.getSystemService(Context.AUDIO_SERVICE);
textureView.setSurfaceTextureListener(videoListener);
TextView videoDesc = (TextView) view.findViewById(R.id.poiContentVideoDesc);
videoDesc.setText(listViewItem.getText());
}
return view;
case HEADER:
// TODO
if(view.findViewById(R.id.poiContentTextView) == null) {
view = LayoutInflater.from(getContext()).inflate(R.layout.poi_content, parent, false);
}
contentView = (TextView) view.findViewById(R.id.poiContentTextView);
contentView.setText(listViewItem.getText() + "\n");
if(listViewItem.getText().length() == 0) {
return new View(getContext());
}
return view;
case BODY:
// TODO
contentView = (TextView) view.findViewById(R.id.poiContentTextView);
contentView.setText(listViewItem.getText() + "\n");
return view;
default:
contentView = (TextView) view.findViewById(R.id.poiContentTextView);
contentView.setText("Something went wrong\n");
return view;
}
}
private TextureView.SurfaceTextureListener videoListener = new TextureView.SurfaceTextureListener() {
@Override
public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
Surface s = new Surface(surface);
try {
player = new MediaPlayer();
player.setDataSource(filePath);
player.setSurface(s);
player.prepareAsync();
player.setAudioStreamType(AudioManager.STREAM_MUSIC);
player.setVideoScalingMode(MediaPlayer.VIDEO_SCALING_MODE_SCALE_TO_FIT);
player.setOnBufferingUpdateListener(new MediaPlayer.OnBufferingUpdateListener() {
@Override
public void onBufferingUpdate(MediaPlayer mp, int percent) {
//Do nothing
}
});
player.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
//Do nothing
}
});
player.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(final MediaPlayer mp) {
play.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(mp.isPlaying()) {
mp.pause();
play.setImageResource(R.mipmap.ic_play_arrow_white_36dp);
} else {
mp.start();
play.setImageResource(R.mipmap.ic_pause_white_36dp);
}
}
});
replay.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(mp.isPlaying()) {
play.setImageResource(R.mipmap.ic_play_arrow_white_36dp);
mp.pause();
mp.seekTo(0);
} else {
play.setImageResource(R.mipmap.ic_play_arrow_white_36dp);
mp.seekTo(0);
}
}
});
mute.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mp.setVolume(0.0f, 0.0f);
volume.setProgress(0);
}
});
max.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mp.setVolume(1.0f, 1.0f);
volume.setProgress(audio.getStreamMaxVolume(AudioManager.STREAM_MUSIC));
}
});
int maxVolume = audio.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
int currVolume = audio.getStreamVolume(AudioManager.STREAM_MUSIC);
volume.setMax(maxVolume);
volume.setProgress(currVolume);
volume.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
audio.setStreamVolume(AudioManager.STREAM_MUSIC, progress, 0);
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
}
});
player.setOnVideoSizeChangedListener(new MediaPlayer.OnVideoSizeChangedListener() {
@Override
public void onVideoSizeChanged(MediaPlayer mp, int width, int height) {
//Do nothing
}
});
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@Override
public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) {
}
@Override
public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
if (player != null) {
player.stop();
player.release();
player = null;
}
return true;
}
@Override
public void onSurfaceTextureUpdated(SurfaceTexture surface) {
}
};
}
</listviewitem>I really do not understand in the slightest what is causing all these errors, and why the video file won’t play ?
If anyone is able to help I will highly highly appreciate it !I am using Genymotion Emulator - Google Nexus 4 - API 21
Thank you very much !