
Recherche avancée
Médias (3)
-
Elephants Dream - Cover of the soundtrack
17 octobre 2011, par
Mis à jour : Octobre 2011
Langue : English
Type : Image
-
Valkaama DVD Label
4 octobre 2011, par
Mis à jour : Février 2013
Langue : English
Type : Image
-
Publier une image simplement
13 avril 2011, par ,
Mis à jour : Février 2012
Langue : français
Type : Video
Autres articles (25)
-
L’espace de configuration de MediaSPIP
29 novembre 2010, parL’espace de configuration de MediaSPIP est réservé aux administrateurs. Un lien de menu "administrer" est généralement affiché en haut de la page [1].
Il permet de configurer finement votre site.
La navigation de cet espace de configuration est divisé en trois parties : la configuration générale du site qui permet notamment de modifier : les informations principales concernant le site (...) -
Supporting all media types
13 avril 2011, parUnlike most software and media-sharing platforms, MediaSPIP aims to manage as many different media types as possible. The following are just a few examples from an ever-expanding list of supported formats : images : png, gif, jpg, bmp and more audio : MP3, Ogg, Wav and more video : AVI, MP4, OGV, mpg, mov, wmv and more text, code and other data : OpenOffice, Microsoft Office (Word, PowerPoint, Excel), web (html, CSS), LaTeX, Google Earth and (...)
-
Les formats acceptés
28 janvier 2010, parLes commandes suivantes permettent d’avoir des informations sur les formats et codecs gérés par l’installation local de ffmpeg :
ffmpeg -codecs ffmpeg -formats
Les format videos acceptés en entrée
Cette liste est non exhaustive, elle met en exergue les principaux formats utilisés : h264 : H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 m4v : raw MPEG-4 video format flv : Flash Video (FLV) / Sorenson Spark / Sorenson H.263 Theora wmv :
Les formats vidéos de sortie possibles
Dans un premier temps on (...)
Sur d’autres sites (6080)
-
ffmpeg gets stuck at 20 FPS on 4Kp30
1er mars 2023, par Ivy GrowingPlease, help me to understand why putting OBS between the capture card and the ffmpeg improves the FPS rate.


Details :


timeit ffmpeg -y -init_hw_device qsv=hw -filter_hw_device hw -hwaccel qsv -f dshow -video_size 3840x2160 -rtbufsize 2002000k -framerate 30 -c:v rawvideo -i video="USB Capture HDMI 4K+" -r 30 -t 00:01:00 -c:v h264_qsv -preset veryfast -b:v 10000K -movflags faststart -f mpegts output4kqsv.mpg -benchmark
...
Input #0, dshow, from 'video=USB Capture HDMI 4K+':
 Duration: N/A, start: 787911.842300, bitrate: N/A
 Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422(tv, bt709/bt709/unknown), 3840x2160, 30 fps, 30 tbr, 10000k tbn
Stream mapping:
 Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (h264_qsv))
Press [q] to stop, [?] for help
Output #0, mpegts, to 'output4kqsv.mpg':
 Metadata:
 encoder : Lavf59.27.100
 Stream #0:0: Video: h264, nv12(tv, bt709/bt709/unknown, progressive), 3840x2160, q=2-31, 10000 kb/s, 30 fps, 90k tbn
 Metadata:
 encoder : Lavc59.37.100 h264_qsv
...
frame= 1800 fps= 19 q=17.0 Lsize= 74557kB time=00:00:59.90 bitrate=10196.5kbits/s speed=0.648x
...
Elapsed Time: 0:01:34.749



Capturing the video from the capture card is limited to 19-20 FPS and speed 0.65. Tried million tweaks like changing codec from QSV to pure software, changing bitrate, presets, flags, etc - nothing helps.


However, if the same capture card is sourced to OBS and the OBS is set as Virtual camera then it's 30 FPS and speed 1.0 :


timeit ffmpeg -y -init_hw_device qsv=hw -filter_hw_device hw -hwaccel qsv -f dshow -video_size 3840x2160 -rtbufsize 2002000k -framerate 30 -i video="OBS Virtual Camera" -r 30 -t 00:01:00 -c:v h264_qsv -preset veryfast -b:v 10000K -movflags faststart -f mpegts obs4kqsv1.mpg -benchmark
...
Input #0, dshow, from 'video=OBS Virtual Camera':
 Duration: N/A, start: 1576816.988000, bitrate: N/A
 Stream #0:0: Video: rawvideo (NV12 / 0x3231564E), nv12, 3840x2160, 30 fps, 30 tbr, 10000k tbn
Stream mapping:
 Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (h264_qsv))
Press [q] to stop, [?] for help
Output #0, mpegts, to 'obs4kqsv1.mpg':
 Metadata:
 encoder : Lavf59.27.100
 Stream #0:0: Video: h264, nv12(progressive), 3840x2160, q=2-31, 10000 kb/s, 30 fps, 90k tbn
 Metadata:
 encoder : Lavc59.37.100 h264_qsv
...
frame= 1800 fps= 30 q=17.0 Lsize= 74629kB time=00:00:59.90 bitrate=10206.3kbits/s speed=0.999x
...
Elapsed Time: 0:01:02.780



Is OBS just providing "artificial" extra frames ?


How to tweak the ffmpeg command to have all 30 FPS encoded ?


-
How to play audio using libao and FFmpeg in C ?
12 mars 2024, par OmegaLol21I am trying to create a simple prototype application that opens a video file and plays its audio. I am using the FFmpeg libraries (libavcodec, libavformat, etc) to open and decode the video, and I am attempting to use libao to play the audio. I tried looking up code examples but a lot of them either don't work or use deprecated functions.


So far, I managed to come up with this :


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

int main(int argc, char** argv) {
 AVFormatContext* format_ctx = avformat_alloc_context();
 int audio_stream_index = -1;
 AVCodecContext* codec_ctx = NULL;
 AVCodec* codec = NULL;
 AVPacket packet;
 AVFrame* frame = NULL;
 ao_device* device = NULL;
 ao_sample_format sample_format;
 uint8_t* output_buffer = NULL;
 int output_linesize;

 avformat_open_input(&format_ctx, "test.mp4", NULL, NULL);
 avformat_find_stream_info(format_ctx, NULL);

 for (int i = 0; i < format_ctx->nb_streams; i++) {
 if (format_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
 audio_stream_index = i;
 break;
 }
 }

 codec_ctx = avcodec_alloc_context3(NULL);
 avcodec_parameters_to_context(codec_ctx, format_ctx->streams[audio_stream_index]->codecpar);
 codec = avcodec_find_decoder(codec_ctx->codec_id);
 avcodec_open2(codec_ctx, codec, NULL);

 // Initialize libao
 ao_initialize();
 int driver_id = ao_default_driver_id();

 sample_format.bits = 16;
 sample_format.channels = 2;
 sample_format.rate = 44100;
 sample_format.byte_format = AO_FMT_NATIVE;
 sample_format.matrix = 0;
 device = ao_open_live(driver_id, &sample_format, NULL);
 if (!device) {
 fprintf(stderr, "Could not open audio device\n");
 return 1;
 }

 frame = av_frame_alloc();

 while (av_read_frame(format_ctx, &packet) >= 0) {
 if (packet.stream_index == audio_stream_index) {
 int ret = avcodec_send_packet(codec_ctx, &packet);
 if (ret < 0) {
 fprintf(stderr, "Error sending packet for decoding\n");
 break;
 }

 while (ret >= 0) {
 ret = avcodec_receive_frame(codec_ctx, frame);
 if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) {
 break;
 }
 else if (ret < 0) {
 fprintf(stderr, "Error during decoding\n");
 break;
 }

 ao_play(device, (char*)frame->data[0], frame->nb_samples * 2 * frame->channels);
 }
 }
 av_packet_unref(&packet);
 }

 // Clean up
 av_frame_free(&frame);
 avcodec_free_context(&codec_ctx);
 avformat_close_input(&format_ctx);
 ao_close(device);
 ao_shutdown();
 av_freep(&output_buffer);

 return 0;
}



This is the closest I have gotten to play audio. It plays audio but there is a lot of static sound in the background. I did try using using
frame->linesize[0]
fornum_bytes
inao_play
but that didn't produce a sound that sounded at all like the video.

Is there something I am doing wrong or missing ?


EDIT : While doing more testing, I managed to find out that the above code sample outputs pure static in the left speaker, however, in the right speaker, it does play the audio, albeit heavily distorted ?


-
FFMpeg, libav, Problem with sws_scale and yuv to rgb conversion - colors are not correct
7 juillet 2022, par MilikaI've been trying to create my own video player in Delphi, and ffmpeg works great, until i hit a snag with color spaces, or color conversion.


Been trying everything for a couple of days, but can't figure it out.
I'm using AV_PIX_FMT_RGB48LE as output...


Old context creation :


videoConvContext := sws_getContext(AVStreamInit.codec.width, AVStreamInit.codec.height, AVStreamInit.codec.pix_fmt, AVStreamInit.codec.width, AVStreamInit.codec.height, AV_PIX_FMT_RGB48LE, SWS_POINT, nil, nil, nil);



New context creation :


dstRange := 1;
 srcRange := 1;
 if AVStreamInit.codec.color_range = AVCOL_RANGE_MPEG then
 srcRange := 0;

 videoConvContext := sws_alloc_context();

 av_opt_set_int(videoConvContext, 'sws_flags', SWS_POINT or SWS_PRINT_INFO, 0);

 av_opt_set_int(videoConvContext, 'srcw', AVStreamInit.codec.width, 0);
 av_opt_set_int(videoConvContext, 'srch', AVStreamInit.codec.height, 0);
 av_opt_set_int(videoConvContext, 'src_format', Integer(AVStreamInit.codec.pix_fmt), 0);

 av_opt_set_int(videoConvContext, 'dstw', AVStreamInit.codec.width, 0);
 av_opt_set_int(videoConvContext, 'dsth', AVStreamInit.codec.height, 0);
 av_opt_set_int(videoConvContext, 'dst_format', Integer(AV_PIX_FMT_RGB48LE), 0);

 i1 := sws_getCoefficients2(Integer(AVStreamInit.codec.colorspace));
 i2 := sws_getCoefficients2(SWS_CS_ITU709);

 ret := sws_setColorspaceDetails2(videoConvContext, i1, srcRange, i2, dstRange, 0, 1 shl 16, 1 shl 16);

 sws_init_context(videoConvContext, nil, nil);



Results are exactly the same....


Output from sws_scale does not have correct colors, here are 2 screenshot


ok - from mpc-hc



not ok - from my player via sws_scale (direct raw extract so no color processing done)



This video has pix_fmt AV_PIX_FMT_YUV420P10LE, but it happens on other YUV inputs, but not so obvious. Also on other RGB outputs(8bit etc)...
Here the Netflix logo is pure red, but sws_scale output gives orange-ish...


Sws_scale code just for reference :


sws_scale(videoConvContext, @AVPacketBuffer.AVFrameCopy.Data, @AVPacketBuffer.AVFrameCopy.linesize, 0, AVStream.codec.height, @BitmapXBuffer.data, @linesize);



BitmapXBuffer.data is a signle buffer of correct size...


AVFrameCopy - is a copy of original frame done with :


if Assigned(AVPacketBuffer.AVFrameCopy) then
 av_frame_free(@AVPacketBuffer.AVFrameCopy);

 AVPacketBuffer.AVFrameCopy := av_frame_alloc();
 AVPacketBuffer.AVFrameCopy.format := AVPacketBuffer.AVFrame.format;
 AVPacketBuffer.AVFrameCopy.width := AVPacketBuffer.AVFrame.width;
 AVPacketBuffer.AVFrameCopy.height := AVPacketBuffer.AVFrame.height;
 AVPacketBuffer.AVFrameCopy.channels := AVPacketBuffer.AVFrame.channels;
 AVPacketBuffer.AVFrameCopy.channel_layout := AVPacketBuffer.AVFrame.channel_layout;
 AVPacketBuffer.AVFrameCopy.nb_samples := AVPacketBuffer.AVFrame.nb_samples;
 av_frame_get_buffer(AVPacketBuffer.AVFrameCopy, 32);
 av_frame_copy(AVPacketBuffer.AVFrameCopy, AVPacketBuffer.AVFrame);
 av_frame_copy_props(AVPacketBuffer.AVFrameCopy, AVPacketBuffer.AVFrame);



Thanks !