
Recherche avancée
Médias (1)
-
Bug de détection d’ogg
22 mars 2013, par
Mis à jour : Avril 2013
Langue : français
Type : Video
Autres articles (111)
-
Publier sur MédiaSpip
13 juin 2013Puis-je poster des contenus à partir d’une tablette Ipad ?
Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir -
Emballe médias : à quoi cela sert ?
4 février 2011, parCe plugin vise à gérer des sites de mise en ligne de documents de tous types.
Il crée des "médias", à savoir : un "média" est un article au sens SPIP créé automatiquement lors du téléversement d’un document qu’il soit audio, vidéo, image ou textuel ; un seul document ne peut être lié à un article dit "média" ; -
Script d’installation automatique de MediaSPIP
25 avril 2011, parAfin de palier aux difficultés d’installation dues principalement aux dépendances logicielles coté serveur, un script d’installation "tout en un" en bash a été créé afin de faciliter cette étape sur un serveur doté d’une distribution Linux compatible.
Vous devez bénéficier d’un accès SSH à votre serveur et d’un compte "root" afin de l’utiliser, ce qui permettra d’installer les dépendances. Contactez votre hébergeur si vous ne disposez pas de cela.
La documentation de l’utilisation du script d’installation (...)
Sur d’autres sites (7203)
-
Issue when streaming some TV channels threw ffMpeg
7 octobre 2016, par Raphael SerievicI am trying to stream a TV Tuner feed with ffMpeg through udp.
The ffMpeg command line I use is the following :
ffmpeg.exe -i udp://@239.255.255.9:1234 -map 0:p:1317:0 -profile:v baseline -crf 30 -preset ultrafast -vcodec libx264 -r 25 -vf scale=720:576-b:v 500k -f rtp udp://10.150.112.107:15048/ -map 0:p:1317:1 -acodec pcm_mulaw -strict experimental -ar 8k -ac 1 -b:a 128k -f rtp udp://10.150.112.107:15032/
Where :
- 1317 is the program id (channel)
- 10.150.112.107 is where I want to stream the TV channel
- 239.255.255.9 is where I receive the original TV channel’s feed from my TV Tuner
My problem is that with some program IDs it is working and with some others it is not : it is working with 1572 ("channel 10 hd") but not with 1317 ("7flix Sydney").
The output of this command-line for channel 1572 (where it works) is the following :
C:\Program Files (x86)\Tuner Manager\ServerModule> ffmpeg.exe
-i udp://@239.255.255.7:1234 -map 0:p:1572:0 -profile:v baseline -crf 30 -prese
t ultrafast -vcodec libx264 -r 25 -vf scale=720:576 - b:v 500k -f rtp udp://1
0.150.112.107:15048/ -map 0:p:1572:1 -acodec pcm_mulaw -strict experimental -ar
8k -ac 1 -b:a 128k -f rtp udp://10.150.112.107:15032/
ffmpeg version N-71924-ga2190de Copyright (c) 2000-2015 the FFmpeg developers
built with gcc 4.9.2 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-av
isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab
le-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --
enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-l
ibilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enab
le-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --en
able-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --ena
ble-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc
--enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enabl
e-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --ena
ble-decklink --enable-zlib
libavutil 54. 23.101 / 54. 23.101
libavcodec 56. 37.100 / 56. 37.100
libavformat 56. 31.102 / 56. 31.102
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 16.101 / 5. 16.101
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 1.100 / 1. 1.100
libpostproc 53. 3.100 / 53. 3.100
[NULL @ 00000000049ce980] non-existing SPS 0 referenced in buffering period
[h264 @ 00000000049ce980] non-existing PPS 0 referenced
[h264 @ 00000000049ce980] decode_slice_header error
[h264 @ 00000000049ce980] no frame!
[h264 @ 00000000049ce980] non-existing SPS 0 referenced in buffering period
[h264 @ 00000000049ce980] non-existing PPS 0 referenced
[h264 @ 00000000049ce980] decode_slice_header error
[h264 @ 00000000049ce980] no frame!
[mpeg2video @ 000000000497e3e0] Invalid frame dimensions 0x0.
[mpeg2video @ 0000000004967c80] Invalid frame dimensions 0x0.
[h264 @ 00000000049ce980] non-existing SPS 0 referenced in buffering period
[h264 @ 00000000049ce980] non-existing PPS 0 referenced
[h264 @ 00000000049ce980] decode_slice_header error
[h264 @ 00000000049ce980] no frame!
[h264 @ 00000000049ce980] non-existing SPS 0 referenced in buffering period
[h264 @ 00000000049ce980] non-existing PPS 0 referenced
[h264 @ 00000000049ce980] decode_slice_header error
[h264 @ 00000000049ce980] no frame!
[mpeg2video @ 000000000497e3e0] Invalid frame dimensions 0x0.
[mpeg2video @ 0000000004967c80] Invalid frame dimensions 0x0.
[h264 @ 00000000049ce980] non-existing SPS 0 referenced in buffering period
[h264 @ 00000000049ce980] non-existing PPS 0 referenced
[h264 @ 00000000049ce980] decode_slice_header error
[h264 @ 00000000049ce980] no frame!
[mpeg2video @ 00000000049cc980] Invalid frame dimensions 0x0.
[mpeg2video @ 00000000049cdbc0] Invalid frame dimensions 0x0.
[h264 @ 00000000049ce980] non-existing SPS 0 referenced in buffering period
[h264 @ 00000000049ce980] non-existing PPS 0 referenced
[h264 @ 00000000049ce980] decode_slice_header error
[h264 @ 00000000049ce980] no frame!
[mpeg2video @ 0000000004967c80] Invalid frame dimensions 0x0.
Last message repeated 1 times
[mpeg2video @ 0000000004967c80] Invalid frame dimensions 0x0.
[mpeg2video @ 00000000049cc980] Invalid frame dimensions 0x0.
[h264 @ 00000000049ce980] non-existing SPS 0 referenced in buffering period
[h264 @ 00000000049ce980] non-existing PPS 0 referenced
[h264 @ 00000000049ce980] decode_slice_header error
[h264 @ 00000000049ce980] no frame!
[mpeg2video @ 0000000004967c80] Invalid frame dimensions 0x0.
[h264 @ 00000000049ce980] non-existing SPS 0 referenced in buffering period
[h264 @ 00000000049ce980] non-existing PPS 0 referenced
[h264 @ 00000000049ce980] decode_slice_header error
[h264 @ 00000000049ce980] no frame!
[mpeg2video @ 000000000497e3e0] Invalid frame dimensions 0x0.
[mpeg2video @ 00000000049cc980] Invalid frame dimensions 0x0.
[h264 @ 00000000049ce980] non-existing SPS 0 referenced in buffering period
[h264 @ 00000000049ce980] non-existing PPS 0 referenced
[h264 @ 00000000049ce980] decode_slice_header error
[h264 @ 00000000049ce980] no frame!
[mpeg2video @ 000000000497e3e0] Invalid frame dimensions 0x0.
[mpeg2video @ 0000000004967c80] Invalid frame dimensions 0x0.
[h264 @ 00000000049ce980] non-existing SPS 0 referenced in buffering period
[h264 @ 00000000049ce980] non-existing PPS 0 referenced
[h264 @ 00000000049ce980] decode_slice_header error
[h264 @ 00000000049ce980] no frame!
[mpeg2video @ 00000000049cc980] Invalid frame dimensions 0x0.
[h264 @ 00000000049ce980] non-existing SPS 0 referenced in buffering period
[h264 @ 00000000049ce980] non-existing PPS 0 referenced
[h264 @ 00000000049ce980] decode_slice_header error
[h264 @ 00000000049ce980] no frame!
[mpeg2video @ 000000000497e3e0] Invalid frame dimensions 0x0.
[h264 @ 00000000049ce980] non-existing SPS 0 referenced in buffering period
[h264 @ 00000000049ce980] non-existing PPS 0 referenced
[h264 @ 00000000049ce980] non-existing SPS 0 referenced in buffering period
[h264 @ 00000000049ce980] non-existing PPS 0 referenced
[h264 @ 00000000049ce980] decode_slice_header error
[h264 @ 00000000049ce980] no frame!
[mpeg2video @ 0000000004975b40] Invalid frame dimensions 0x0.
[h264 @ 00000000049ce980] non-existing SPS 0 referenced in buffering period
[h264 @ 00000000049ce980] non-existing PPS 0 referenced
[h264 @ 00000000049ce980] decode_slice_header error
[h264 @ 00000000049ce980] no frame!
[mpeg2video @ 000000000497e3e0] Invalid frame dimensions 0x0.
[h264 @ 00000000049ce980] non-existing SPS 0 referenced in buffering period
[h264 @ 00000000049ce980] non-existing PPS 0 referenced
[h264 @ 00000000049ce980] decode_slice_header error
[h264 @ 00000000049ce980] no frame!
[mpeg2video @ 00000000049cdbc0] Invalid frame dimensions 0x0.
[h264 @ 00000000049ce980] non-existing SPS 0 referenced in buffering period
[h264 @ 00000000049ce980] non-existing PPS 0 referenced
[h264 @ 00000000049ce980] decode_slice_header error
[h264 @ 00000000049ce980] no frame!
[mpeg2video @ 0000000004967c80] Invalid frame dimensions 0x0.
[h264 @ 00000000049ce980] non-existing SPS 0 referenced in buffering period
[h264 @ 00000000049ce980] non-existing PPS 0 referenced
[h264 @ 00000000049ce980] decode_slice_header error
[h264 @ 00000000049ce980] no frame!
[mpeg2video @ 000000000497e3e0] Invalid frame dimensions 0x0.
[h264 @ 00000000049ce980] non-existing SPS 0 referenced in buffering period
[h264 @ 00000000049ce980] non-existing PPS 0 referenced
[h264 @ 00000000049ce980] decode_slice_header error
[h264 @ 00000000049ce980] no frame!
[mpeg2video @ 0000000004975b40] Invalid frame dimensions 0x0.
[mpeg2video @ 0000000004967c80] Invalid frame dimensions 0x0.
[h264 @ 00000000049ce980] non-existing SPS 0 referenced in buffering period
[h264 @ 00000000049ce980] non-existing PPS 0 referenced
[h264 @ 00000000049ce980] decode_slice_header error
[h264 @ 00000000049ce980] no frame!
[mpeg2video @ 000000000497e3e0] Invalid frame dimensions 0x0.
[h264 @ 00000000049ce980] non-existing SPS 0 referenced in buffering period
[h264 @ 00000000049ce980] non-existing PPS 0 referenced
[h264 @ 00000000049ce980] decode_slice_header error
[h264 @ 00000000049ce980] no frame!
[h264 @ 00000000049ce980] decode_slice_header error
[h264 @ 00000000049ce980] no frame!
[mpeg2video @ 0000000004975b40] Invalid frame dimensions 0x0.
[mpeg2video @ 000000000497e3e0] Invalid frame dimensions 0x0.
[h264 @ 00000000049ce980] non-existing SPS 0 referenced in buffering period
[h264 @ 00000000049ce980] non-existing PPS 0 referenced
[h264 @ 00000000049ce980] decode_slice_header error
[h264 @ 00000000049ce980] no frame!
[mpeg2video @ 0000000004967c80] Invalid frame dimensions 0x0.
[h264 @ 00000000049ce980] non-existing SPS 0 referenced in buffering period
[h264 @ 00000000049ce980] non-existing PPS 0 referenced
[h264 @ 00000000049ce980] decode_slice_header error
[h264 @ 00000000049ce980] no frame!
[mpeg2video @ 0000000004975b40] Invalid frame dimensions 0x0.
Last message repeated 1 times
[mpeg2video @ 0000000004975b40] Invalid frame dimensions 0x0.
[mpeg2video @ 00000000049cdbc0] Invalid frame dimensions 0x0.
Last message repeated 1 times
[mpeg2video @ 0000000004967c80] Invalid frame dimensions 0x0.
[mpeg2video @ 0000000004975b40] Invalid frame dimensions 0x0.
[h264 @ 00000000049ce980] non-existing SPS 0 referenced in buffering period
[h264 @ 00000000049ce980] non-existing PPS 0 referenced
[h264 @ 00000000049ce980] decode_slice_header error
[h264 @ 00000000049ce980] no frame!
[mpeg2video @ 00000000049cdbc0] Invalid frame dimensions 0x0.
Last message repeated 2 times
[mpeg2video @ 00000000049cdbc0] Invalid frame dimensions 0x0.
[mpeg2video @ 0000000004975b40] Invalid frame dimensions 0x0.
Last message repeated 3 times
[mpeg2video @ 000000000497e3e0] Invalid frame dimensions 0x0.
[mpeg2video @ 0000000004975b40] Invalid frame dimensions 0x0.
Last message repeated 3 times
[mpegts @ 000000000494d6c0] Could not find codec parameters for stream 2 (Unknow
n: none ([11][0][0][0] / 0x000B)): unknown codec
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[mpegts @ 000000000494d6c0] Could not find codec parameters for stream 3 (Unknow
n: none ([5][0][0][0] / 0x0005)): unknown codec
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[mpegts @ 000000000494d6c0] Could not find codec parameters for stream 4 (Unknow
n: none ([11][0][0][0] / 0x000B)): unknown codec
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[mpegts @ 000000000494d6c0] Could not find codec parameters for stream 5 (Unknow
n: none ([12][0][0][0] / 0x000C)): unknown codec
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[mpegts @ 000000000494d6c0] Could not find codec parameters for stream 8 (Unknow
n: none ([5][0][0][0] / 0x0005)): unknown codec
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[mpegts @ 000000000494d6c0] Could not find codec parameters for stream 9 (Unknow
n: none ([11][0][0][0] / 0x000B)): unknown codec
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[mpegts @ 000000000494d6c0] Could not find codec parameters for stream 10 (Unkno
wn: none ([12][0][0][0] / 0x000C)): unknown codec
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[mpegts @ 000000000494d6c0] Could not find codec parameters for stream 14 (Unkno
wn: none ([5][0][0][0] / 0x0005)): unknown codec
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[mpegts @ 000000000494d6c0] Could not find codec parameters for stream 15 (Unkno
wn: none ([11][0][0][0] / 0x000B)): unknown codec
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[mpegts @ 000000000494d6c0] Could not find codec parameters for stream 16 (Unkno
wn: none ([12][0][0][0] / 0x000C)): unknown codec
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[mpegts @ 000000000494d6c0] Could not find codec parameters for stream 25 (Unkno
wn: none ([5][0][0][0] / 0x0005)): unknown codec
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[mpegts @ 000000000494d6c0] Could not find codec parameters for stream 26 (Unkno
wn: none ([11][0][0][0] / 0x000B)): unknown codec
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[mpegts @ 000000000494d6c0] Could not find codec parameters for stream 27 (Unkno
wn: none ([12][0][0][0] / 0x000C)): unknown codec
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[mpegts @ 000000000494d6c0] Could not find codec parameters for stream 29 (Unkno
wn: none ([5][0][0][0] / 0x0005)): unknown codec
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[mpegts @ 000000000494d6c0] Could not find codec parameters for stream 30 (Unkno
wn: none ([11][0][0][0] / 0x000B)): unknown codec
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[mpegts @ 000000000494d6c0] Could not find codec parameters for stream 31 (Unkno
wn: none ([12][0][0][0] / 0x000C)): unknown codec
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Input #0, mpegts, from 'udp://@239.255.255.7:1234':
Duration: N/A, start: 64984.698511, bitrate: N/A
Program 1569
Metadata:
service_name : ONE
service_provider: TEN Sydney
Stream #0:2[0x1fd2]: Unknown: none ([11][0][0][0] / 0x000B)
Stream #0:25[0x3e8]: Unknown: none ([5][0][0][0] / 0x0005)
Stream #0:26[0x3f2]: Unknown: none ([11][0][0][0] / 0x000B)
Stream #0:27[0x3fc]: Unknown: none ([12][0][0][0] / 0x000C)
Stream #0:23[0x202]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv42
0p(tv), 720x576 [SAR 64:45 DAR 16:9], max. 15000 kb/s, 25 fps, 25 tbr, 90k tbn,
50 tbc
Stream #0:24[0x2a0](eng): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, ster
eo, s16p, 192 kb/s
Stream #0:7[0x241](eng): Subtitle: dvb_teletext ([6][0][0][0] / 0x0006)
Program 1573
Metadata:
service_name : TEN Digital
service_provider: TEN Sydney
Stream #0:2[0x1fd2]: Unknown: none ([11][0][0][0] / 0x000B)
Stream #0:14[0x3ea]: Unknown: none ([5][0][0][0] / 0x0005)
Stream #0:15[0x3f4]: Unknown: none ([11][0][0][0] / 0x000B)
Stream #0:16[0x3fe]: Unknown: none ([12][0][0][0] / 0x000C)
Stream #0:17[0x200]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv42
0p(tv), 720x576 [SAR 64:45 DAR 16:9], max. 15000 kb/s, 25 fps, 25 tbr, 90k tbn,
50 tbc
Stream #0:18[0x28a](eng): Audio: mp2 ([4][0][0][0] / 0x0004), 48000 Hz, ster
eo, s16p, 256 kb/s
Stream #0:19[0x240](eng): Subtitle: dvb_teletext ([6][0][0][0] / 0x0006)
Program 1574
Metadata:
service_name : TVSN
service_provider: TEN Sydney
Stream #0:6[0x206]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420
p(tv), 720x576 [SAR 64:45 DAR 16:9], max. 15000 kb/s, 25 fps, 25 tbr, 90k tbn, 5
0 tbc
Stream #0:28[0x2b2](eng): Audio: mp2 ([4][0][0][0] / 0x0004), 48000 Hz, ster
eo, s16p, 192 kb/s
Stream #0:2[0x1fd2]: Unknown: none ([11][0][0][0] / 0x000B)
Stream #0:29[0x3eb]: Unknown: none ([5][0][0][0] / 0x0005)
Stream #0:30[0x3f5]: Unknown: none ([11][0][0][0] / 0x000B)
Stream #0:31[0x3ff]: Unknown: none ([12][0][0][0] / 0x000C)
Program 1575
Metadata:
service_name : ONE
service_provider: TEN Sydney
Stream #0:23[0x202]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv42
0p(tv), 720x576 [SAR 64:45 DAR 16:9], max. 15000 kb/s, 25 fps, 25 tbr, 90k tbn,
50 tbc
Stream #0:24[0x2a0](eng): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, ster
eo, s16p, 192 kb/s
Stream #0:7[0x241](eng): Subtitle: dvb_teletext ([6][0][0][0] / 0x0006)
Stream #0:2[0x1fd2]: Unknown: none ([11][0][0][0] / 0x000B)
Stream #0:25[0x3e8]: Unknown: none ([5][0][0][0] / 0x0005)
Stream #0:26[0x3f2]: Unknown: none ([11][0][0][0] / 0x000B)
Stream #0:27[0x3fc]: Unknown: none ([12][0][0][0] / 0x000C)
Program 1576
Metadata:
service_name : ELEVEN
service_provider: TEN Sydney
Stream #0:2[0x1fd2]: Unknown: none ([11][0][0][0] / 0x000B)
Stream #0:8[0x3e9]: Unknown: none ([5][0][0][0] / 0x0005)
Stream #0:9[0x3f3]: Unknown: none ([11][0][0][0] / 0x000B)
Stream #0:10[0x3fd]: Unknown: none ([12][0][0][0] / 0x000C)
Stream #0:11[0x204]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv42
0p(tv), 720x576 [SAR 64:45 DAR 16:9], max. 15000 kb/s, 25 fps, 25 tbr, 90k tbn,
50 tbc
Stream #0:12[0x2a9](eng): Audio: mp2 ([4][0][0][0] / 0x0004), 48000 Hz, ster
eo, s16p, 192 kb/s
Stream #0:13[0x242](eng): Subtitle: dvb_teletext ([6][0][0][0] / 0x0006)
Program 1577
Metadata:
service_name : SpreeTV
service_provider: TEN Sydney
Stream #0:0[0x208]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420
p(tv), 720x576 [SAR 64:45 DAR 16:9], max. 15000 kb/s, 25 fps, 25 tbr, 90k tbn, 5
0 tbc
Stream #0:1[0x2bc](eng): Audio: mp2 ([4][0][0][0] / 0x0004), 48000 Hz, stere
o, s16p, 192 kb/s
Stream #0:2[0x1fd2]: Unknown: none ([11][0][0][0] / 0x000B)
Stream #0:3[0x3ec]: Unknown: none ([5][0][0][0] / 0x0005)
Stream #0:4[0x3f6]: Unknown: none ([11][0][0][0] / 0x000B)
Stream #0:5[0x400]: Unknown: none ([12][0][0][0] / 0x000C)
Program 1572
Metadata:
service_name : TEN HD
service_provider: TEN Sydney
Stream #0:20[0x1ff]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(tv
, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 25 fps, 50 tbr, 90k tbn, 50 tbc
Stream #0:21[0x289](eng): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, 5.1(side
), fltp, 448 kb/s
Stream #0:22[0x23f](eng): Subtitle: dvb_teletext ([6][0][0][0] / 0x0006)
Stream #0:2[0x1fd2]: Unknown: none ([11][0][0][0] / 0x000B)
Stream #0:14[0x3ea]: Unknown: none ([5][0][0][0] / 0x0005)
Stream #0:15[0x3f4]: Unknown: none ([11][0][0][0] / 0x000B)
Stream #0:16[0x3fe]: Unknown: none ([12][0][0][0] / 0x000C)
[NULL @ 0000000005af6de0] Unable to find a suitable output format for 'pipe:'
pipe:: Invalid argumentThe output of this command-line for channel 1317 (where it does not works) is the following :
Microsoft Windows [Version 6.2.9200]
(c) 2012 Microsoft Corporation. All rights reserved.
C:\Users\Administrator.TMC>"C:\Program Files (x86)\Tv Tuner Mana
ger\ServerModule\ffmpeg.exe" -i udp://@239.255.255.9:1234 -map 0:p:1317:0 -profi
le:v baseline -crf 30 -preset ultrafast -vcodec libx264 -r 25 -vf scale=720:576
-b:v 500k -f rtp udp://10.150.112.107:15048/ -map 0:p:1317:1 -acodec pcm_mulaw -
strict experimental -ar 8k -ac 1 -b:a 128k -f rtp udp://10.150.112.107:15032/
ffmpeg version N-71924-ga2190de Copyright (c) 2000-2015 the FFmpeg developers
built with gcc 4.9.2 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-av
isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab
le-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --
enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-l
ibilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enab
le-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --en
able-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --ena
ble-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc
--enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enabl
e-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --ena
ble-decklink --enable-zlib
libavutil 54. 23.101 / 54. 23.101
libavcodec 56. 37.100 / 56. 37.100
libavformat 56. 31.102 / 56. 31.102
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 16.101 / 5. 16.101
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 1.100 / 1. 1.100
libpostproc 53. 3.100 / 53. 3.100
[mpeg2video @ 000000000473a8a0] Invalid frame dimensions 0x0.
[NULL @ 0000000004789600] non-existing PPS 0 referenced
[h264 @ 0000000004789600] decode_slice_header error
[h264 @ 0000000004789600] no frame!
[mpeg2video @ 000000000472dac0] Invalid frame dimensions 0x0.
[NULL @ 000000000472a060] non-existing PPS 0 referenced
[h264 @ 000000000472a060] decode_slice_header error
[h264 @ 000000000472a060] no frame!
[mpeg2video @ 000000000473a8a0] Invalid frame dimensions 0x0.
[h264 @ 000000000472a060] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 000000000472a060] decode_slice_header error
[h264 @ 000000000472a060] no frame!
[h264 @ 000000000472a060] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 000000000472a060] decode_slice_header error
[h264 @ 000000000472a060] no frame!
[mpeg2video @ 000000000472dac0] Invalid frame dimensions 0x0.
[mpeg2video @ 00000000047c9200] Invalid frame dimensions 0x0.
Last message repeated 1 times
[mpeg2video @ 000000000472c620] Invalid frame dimensions 0x0.
[h264 @ 0000000004789600] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0000000004789600] decode_slice_header error
[h264 @ 0000000004789600] no frame!
[mpeg2video @ 00000000047c9200] Invalid frame dimensions 0x0.
[mpeg2video @ 000000000472dac0] Invalid frame dimensions 0x0.
[h264 @ 000000000472a060] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 000000000472a060] decode_slice_header error
[h264 @ 000000000472a060] no frame!
[mpeg2video @ 00000000047c9200] Invalid frame dimensions 0x0.
[mpeg2video @ 000000000473a8a0] Invalid frame dimensions 0x0.
Last message repeated 1 times
[mpeg2video @ 000000000472dac0] Invalid frame dimensions 0x0.
[mpeg2video @ 00000000047c9200] Invalid frame dimensions 0x0.
Last message repeated 1 times
[mpeg2video @ 00000000047c9200] Invalid frame dimensions 0x0.
[mpeg2video @ 000000000473a8a0] Invalid frame dimensions 0x0.
Last message repeated 1 times
[mpeg2video @ 000000000472c620] Invalid frame dimensions 0x0.
[mpeg2video @ 000000000473a8a0] Invalid frame dimensions 0x0.
Last message repeated 1 times
[mpeg2video @ 000000000472dac0] Invalid frame dimensions 0x0.
[mpeg2video @ 000000000473a8a0] Invalid frame dimensions 0x0.
Last message repeated 2 times
[mpeg2video @ 00000000047c9200] Invalid frame dimensions 0x0.
[mpeg2video @ 000000000473a8a0] Invalid frame dimensions 0x0.
[mpegts @ 0000000004710020] Could not find codec parameters for stream 3 (Unknow
n: none ([5][0][0][0] / 0x0005)): unknown codec
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[mpegts @ 0000000004710020] Could not find codec parameters for stream 4 (Unknow
n: none ([11][0][0][0] / 0x000B)): unknown codec
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Input #0, mpegts, from 'udp://@239.255.255.9:1234':
Duration: N/A, start: 77183.898689, bitrate: N/A
Program 1312
Metadata:
service_name : 7 Sydney
service_provider: Seven Network
Stream #0:0[0x201]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420
p(tv), 720x576 [SAR 64:45 DAR 16:9], max. 14950 kb/s, 25 fps, 25 tbr, 90k tbn, 5
0 tbc
Stream #0:1[0x202](eng): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stere
o, s16p, 256 kb/s
Stream #0:2[0x204](eng): Subtitle: dvb_teletext ([6][0][0][0] / 0x0006)
Stream #0:3[0x206]: Unknown: none ([5][0][0][0] / 0x0005)
Stream #0:4[0x299]: Unknown: none ([11][0][0][0] / 0x000B)
Program 1313
Metadata:
service_name : 7 Sydney
service_provider: Seven Network
Stream #0:0[0x201]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420
p(tv), 720x576 [SAR 64:45 DAR 16:9], max. 14950 kb/s, 25 fps, 25 tbr, 90k tbn, 5
0 tbc
Stream #0:1[0x202](eng): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stere
o, s16p, 256 kb/s
Stream #0:2[0x204](eng): Subtitle: dvb_teletext ([6][0][0][0] / 0x0006)
Stream #0:3[0x206]: Unknown: none ([5][0][0][0] / 0x0005)
Stream #0:4[0x299]: Unknown: none ([11][0][0][0] / 0x000B)
Program 1314
Metadata:
service_name : 7TWO Sydney
service_provider: Seven Network
Stream #0:3[0x206]: Unknown: none ([5][0][0][0] / 0x0005)
Stream #0:18[0x221]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv42
0p(tv), 720x576 [SAR 64:45 DAR 16:9], max. 14950 kb/s, 25 fps, 25 tbr, 90k tbn,
50 tbc
Stream #0:10[0x222](eng): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, ster
eo, s16p, 192 kb/s
Stream #0:5[0x224](eng): Subtitle: dvb_teletext ([6][0][0][0] / 0x0006)
Stream #0:4[0x299]: Unknown: none ([11][0][0][0] / 0x000B)
Program 1315
Metadata:
service_name : 7mate Sydney
service_provider: Seven Network
Stream #0:3[0x206]: Unknown: none ([5][0][0][0] / 0x0005)
Stream #0:13[0x231]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv42
0p(tv), 720x576 [SAR 64:45 DAR 16:9], max. 14950 kb/s, 25 fps, 25 tbr, 90k tbn,
50 tbc
Stream #0:15[0x232](eng): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, ster
eo, s16p, 256 kb/s
Stream #0:12[0x234](eng): Subtitle: dvb_teletext ([6][0][0][0] / 0x0006)
Stream #0:4[0x299]: Unknown: none ([11][0][0][0] / 0x000B)
Program 1316
Metadata:
service_name : 7HD Sydney
service_provider: Seven Network
Stream #0:3[0x206]: Unknown: none ([5][0][0][0] / 0x0005)
Stream #0:6[0x241]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p, 19
20x1080 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 90k tbn, 50 tbc
Stream #0:16[0x243](eng): Audio: ac3 ([6][0][0][0] / 0x0006), 48000 Hz, ster
eo, fltp, 384 kb/s
Stream #0:8[0x244](eng): Subtitle: dvb_teletext ([6][0][0][0] / 0x0006)
Stream #0:4[0x299]: Unknown: none ([11][0][0][0] / 0x000B)
Program 1317
Metadata:
service_name : 7flix Sydney
service_provider: Seven Network
Stream #0:3[0x206]: Unknown: none ([5][0][0][0] / 0x0005)
Stream #0:11[0x251]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv42
0p(tv), 720x576 [SAR 64:45 DAR 16:9], max. 12500 kb/s, 25 fps, 25 tbr, 90k tbn,
50 tbc
Stream #0:9[0x253](eng): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stere
o, s16p, 128 kb/s
Stream #0:14[0x254](eng): Subtitle: dvb_teletext ([6][0][0][0] / 0x0006)
Stream #0:4[0x299]: Unknown: none ([11][0][0][0] / 0x000B)
Program 1320
Metadata:
service_name : RACING.COM
service_provider: Seven Network
Stream #0:7[0x281]: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p, 64
0x576 [SAR 8:5 DAR 16:9], 25 fps, 25 tbr, 90k tbn, 50 tbc
Stream #0:17[0x282](eng): Audio: aac_latm (HE-AACv2) ([17][0][0][0] / 0x0011
), 48000 Hz, stereo, fltp
Stream #0:4[0x299]: Unknown: none ([11][0][0][0] / 0x000B)
Cannot map stream #0:3 - unsupported type.Thanks for your help
-
Android recording video with overlay view [way 2]
2 mars 2016, par t0mI am trying app in android which have functionality to capture video with overlay views. I tried two ways (1. and 2.).
1. Via SurfaceView and JavaCV with FFmpeg.
2. Via OpenCV and JavaCV with FFmpeg.
3. For API21+ maybe with MediaProjection.(Question is divided to two questions, due to stackoverflow length limit.)
ad 1. Via SurfaceView and JavaCV with FFmpeg :
ad 2. Via OpenCV and JavaCV with FFmpeg :
OpenCVCameraActivity.java :
import android.app.Activity;
import android.hardware.Camera;
import android.media.AudioFormat;
import android.media.AudioRecord;
import android.media.MediaRecorder;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.SubMenu;
import android.view.SurfaceView;
import android.view.View;
import android.view.WindowManager;
import android.widget.Toast;
import org.bytedeco.javacv.FFmpegFrameRecorder;
import org.bytedeco.javacv.Frame;
import org.opencv.android.BaseLoaderCallback;
import org.opencv.android.CameraBridgeViewBase;
import org.opencv.android.LoaderCallbackInterface;
import org.opencv.android.OpenCVLoader;
import org.opencv.core.Mat;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ShortBuffer;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.ListIterator;
@SuppressWarnings("ALL")
public class OpenCVCameraActivity extends Activity implements
CameraBridgeViewBase.CvCameraViewListener2,
View.OnTouchListener {
//name of activity, for DEBUGGING
private static final String TAG = OpenCVCameraActivity.class.getSimpleName();
private OpenCVCameraPreview mOpenCvCameraView;
private List mResolutionList;
private MenuItem[] mEffectMenuItems;
private SubMenu mColorEffectsMenu;
private MenuItem[] mResolutionMenuItems;
private SubMenu mResolutionMenu;
private static long frameCounter = 0;
long startTime = 0;
private Mat edgesMat;
boolean recording = false;
private int sampleAudioRateInHz = 44100;
private int imageWidth = 1280;
private int imageHeight = 720;
private int frameRate = 30;
private Frame yuvImage = null;
private File ffmpeg_link;
private FFmpegFrameRecorder recorder;
/*audio data getting thread */
private AudioRecord audioRecord;
private AudioRecordRunnable audioRecordRunnable;
private Thread audioThread;
volatile boolean runAudioThread = true;
ShortBuffer[] samples;
private BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(this) {
@Override
public void onManagerConnected(int status) {
switch (status) {
case LoaderCallbackInterface.SUCCESS:
Log.i(TAG, "OpenCV loaded successfully");
mOpenCvCameraView.enableView();
mOpenCvCameraView.setOnTouchListener(OpenCVCameraActivity.this);
break;
default:
super.onManagerConnected(status);
break;
}
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if(Static.DEBUG) Log.i(TAG, "onCreate()");
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
Thread.setDefaultUncaughtExceptionHandler(uncaughtExceptionHandler);
try {
setContentView(R.layout.activity_opencv);
mOpenCvCameraView = (OpenCVCameraPreview) findViewById(R.id.openCVCameraPreview);
mOpenCvCameraView.setVisibility(SurfaceView.VISIBLE);
mOpenCvCameraView.setCvCameraViewListener(this);
mOpenCvCameraView.enableFpsMeter();
ffmpeg_link = new File(Environment.getExternalStorageDirectory(), "stream.mp4");
} catch (Exception e){
e.printStackTrace();
}
}
private Thread.UncaughtExceptionHandler uncaughtExceptionHandler =
new Thread.UncaughtExceptionHandler() {
public void uncaughtException(Thread thread, Throwable ex) {
if(Static.DEBUG) Log.e(TAG, "Uncaught exception", ex);
}
};
@Override
protected void onRestart() {
if (Static.DEBUG) Log.i(TAG, "onRestart()");
super.onRestart();
}
@Override
protected void onStart() {
if (Static.DEBUG) Log.i(TAG, "onStart()");
super.onStart();
}
@Override
protected void onResume() {
if (Static.DEBUG) Log.i(TAG, "onResume()");
super.onResume();
if (!OpenCVLoader.initDebug()) {
Log.i(TAG, "Internal OpenCV library not found. Using OpenCV Manager for initialization");
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_3_1_0, this, mLoaderCallback);
} else {
Log.i(TAG, "OpenCV library found inside package. Using it!");
mLoaderCallback.onManagerConnected(LoaderCallbackInterface.SUCCESS);
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
if (Static.DEBUG) Log.i(TAG, "onCreateOptionsMenu()");
super.onCreateOptionsMenu(menu);
List<string> effects = mOpenCvCameraView.getEffectList();
if (effects == null) {
Log.e(TAG, "Color effects are not supported by device!");
return true;
}
mColorEffectsMenu = menu.addSubMenu("Color Effect");
mEffectMenuItems = new MenuItem[effects.size()];
int idx = 0;
ListIterator<string> effectItr = effects.listIterator();
while(effectItr.hasNext()) {
String element = effectItr.next();
mEffectMenuItems[idx] = mColorEffectsMenu.add(1, idx, Menu.NONE, element);
idx++;
}
mResolutionMenu = menu.addSubMenu("Resolution");
mResolutionList = mOpenCvCameraView.getResolutionList();
mResolutionMenuItems = new MenuItem[mResolutionList.size()];
ListIterator resolutionItr = mResolutionList.listIterator();
idx = 0;
while(resolutionItr.hasNext()) {
Camera.Size element = resolutionItr.next();
mResolutionMenuItems[idx] = mResolutionMenu.add(2, idx, Menu.NONE,
Integer.valueOf(element.width).toString() + "x" + Integer.valueOf(element.height).toString());
idx++;
}
return true;
}
@Override
protected void onPause() {
if (Static.DEBUG) Log.i(TAG, "onPause()");
super.onPause();
if (mOpenCvCameraView != null)
mOpenCvCameraView.disableView();
}
@Override
protected void onStop() {
if (Static.DEBUG) Log.i(TAG, "onStop()");
super.onStop();
}
@Override
protected void onDestroy() {
if (Static.DEBUG) Log.i(TAG, "onDestroy()");
super.onDestroy();
if (mOpenCvCameraView != null)
mOpenCvCameraView.disableView();
}
public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame) {
++frameCounter;
//Log.i(TAG, "Frame number: "+frameCounter);
final Mat rgba = inputFrame.rgba();
//Core.flip(rgba, rgba, 1);
/*if(Static.DEBUG) Log.i(TAG,"rgba.total(): "+rgba.total());
if(Static.DEBUG) Log.i(TAG,"rgba.channels(): " +rgba.channels());*/
byte[] data = new byte[(int) (rgba.total() * rgba.channels())];
rgba.get(0, 0, data);
//if(Static.DEBUG) Log.i(TAG,"return_buff: "+return_buff.length);
if (audioRecord == null || audioRecord.getRecordingState() != AudioRecord.RECORDSTATE_RECORDING) {
startTime = System.currentTimeMillis();
return rgba;
}
// get video data
if (yuvImage != null && recording) {
ByteBuffer b = (ByteBuffer)yuvImage.image[0].position(0);
b.put(data);
try {
long t = 1000 * (System.currentTimeMillis() - startTime);
if(Static.DEBUG) Log.i(TAG,"Writing Frame on timestamp: "+t);
if (t > recorder.getTimestamp()) {
recorder.setTimestamp(t);
}
recorder.record(yuvImage);
} catch (FFmpegFrameRecorder.Exception e) {
if(Static.DEBUG) Log.i(TAG,e.getMessage());
e.printStackTrace();
}
}
return rgba;
}
@Override
public void onCameraViewStarted(int width, int height) {
edgesMat = new Mat();
}
@Override
public void onCameraViewStopped() {
if (edgesMat != null)
edgesMat.release();
edgesMat = null;
}
public boolean onOptionsItemSelected(MenuItem item) {
Log.i(TAG, "called onOptionsItemSelected; selected item: " + item);
if (item.getGroupId() == 1)
{
mOpenCvCameraView.setEffect((String) item.getTitle());
Toast.makeText(this, mOpenCvCameraView.getEffect(), Toast.LENGTH_SHORT).show();
} else if (item.getGroupId() == 2) {
int id = item.getItemId();
Camera.Size resolution = mResolutionList.get(id);
mOpenCvCameraView.setResolution(resolution);
resolution = mOpenCvCameraView.getResolution();
String caption = Integer.valueOf(resolution.width).toString() + "x" + Integer.valueOf(resolution.height).toString();
Toast.makeText(this, caption, Toast.LENGTH_SHORT).show();
}
return true;
}
@Override
public boolean onTouch(View v, MotionEvent event) {
Log.i(TAG,"onTouch event");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss");
String currentDateandTime = sdf.format(new Date());
String fileName = Environment.getExternalStorageDirectory().getPath() +
"/sample_picture_" + currentDateandTime + ".jpg";
mOpenCvCameraView.takePicture(fileName);
Toast.makeText(this, fileName + " saved", Toast.LENGTH_SHORT).show();
return false;
}
/**
* Click to ImageButton to start recording.
*/
public void onClickBtnStartRecord2(View v) {
if (Static.DEBUG) Log.i(TAG, "onClickBtnStartRecord()");
if(!recording)
startRecording();
else
stopRecording();
}
private void startRecording() {
if (Static.DEBUG) Log.i(TAG, "startRecording()");
initRecorder();
try {
recorder.start();
startTime = System.currentTimeMillis();
recording = true;
audioThread.start();
if (Static.DEBUG) Log.i(TAG, "startRecording() success");
} catch(FFmpegFrameRecorder.Exception e) {
e.printStackTrace();
}
}
private void stopRecording() {
if (Static.DEBUG) Log.i(TAG, "stopRecording()");
runAudioThread = false;
try {
audioThread.join();
} catch(InterruptedException e) {
e.printStackTrace();
}
audioRecordRunnable = null;
audioThread = null;
if (Static.DEBUG) Log.i(TAG, "stopRecording() 2");
if(recorder != null && recording) {
recording = false;
try {
recorder.stop();
recorder.release();
Log.i(TAG, "Finishing recording, calling stop and release on recorder");
} catch(FFmpegFrameRecorder.Exception e) {
e.printStackTrace();
}
recorder = null;
}
}
//---------------------------------------
// initialize ffmpeg_recorder
//---------------------------------------
private void initRecorder() {
Log.i(TAG, "init recorder");
try {
if (yuvImage == null) {
yuvImage = new Frame(imageWidth, imageHeight, Frame.DEPTH_UBYTE, 4);
Log.i(TAG, "create yuvImage");
}
Log.i(TAG, "ffmpeg_url: " + ffmpeg_link.getAbsolutePath());
//Log.i(TAG, "ffmpeg_url: " + ffmpeg_link.exists());
recorder = new FFmpegFrameRecorder(ffmpeg_link, imageWidth, imageHeight, 1);
recorder.setFormat("mp4");
recorder.setSampleRate(sampleAudioRateInHz);
// Set in the surface changed method
recorder.setFrameRate(frameRate);
audioRecordRunnable = new AudioRecordRunnable();
audioThread = new Thread(audioRecordRunnable);
runAudioThread = true;
Log.i(TAG, "recorder initialize success");
} catch (Exception e){
e.printStackTrace();
}
}
//---------------------------------------------
// audio thread, gets and encodes audio data
//---------------------------------------------
class AudioRecordRunnable implements Runnable {
@Override
public void run() {
android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_URGENT_AUDIO);
// Audio
int bufferSize;
ShortBuffer audioData;
int bufferReadResult;
bufferSize = AudioRecord.getMinBufferSize(sampleAudioRateInHz,
AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT);
audioRecord = new AudioRecord(MediaRecorder.AudioSource.MIC, sampleAudioRateInHz,
AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT, bufferSize);
audioData = ShortBuffer.allocate(bufferSize);
Log.d(TAG, "audioRecord.startRecording()");
audioRecord.startRecording();
// ffmpeg_audio encoding loop
while(runAudioThread) {
//Log.v(TAG,"recording? " + recording);
bufferReadResult = audioRecord.read(audioData.array(), 0, audioData.capacity());
audioData.limit(bufferReadResult);
if(bufferReadResult > 0) {
Log.v(TAG, "bufferReadResult: " + bufferReadResult);
// If "recording" isn't true when start this thread, it never get's set according to this if statement...!!!
// Why? Good question...
if(recording) {
try {
recorder.recordSamples(audioData);
//Log.v(TAG,"recording " + 1024*i + " to " + 1024*i+1024);
} catch(FFmpegFrameRecorder.Exception e) {
Log.v(TAG, e.getMessage());
e.printStackTrace();
}
}
}
}
Log.v(TAG, "AudioThread Finished, release audioRecord");
// encoding finish, release recorder
if(audioRecord != null) {
audioRecord.stop();
audioRecord.release();
audioRecord = null;
Log.v(TAG, "audioRecord released");
}
}
}
}
</string></string>OpenCVCameraPreview.java :
import android.content.Context;
import android.hardware.Camera;
import android.util.AttributeSet;
import android.util.Log;
import org.opencv.android.JavaCameraView;
import java.io.FileOutputStream;
import java.util.List;
public class OpenCVCameraPreview extends JavaCameraView implements Camera.PictureCallback {
private static final String TAG = OpenCVCameraPreview.class.getSimpleName();
private String mPictureFileName;
public OpenCVCameraPreview(Context context, AttributeSet attrs) {
super(context, attrs);
}
public List<string> getEffectList() {
return mCamera.getParameters().getSupportedColorEffects();
}
public boolean isEffectSupported() {
return (mCamera.getParameters().getColorEffect() != null);
}
public String getEffect() {
return mCamera.getParameters().getColorEffect();
}
public void setEffect(String effect) {
Camera.Parameters params = mCamera.getParameters();
params.setColorEffect(effect);
mCamera.setParameters(params);
}
public List getResolutionList() {
return mCamera.getParameters().getSupportedPreviewSizes();
}
public void setResolution(Camera.Size resolution) {
disconnectCamera();
mMaxHeight = resolution.height;
mMaxWidth = resolution.width;
connectCamera(getWidth(), getHeight());
}
public Camera.Size getResolution() {
return mCamera.getParameters().getPreviewSize();
}
public void takePicture(final String fileName) {
Log.i(TAG, "Taking picture");
this.mPictureFileName = fileName;
// Postview and jpeg are sent in the same buffers if the queue is not empty when performing a capture.
// Clear up buffers to avoid mCamera.takePicture to be stuck because of a memory issue
mCamera.setPreviewCallback(null);
// PictureCallback is implemented by the current class
mCamera.takePicture(null, null, this);
}
@Override
public void onPictureTaken(byte[] data, Camera camera) {
Log.i(TAG, "Saving a bitmap to file");
// The camera preview was automatically stopped. Start it again.
mCamera.startPreview();
mCamera.setPreviewCallback(this);
// Write the image in a file (in jpeg format)
try {
FileOutputStream fos = new FileOutputStream(mPictureFileName);
fos.write(data);
fos.close();
} catch (java.io.IOException e) {
Log.e("PictureDemo", "Exception in photoCallback", e);
}
}
}
</string>activity_opencv.xml :
<?xml version="1.0" encoding="utf-8"?>
<relativelayout>
<ImageButton<br />
android:id="@+id/btnStartRecord2"<br />
android:layout_width="70dp"<br />
android:layout_height="70dp"<br />
android:scaleType="fitXY"<br />
android:src="@drawable/record_icon"<br />
android:background="@null"<br />
android:text="@string/btnStartRecord"<br />
android:onClick="onClickBtnStartRecord2"<br />
android:layout_centerVertical="true"<br />
android:layout_alignParentRight="true"<br />
android:layout_alignParentEnd="true"/>
</relativelayout>Overlay views working, but recorded video is without overlay views, and recording with
onCameraFrame
method is very slow. -
Android studio + OpenCV + FFmpeg
26 février 2016, par t0mI have problem with code, which is functional only for Genymotion device (Android 4.1.1), but for Genymotion device 5.0.1 and real device Huawei honor 4c Android 4.4.2 not.
I have imported OpenCV 3.1 to Android studio by : http://stackoverflow.com/a/27421494/4244605
I added JavaCV with FFmpeg by : https://github.com/bytedeco/javacvAndroid studio 1.5.1
minSdkVersion 15
compileSdkVersion 23Code is only for test.
OpenCVCameraActivity.java :package co.timeiseverything.pstimeiseverything;
import android.app.Activity;
import android.hardware.Camera;
import android.media.AudioFormat;
import android.media.AudioRecord;
import android.media.MediaRecorder;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.SubMenu;
import android.view.SurfaceView;
import android.view.View;
import android.view.WindowManager;
import android.widget.Toast;
import org.bytedeco.javacv.FFmpegFrameRecorder;
import org.bytedeco.javacv.Frame;
import org.opencv.android.BaseLoaderCallback;
import org.opencv.android.CameraBridgeViewBase;
import org.opencv.android.LoaderCallbackInterface;
import org.opencv.android.OpenCVLoader;
import org.opencv.core.Mat;
import java.io.File;
import java.nio.ShortBuffer;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.ListIterator;
@SuppressWarnings("ALL")
public class OpenCVCameraActivity extends Activity implements
CameraBridgeViewBase.CvCameraViewListener2,
View.OnTouchListener {
//name of activity, for DEBUGGING
private static final String TAG = OpenCVCameraActivity.class.getSimpleName();
private OpenCVCameraPreview mOpenCvCameraView;
private List mResolutionList;
private MenuItem[] mEffectMenuItems;
private SubMenu mColorEffectsMenu;
private MenuItem[] mResolutionMenuItems;
private SubMenu mResolutionMenu;
private static long frameCounter = 0;
long startTime = 0;
private Mat edgesMat;
boolean recording = false;
private int sampleAudioRateInHz = 44100;
private int imageWidth = 1920;
private int imageHeight = 1080;
private int frameRate = 30;
private Frame yuvImage = null;
private File ffmpeg_link;
private FFmpegFrameRecorder recorder;
/* audio data getting thread */
private AudioRecord audioRecord;
private AudioRecordRunnable audioRecordRunnable;
private Thread audioThread;
volatile boolean runAudioThread = true;
ShortBuffer[] samples;
private BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(this) {
@Override
public void onManagerConnected(int status) {
switch (status) {
case LoaderCallbackInterface.SUCCESS:
Log.i(TAG, "OpenCV loaded successfully");
mOpenCvCameraView.enableView();
mOpenCvCameraView.setOnTouchListener(OpenCVCameraActivity.this);
break;
default:
super.onManagerConnected(status);
break;
}
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if(Static.DEBUG) Log.i(TAG, "onCreate()");
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
try {
setContentView(R.layout.activity_opencv);
mOpenCvCameraView = (OpenCVCameraPreview) findViewById(R.id.openCVCameraPreview);
mOpenCvCameraView.setVisibility(SurfaceView.VISIBLE);
mOpenCvCameraView.setCvCameraViewListener(this);
//mOpenCvCameraView.enableFpsMeter();
ffmpeg_link = new File(Environment.getExternalStorageDirectory(), "stream.mp4");
} catch (Exception e){
e.printStackTrace();
}
}
@Override
protected void onRestart() {
if (Static.DEBUG) Log.i(TAG, "onRestart()");
super.onRestart();
}
@Override
protected void onStart() {
if (Static.DEBUG) Log.i(TAG, "onStart()");
super.onStart();
}
@Override
protected void onResume() {
if (Static.DEBUG) Log.i(TAG, "onResume()");
super.onResume();
if (!OpenCVLoader.initDebug()) {
Log.i(TAG, "Internal OpenCV library not found. Using OpenCV Manager for initialization");
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_11, this, mLoaderCallback);
} else {
Log.i(TAG, "OpenCV library found inside package. Using it!");
mLoaderCallback.onManagerConnected(LoaderCallbackInterface.SUCCESS);
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
if (Static.DEBUG) Log.i(TAG, "onCreateOptionsMenu()");
super.onCreateOptionsMenu(menu);
List<string> effects = mOpenCvCameraView.getEffectList();
if (effects == null) {
Log.e(TAG, "Color effects are not supported by device!");
return true;
}
mColorEffectsMenu = menu.addSubMenu("Color Effect");
mEffectMenuItems = new MenuItem[effects.size()];
int idx = 0;
ListIterator<string> effectItr = effects.listIterator();
while(effectItr.hasNext()) {
String element = effectItr.next();
mEffectMenuItems[idx] = mColorEffectsMenu.add(1, idx, Menu.NONE, element);
idx++;
}
mResolutionMenu = menu.addSubMenu("Resolution");
mResolutionList = mOpenCvCameraView.getResolutionList();
mResolutionMenuItems = new MenuItem[mResolutionList.size()];
ListIterator resolutionItr = mResolutionList.listIterator();
idx = 0;
while(resolutionItr.hasNext()) {
Camera.Size element = resolutionItr.next();
mResolutionMenuItems[idx] = mResolutionMenu.add(2, idx, Menu.NONE,
Integer.valueOf(element.width).toString() + "x" + Integer.valueOf(element.height).toString());
idx++;
}
return true;
}
@Override
protected void onPause() {
if (Static.DEBUG) Log.i(TAG, "onPause()");
super.onPause();
if (mOpenCvCameraView != null)
mOpenCvCameraView.disableView();
}
@Override
protected void onStop() {
if (Static.DEBUG) Log.i(TAG, "onStop()");
super.onStop();
}
@Override
protected void onDestroy() {
if (Static.DEBUG) Log.i(TAG, "onDestroy()");
super.onDestroy();
if (mOpenCvCameraView != null)
mOpenCvCameraView.disableView();
}
public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame) {
++frameCounter;
//Log.i(TAG, "Frame number: "+frameCounter);
return inputFrame.rgba();
}
@Override
public void onCameraViewStarted(int width, int height) {
edgesMat = new Mat();
}
@Override
public void onCameraViewStopped() {
if (edgesMat != null)
edgesMat.release();
edgesMat = null;
}
public boolean onOptionsItemSelected(MenuItem item) {
Log.i(TAG, "called onOptionsItemSelected; selected item: " + item);
if (item.getGroupId() == 1)
{
mOpenCvCameraView.setEffect((String) item.getTitle());
Toast.makeText(this, mOpenCvCameraView.getEffect(), Toast.LENGTH_SHORT).show();
} else if (item.getGroupId() == 2) {
int id = item.getItemId();
Camera.Size resolution = mResolutionList.get(id);
mOpenCvCameraView.setResolution(resolution);
resolution = mOpenCvCameraView.getResolution();
String caption = Integer.valueOf(resolution.width).toString() + "x" + Integer.valueOf(resolution.height).toString();
Toast.makeText(this, caption, Toast.LENGTH_SHORT).show();
}
return true;
}
@Override
public boolean onTouch(View v, MotionEvent event) {
Log.i(TAG,"onTouch event");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss");
String currentDateandTime = sdf.format(new Date());
String fileName = Environment.getExternalStorageDirectory().getPath() +
"/sample_picture_" + currentDateandTime + ".jpg";
mOpenCvCameraView.takePicture(fileName);
Toast.makeText(this, fileName + " saved", Toast.LENGTH_SHORT).show();
return false;
}
/**
* Click to ImageButton to start recording.
*/
public void onClickBtnStartRecord2(View v) {
if (Static.DEBUG) Log.i(TAG, "onClickBtnStartRecord()");
if(!recording)
startRecording();
else
stopRecording();
}
private void startRecording() {
if (Static.DEBUG) Log.i(TAG, "startRecording()");
initRecorder();
try {
recorder.start();
startTime = System.currentTimeMillis();
recording = true;
audioThread.start();
} catch(FFmpegFrameRecorder.Exception e) {
e.printStackTrace();
}
}
private void stopRecording() {
if (Static.DEBUG) Log.i(TAG, "stopRecording()");
runAudioThread = false;
try {
audioThread.join();
} catch(InterruptedException e) {
e.printStackTrace();
}
audioRecordRunnable = null;
audioThread = null;
if(recorder != null && recording) {
recording = false;
Log.v(TAG, "Finishing recording, calling stop and release on recorder");
try {
recorder.stop();
recorder.release();
} catch(FFmpegFrameRecorder.Exception e) {
e.printStackTrace();
}
recorder = null;
}
}
//---------------------------------------
// initialize ffmpeg_recorder
//---------------------------------------
private void initRecorder() {
Log.w(TAG, "init recorder");
try {
if (yuvImage == null) {
yuvImage = new Frame(imageWidth, imageHeight, Frame.DEPTH_UBYTE, 2);
Log.i(TAG, "create yuvImage");
}
Log.i(TAG, "ffmpeg_url: " + ffmpeg_link.getAbsolutePath());
Log.i(TAG, "ffmpeg_url: " + ffmpeg_link.exists());
recorder = new FFmpegFrameRecorder(ffmpeg_link, imageWidth, imageHeight, 1);
recorder.setFormat("mp4");
recorder.setSampleRate(sampleAudioRateInHz);
// Set in the surface changed method
recorder.setFrameRate(frameRate);
Log.i(TAG, "recorder initialize success");
audioRecordRunnable = new AudioRecordRunnable();
audioThread = new Thread(audioRecordRunnable);
runAudioThread = true;
} catch (Exception e){
e.printStackTrace();
}
}
//---------------------------------------------
// audio thread, gets and encodes audio data
//---------------------------------------------
class AudioRecordRunnable implements Runnable {
@Override
public void run() {
android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_URGENT_AUDIO);
// Audio
int bufferSize;
ShortBuffer audioData;
int bufferReadResult;
bufferSize = AudioRecord.getMinBufferSize(sampleAudioRateInHz,
AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT);
audioRecord = new AudioRecord(MediaRecorder.AudioSource.MIC, sampleAudioRateInHz,
AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT, bufferSize);
audioData = ShortBuffer.allocate(bufferSize);
Log.d(TAG, "audioRecord.startRecording()");
audioRecord.startRecording();
/* ffmpeg_audio encoding loop */
while(runAudioThread) {
//Log.v(TAG,"recording? " + recording);
bufferReadResult = audioRecord.read(audioData.array(), 0, audioData.capacity());
audioData.limit(bufferReadResult);
if(bufferReadResult > 0) {
Log.v(TAG, "bufferReadResult: " + bufferReadResult);
// If "recording" isn't true when start this thread, it never get's set according to this if statement...!!!
// Why? Good question...
if(recording) {
try {
recorder.recordSamples(audioData);
//Log.v(TAG,"recording " + 1024*i + " to " + 1024*i+1024);
} catch(FFmpegFrameRecorder.Exception e) {
Log.v(TAG, e.getMessage());
e.printStackTrace();
}
}
}
}
Log.v(TAG, "AudioThread Finished, release audioRecord");
/* encoding finish, release recorder */
if(audioRecord != null) {
audioRecord.stop();
audioRecord.release();
audioRecord = null;
Log.v(TAG, "audioRecord released");
}
}
}
}
</string></string>OpenCVCameraPreview.java :
package co.timeiseverything.pstimeiseverything;
import android.content.Context;
import android.hardware.Camera;
import android.util.AttributeSet;
import android.util.Log;
import org.opencv.android.JavaCameraView;
import java.io.FileOutputStream;
import java.util.List;
public class OpenCVCameraPreview extends JavaCameraView implements Camera.PictureCallback {
private static final String TAG = OpenCVCameraPreview.class.getSimpleName();
private String mPictureFileName;
public OpenCVCameraPreview(Context context, AttributeSet attrs) {
super(context, attrs);
}
public List<string> getEffectList() {
return mCamera.getParameters().getSupportedColorEffects();
}
public boolean isEffectSupported() {
return (mCamera.getParameters().getColorEffect() != null);
}
public String getEffect() {
return mCamera.getParameters().getColorEffect();
}
public void setEffect(String effect) {
Camera.Parameters params = mCamera.getParameters();
params.setColorEffect(effect);
mCamera.setParameters(params);
}
public List getResolutionList() {
return mCamera.getParameters().getSupportedPreviewSizes();
}
public void setResolution(Camera.Size resolution) {
disconnectCamera();
mMaxHeight = resolution.height;
mMaxWidth = resolution.width;
connectCamera(getWidth(), getHeight());
}
public Camera.Size getResolution() {
return mCamera.getParameters().getPreviewSize();
}
public void takePicture(final String fileName) {
Log.i(TAG, "Taking picture");
this.mPictureFileName = fileName;
// Postview and jpeg are sent in the same buffers if the queue is not empty when performing a capture.
// Clear up buffers to avoid mCamera.takePicture to be stuck because of a memory issue
mCamera.setPreviewCallback(null);
// PictureCallback is implemented by the current class
mCamera.takePicture(null, null, this);
}
@Override
public void onPictureTaken(byte[] data, Camera camera) {
Log.i(TAG, "Saving a bitmap to file");
// The camera preview was automatically stopped. Start it again.
mCamera.startPreview();
mCamera.setPreviewCallback(this);
// Write the image in a file (in jpeg format)
try {
FileOutputStream fos = new FileOutputStream(mPictureFileName);
fos.write(data);
fos.close();
} catch (java.io.IOException e) {
Log.e("PictureDemo", "Exception in photoCallback", e);
}
}
}
</string>Gradle :
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "co.timeiseverything.pstimeiseverything"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/maven/org.bytedeco.javacpp-presets/opencv/pom.properties'
exclude 'META-INF/maven/org.bytedeco.javacpp-presets/opencv/pom.xml'
exclude 'META-INF/maven/org.bytedeco.javacpp-presets/ffmpeg/pom.properties'
exclude 'META-INF/maven/org.bytedeco.javacpp-presets/ffmpeg/pom.xml'
}
}
repositories {
mavenCentral()
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.google.android.gms:play-services-appindexing:8.1.0'
compile group: 'org.bytedeco', name: 'javacv', version: '1.1'
compile group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '3.0.0-1.1', classifier: 'android-arm'
compile group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '3.0.0-1.1', classifier: 'android-x86'
compile group: 'org.bytedeco.javacpp-presets', name: 'ffmpeg', version: '2.8.1-1.1', classifier: 'android-arm'
compile group: 'org.bytedeco.javacpp-presets', name: 'ffmpeg', version: '2.8.1-1.1', classifier: 'android-x86'
compile project(':openCVLibrary310')
}proguard-rules.pro
Edited by : linkjniLibs :
app/src/main/jniLibs :armeabi armeabi-v7a arm64-v8a mips mips64 x86 x86_64
Problem
02-19 11:57:37.684 1759-1759/ I/OpenCVCameraActivity: onClickBtnStartRecord()
02-19 11:57:37.684 1759-1759/ I/OpenCVCameraActivity: startRecording()
02-19 11:57:37.684 1759-1759/ W/OpenCVCameraActivity: init recorder
02-19 11:57:37.691 1759-1759/ I/OpenCVCameraActivity: create yuvImage
02-19 11:57:37.691 1759-1759/ I/OpenCVCameraActivity: ffmpeg_url: /storage/emulated/0/stream.mp4
02-19 11:57:37.696 1759-1759/ I/OpenCVCameraActivity: ffmpeg_url: false
02-19 11:57:37.837 1759-1759/ W/linker: libjniavutil.so: unused DT entry: type 0x1d arg 0x18cc3
02-19 11:57:37.837 1759-1759/ W/linker: libjniavutil.so: unused DT entry: type 0x6ffffffe arg 0x21c30
02-19 11:57:37.837 1759-1759/ W/linker: libjniavutil.so: unused DT entry: type 0x6fffffff arg 0x1
02-19 11:57:37.838 1759-1759/co.timeiseverything.pstimeiseverything E/art: dlopen("/data/app/co.timeiseverything.pstimeiseverything-2/lib/x86/libjniavutil.so", RTLD_LAZY) failed: dlopen failed: cannot locate symbol "av_version_info" referenced by "libjniavutil.so"...
02-19 11:57:37.843 1759-1759/co.timeiseverything.pstimeiseverything I/art: Rejecting re-init on previously-failed class java.lang.Class
02-19 11:57:37.844 1759-1759/co.timeiseverything.pstimeiseverything E/AndroidRuntime: FATAL EXCEPTION: main
Process: co.timeiseverything.pstimeiseverything, PID: 1759
java.lang.IllegalStateException: Could not execute method of the activity
at android.view.View$1.onClick(View.java:4020)
at android.view.View.performClick(View.java:4780)
at android.view.View$PerformClick.run(View.java:19866)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at android.view.View$1.onClick(View.java:4015)
at android.view.View.performClick(View.java:4780)
at android.view.View$PerformClick.run(View.java:19866)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Caused by: java.lang.UnsatisfiedLinkError: org.bytedeco.javacpp.avutil
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:309)
at org.bytedeco.javacpp.Loader.load(Loader.java:413)
at org.bytedeco.javacpp.Loader.load(Loader.java:381)
at org.bytedeco.javacpp.avcodec$AVPacket.<clinit>(avcodec.java:1650)
at org.bytedeco.javacv.FFmpegFrameRecorder.<init>(FFmpegFrameRecorder.java:149)
at org.bytedeco.javacv.FFmpegFrameRecorder.<init>(FFmpegFrameRecorder.java:129)
at co.timeiseverything.pstimeiseverything.OpenCVCameraActivity.initRecorder(OpenCVCameraActivity.java:320)
at co.timeiseverything.pstimeiseverything.OpenCVCameraActivity.startRecording(OpenCVCameraActivity.java:266)
at co.timeiseverything.pstimeiseverything.OpenCVCameraActivity.onClickBtnStartRecord2(OpenCVCameraActivity.java:259)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at android.view.View$1.onClick(View.java:4015)
at android.view.View.performClick(View.java:4780)
at android.view.View$PerformClick.run(View.java:19866)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
</init></init></clinit>