
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 (35)
-
Les autorisations surchargées par les plugins
27 avril 2010, parMediaspip core
autoriser_auteur_modifier() afin que les visiteurs soient capables de modifier leurs informations sur la page d’auteurs -
Contribute to a better visual interface
13 avril 2011MediaSPIP is based on a system of themes and templates. Templates define the placement of information on the page, and can be adapted to a wide range of uses. Themes define the overall graphic appearance of the site.
Anyone can submit a new graphic theme or template and make it available to the MediaSPIP community. -
HTML5 audio and video support
13 avril 2011, parMediaSPIP uses HTML5 video and audio tags to play multimedia files, taking advantage of the latest W3C innovations supported by modern browsers.
The MediaSPIP player used has been created specifically for MediaSPIP and can be easily adapted to fit in with a specific theme.
For older browsers the Flowplayer flash fallback is used.
MediaSPIP allows for media playback on major mobile platforms with the above (...)
Sur d’autres sites (5420)
-
FFmpeg chromakey libavfilter using C-API - key/replace green with alpha transparency
3 juin 2020, par ZeroDefectI'm trying to use the FFmpeg chromakey libavfilter (via the C-API using C++17) to key some green pixels in a YUVA422p image and replace them with alpha transparency.



Now, I setup/initialise the graph, connect the filters, and push through a frame ; however, the output frame appears unchanged. I suspect one of my configuration parameters is incorrect, but I'm really unsure. After having read the pertinent documentation, I still don't understand the problem.



I have published a (minimal) code sample in github - https://github.com/zerodefect/chromakey_test. I have tried to keep the code sample as brief as possible but it is still a bit lengthy.



The code sample includes a sample image (green_screen.png) for the purposes of testing.



To run the application, the following parameters are required :





./cb_chroma_key_test ./green_screen.png [OUTPUT_PATH]





The application dumps out a PLANAR image at YUV422p which I then load in via rawpixels.net - a brilliant little online utility to view raw image data (packed or planar).



My avfilter graph consists of :





buffersrc -> format -> chromakey -> buffersink





The format filter is taking the RGBA (packed) format and converting it to YUVA422 planar.



- 

- GCC 8.4
- Ubuntu 18.04
- FFmpeg 4.2








-
Raw audio decoding of video with Libav is chopped
25 juin 2020, par AlphabetI'm currently using
libav
to extract the audio stream of a video into a raw PCM file.

This code works fine for mp3 but when I try with a mp4 video, the raw format imported on Audacity show stranges regular descending lines between 0 and -1.




Here is my implementation.


#include 
#include 
#include 
#include 

#include <libavcodec></libavcodec>avcodec.h>
#include <libavformat></libavformat>avformat.h>
#include <libswresample></libswresample>swresample.h>

int decode_raw(AVFormatContext *format_ctx)
{
 AVCodec *codec = NULL;
 AVCodecContext* codec_ctx = NULL;
 AVFrame* frame = NULL;
 AVPacket packet;
 int stream_idx = av_find_best_stream(format_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, &codec, 0);
 int res;

 if (stream_idx < 0) {
 printf("Could not find stream.\n");
 return (1);
 }

 if ((codec_ctx = avcodec_alloc_context3(codec)) == NULL) {
 printf("Could not allocate codec context.\n");
 return (1);
 }

 if (avcodec_parameters_to_context(codec_ctx, format_ctx->streams[stream_idx]->codecpar) < 0) {
 printf("Could not setup codec context parameters.\n");
 return (1);
 }

 // Explicitly request non planar data.
 codec_ctx->request_sample_fmt = av_get_packed_sample_fmt(codec_ctx->sample_fmt);

 if (avcodec_open2(codec_ctx, codec, NULL) != 0) {
 printf("Could not open codec.\n");
 return (1);
 }

 if ((frame = av_frame_alloc()) == NULL) {
 printf("Could not alloc frame.\n");
 return (1);
 }

 av_init_packet(&packet);

 int fd = open("raw", O_CREAT | O_WRONLY | O_TRUNC);

 // Decode frames.
 while ((res = av_read_frame(format_ctx, &packet)) == 0) {
 // Does the packet belong to the correct stream?
 if (packet.stream_index != stream_idx) {
 av_packet_unref(&packet);
 continue;
 }

 // We have a valid packet => send it to the decoder.
 if ((res = avcodec_send_packet(codec_ctx, &packet)) != 0) {
 printf("Failed to send packet: %d.\n", res);
 break;
 }

 av_packet_unref(&packet);
 res = avcodec_receive_frame(codec_ctx, frame);

 if (res == AVERROR(EAGAIN) || res == AVERROR_EOF)
 break;
 else if (res < 0) {
 printf("Failed to decode packet: %d.\n", res);
 return (1);
 }

 write(fd, frame->extended_data[0], frame->linesize[0]);
 }

 close(fd);
 av_frame_free(&frame);
 avcodec_close(codec_ctx);
 avcodec_free_context(&codec_ctx);
 return (0);
}

int main(int argc, char **argv)
{
 AVFormatContext *av_format_ctx = NULL;

 if (argc != 2) {
 printf("./streamer [file]\n");
 return (1);
 }

 if (avformat_open_input(&av_format_ctx, argv[1], NULL, NULL) != 0) {
 printf("Could not open input file.");
 return (1);
 }

 if (avformat_find_stream_info(av_format_ctx, NULL) != 0) {
 printf("Could not find stream information.");
 return (1);
 }

 decode_raw(av_format_ctx);
 avformat_close_input(&av_format_ctx);
 return (0);
}



What I tried


- 

- Check endianness and if I correctly imported the raw file in Audacity
- Execute the corresponding ffmpeg command
ffmpeg -i video.mp4 -f f32le output.raw
(my code outputAV_SAMPLE_FMT_FLT
) to compare both files.






I hexdumped both files and found this.


// 96 1f 03 3f - 22 03 0c 3f
// Doesn't exist in the output of my program?

5581a0 7c ad 6f bc 96 1f 03 3f 4f 01 25 3e 22 03 0c 3f |.o....?O.%>"..? // ffmpeg
5580d0 7c ad 6f bc 4f 01 25 3e 3a d2 89 3e 7c d7 9a 3e |.o.O.%>:..>|..> // my implementation




Edit #1


After an endless succession of disappointing experiences, AAC audio streams appear to be corrupted after decoding. However, the raw PCM output from ffmpeg works well for MP4.


I tried to resample the audio frames with
swr_convert
but it is too poorly documented and I turned into a lot of issues.

-
Grab audio samples with ffmpeg and C, error with official example code
31 août 2020, par nji9For dev with mingw-w64 I'm using ffmpeg v. 4.3.1. and also the latest Git version of ffmpeg (Zeranoe's Windows 64 builds).


I get "strange" problems when running the official example code for decoding audio


https://github.com/FFmpeg/FFmpeg/blob/master/doc/examples/decode_audio.c


MP3DirectCut(Lib-bass).mp3


http://www.mediafire.com/file/ozmjjcpwyhhdnr7/MP3DirectCut(Lib-bass).mp3/file


Generates pcm, but outputs :


"Warning: the sample format the decoder produced is planar (s16p).
This example will output the first channel only."



But the output pcm has both channels !??


When recoding the above mp3 to wav with ffmpeg (4.1.4, no error message)


http://www.mediafire.com/file/gcq7ryg43pd57q5/ffmpeg4.1.4.wav/file


and also when recoding the latter to mp3 again


http://www.mediafire.com/file/ij865dkrprn2lta/ffmpeg4.1.4_recode.mp3/file


the example code breaks and produces these error messages :


avcodec_send_packet ()
from within:
"[mp2 @ <someaddress>] Header missing"
and returns error code -1094995529
(= "Invalid data found when processing input")
</someaddress>


It produces that error message for literally all other formats
I tried, and also when written with another editor (Audition 3.0).
But all the files play and show fine on all programs I have.


I'm at a lost at this point.
What is going on and wrong here ?