
Recherche avancée
Médias (1)
-
GetID3 - Bloc informations de fichiers
9 avril 2013, par
Mis à jour : Mai 2013
Langue : français
Type : Image
Autres articles (78)
-
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 (...) -
XMP PHP
13 mai 2011, parDixit Wikipedia, XMP signifie :
Extensible Metadata Platform ou XMP est un format de métadonnées basé sur XML utilisé dans les applications PDF, de photographie et de graphisme. Il a été lancé par Adobe Systems en avril 2001 en étant intégré à la version 5.0 d’Adobe Acrobat.
Étant basé sur XML, il gère un ensemble de tags dynamiques pour l’utilisation dans le cadre du Web sémantique.
XMP permet d’enregistrer sous forme d’un document XML des informations relatives à un fichier : titre, auteur, historique (...)
Sur d’autres sites (8480)
-
avcodec_send_packet high memory usage
11 novembre 2023, par iexavSo for a while now I have been making something like a video player application. The video player receives a video stream, decodes it and displays its contents. I am writing it in java using the ffmpeg wrapper (this should not be of any real significance I am just mentioning that because the code I provide will be in java but the functions that I am using just make calls to the relevant c/c++ functions of the ffmpeg library). The issue is that when I call avcodec_send_packet it nets me a very high memory usage which also scales with the resolution of the video. Most recently I tried decoding a 4k video stream and every call to avcodec_send_packet netted me about 40 mb of memory usage. This stabilizes after the first frame. In other words when I receive the frame the memory usage stops climbing for subsequent frames. For that particular 4k video stream it climbed to about 800 mb and for subsequent avcodec_send_packet and avcodec_receive_frame calls the memory usage doesn't significantly climb. If the resolution is 1080p it nets me about 300 megabytes of memory. This is a pretty high memory usage considering that one decoded 4k YUV420 frame is about 12 megabytes


public Optional<boolean> decodeVideoFrame(AVPacket pkt,boolean readPacket,boolean keyFrames,boolean doProcessing) throws Exception {
 int ret;
 // Decode video frame
 if (readPacket) {
 ret = avcodec_send_packet(video_c, pkt);
 if (pkt.data() == null && pkt.size() == 0) {
 pkt.stream_index(-1);
 }
 if (ret == AVERROR_EAGAIN() || ret == AVERROR_EOF()) {
 // The video codec may have buffered some frames
 } else if (ret < 0) {
 // Ignore errors to emulate the behavior of the old API
 // throw new Exception("avcodec_send_packet() error " + ret + ": Error sending a video packet for decoding.");
 }
 }

 // Did we get a video frame?
 while (true) {
 ret = avcodec_receive_frame(video_c, picture);

 if (ret == AVERROR_EAGAIN() || ret == AVERROR_EOF()) {
 if (pkt.data() == null && pkt.size() == 0) {
 return Optional.empty();
 } else {
 return Optional.of(true);

 }
 } else if (ret < 0) {
 // Ignore errors to emulate the behavior of the old API
 // throw new Exception("avcodec_receive_frame() error " + ret + ": Error during video decoding.");
 return Optional.of(true);

 }
</boolean>


This is pretty much all the relevant code along with maybe the packet allocation :


AVPacket pkt = av_packet_alloc();

 pkt.stream_index(-1);
 int ret;
 while(true){
 if((ret = av_read_frame(grabber.getFormatContext(),pkt))<0){

 if (ret == AVERROR_EAGAIN()) {
 try {
 Thread.sleep(10);
 continue;
 } catch (InterruptedException ex) {
 // reset interrupt
 Thread.interrupted();

 }
 }
 av_packet_unref(pkt);
 pkt.deallocate();
 return null;

 }
 break;

 }


 return pkt;



(this is in a separate method). Also another weird effect that comes out of this is when the video resolution is higher than 1080p the frames gets corrupted. I will attach two images that compare what the frame is supposed to look like and what it actually looks like.What its supposed to look like
What it looks like when given to the decoder
And in case the question is asked this isn't because of how I am displaying the frame. I can say that with 100% certainty as I have moved across 3 different ways of rendering video frames. The first one being CanvasFrame that comes with the wrapper library I am using for ffmpeg, then I switched to javafx ImageView and now I am using vulkan. Same exact result across all three methods. The decoder is pretty much in all cases vp9 and the frames are in yuv420p.


I tried looking through stackoverflow and some other places and I saw a somewhat similar post but unfortunately I couldn't really find an answer there.


Update : I decided to implement hardware acceleration in my program while this problem persists to see if its going to help. With hardware acceleration the memory usage is significantly lower but that's to be expected. The more bizarre thing I came across is this : The frames are still corrupted when resolution is above 1080p EXCEPT if I very specifically say



avcodec_find_decoder_by_name("vp9_cuvid");



. If I use this :


av_find_best_stream(oc, AVMEDIA_TYPE_VIDEO, -1, -1, vidCodec, 0); 



this also allocates the video codec and it uses vp9 but the frames get corrupted. no idea what's going on. I also tried doing


avcodec_find_decoder_by_name("vp9");



but that also leaves me with corrupted frames. (it should be the same codec after all).


-
ffmpeg convert from H.264 (High 4:4:4 Profile) to H.264 (Main Profile)
15 novembre 2019, par MiladHow can I convert a video from H.264 (High 4:4:4 Profile) to H.264 (Main Profile) using ffmpeg ?
I can’t do that with this command :
ffmpeg -i 1/25359.mp4 -profile:v main out.mp4
.That’d return an error :
...
That'd return an error:
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '1/25359.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf56.40.101
Duration: 00:00:06.08, start: 0.000000, bitrate: 1059 kb/s
Stream #0:0(und): Video: h264 (High 4:4:4 Predictive) (avc1 / 0x31637661), yuv444p, 351x297, 1057 kb/s, 12.50 fps, 12.50 tbr, 12800 tbn, 25 tbc (default)
Metadata:
handler_name : VideoHandler
No pixel format specified, yuv444p for H.264 encoding chosen.
Use -pix_fmt yuv420p for compatibility with outdated media players.
x264 [error]: main profile doesn't support 4:4:4
[libx264 @ 0x8fa9640] Error setting profile main.
[libx264 @ 0x8fa9640] Possible profiles: baseline main high high10 high422 high444
Output #0, mp4, to '1/24545.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf56.40.101
Stream #0:0(und): Video: h264, none, q=2-31, 128 kb/s, 12.50 fps (default)
Metadata:
handler_name : VideoHandler
encoder : Lavc56.60.100 libx264
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height -
ffmpeg convert from H.264 (High 4:4:4 Profile) to H.264 (Main Profile)
22 juin 2016, par user3002233How can I convert a video from H.264 (High 4:4:4 Profile) to H.264 (Main Profile) using ffmpeg ?
I can’t do that with this command :
ffmpeg -i 1/25359.mp4 -profile:v main out.mp4
.That’d return an error :
...
That'd return an error:
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '1/25359.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf56.40.101
Duration: 00:00:06.08, start: 0.000000, bitrate: 1059 kb/s
Stream #0:0(und): Video: h264 (High 4:4:4 Predictive) (avc1 / 0x31637661), yuv444p, 351x297, 1057 kb/s, 12.50 fps, 12.50 tbr, 12800 tbn, 25 tbc (default)
Metadata:
handler_name : VideoHandler
No pixel format specified, yuv444p for H.264 encoding chosen.
Use -pix_fmt yuv420p for compatibility with outdated media players.
x264 [error]: main profile doesn't support 4:4:4
[libx264 @ 0x8fa9640] Error setting profile main.
[libx264 @ 0x8fa9640] Possible profiles: baseline main high high10 high422 high444
Output #0, mp4, to '1/24545.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf56.40.101
Stream #0:0(und): Video: h264, none, q=2-31, 128 kb/s, 12.50 fps (default)
Metadata:
handler_name : VideoHandler
encoder : Lavc56.60.100 libx264
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height