
Recherche avancée
Médias (1)
-
The Slip - Artworks
26 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Texte
Autres articles (49)
-
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 -
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 (...) -
Support audio et vidéo HTML5
10 avril 2011MediaSPIP utilise les balises HTML5 video et audio pour la lecture de documents multimedia en profitant des dernières innovations du W3C supportées par les navigateurs modernes.
Pour les navigateurs plus anciens, le lecteur flash Flowplayer est utilisé.
Le lecteur HTML5 utilisé a été spécifiquement créé pour MediaSPIP : il est complètement modifiable graphiquement pour correspondre à un thème choisi.
Ces technologies permettent de distribuer vidéo et son à la fois sur des ordinateurs conventionnels (...)
Sur d’autres sites (10197)
-
How to correctly apply select filter after trim in ffpeg ? [closed]
29 mai 2024, par lakhan dhingraI am using the following ffmpeg command to trim and select certain portions of the video.


ffmpeg -v verbose -i test.mp4 -filter_complex \
"[0:v]trim=start=5:end=40,setpts=PTS-STARTPTS[v_trimmed]; \
 [v_trimmed]select='between(t,10,20)',setpts=N/FRAME_RATE/TB[v]; \
 [0:a]atrim=start=5:end=40,asetpts=PTS-STARTPTS[a_trimmed]; \
 [a_trimmed]aselect='between(t,10,20)',asetpts=N/SR/TB[a]" \
-map "[v]" -map "[a]" -y -r 30 output_video.mp4



The above command errors out with the following trace


[h264 @ 0x12570a0e0] Reinit context to 1280x720, pix_fmt: yuv420p
[graph 0 input from stream 0:0 @ 0x600001ff8000] w:1280 h:720 pixfmt:yuv420p tb:1/30000 fr:30000/1001 sar:1/1 csp:bt709 range:tv
[graph_0_in_0:1 @ 0x600001ff80b0] tb:1/44100 samplefmt:fltp samplerate:44100 chlayout:stereo
[Parsed_trim_0 @ 0x600001ffc420] TB:0.000033 FRAME_RATE:29.970030 SAMPLE_RATE:nan
[Parsed_select_2 @ 0x600001ffc580] TB:0.000033 FRAME_RATE:nan SAMPLE_RATE:nan
[Parsed_atrim_4 @ 0x600001ffc630] TB:0.000023 FRAME_RATE:nan SAMPLE_RATE:44100.000000
[Parsed_aselect_6 @ 0x600001ffc790] TB:0.000023 FRAME_RATE:nan SAMPLE_RATE:44100.000000
[graph 0 input from stream 0:0 @ 0x600001ff8000] video frame properties congruent with link at pts_time: 0
[vost#0:0/libx264 @ 0x125707800] *** dropping frame 0 at ts -9223372036854775808
 Last message repeated 298 times
[fc#0 @ 0x600001ae81b0] Input 1 no longer accepts new data
[aist#0:1/aac @ 0x1257100b0] [dec:aac @ 0x12570ea40] Decoder returned EOF, finishing
[aist#0:1/aac @ 0x1257100b0] [dec:aac @ 0x12570ea40] Terminating thread with return code 0 (success)
[aist#0:1/aac @ 0x1257100b0] All consumers of this stream are done
[fc#0 @ 0x600001ae81b0] Filtergraph returned EOF, finishing
[fc#0 @ 0x600001ae81b0] All consumers returned EOF
[vost#0:0/libx264 @ 0x125707800] *** dropping frame 0 at ts -9223372036854775808
[vost#0:0/libx264 @ 0x125707800] Encoder thread received EOF
[vost#0:0/libx264 @ 0x125707800] Could not open encoder before EOF
[vost#0:0/libx264 @ 0x125707800] Task finished with error code: -22 (Invalid argument)
[vost#0:0/libx264 @ 0x125707800] Terminating thread with return code -22 (Invalid argument)
[aost#0:1/aac @ 0x1257084b0] Encoder thread received EOF
[fc#0 @ 0x600001ae81b0] Terminating thread with return code 0 (success)
[vist#0:0/h264 @ 0x12570ecf0] [dec:h264 @ 0x1257094e0] Decoder returned EOF, finishing
[vist#0:0/h264 @ 0x12570ecf0] [dec:h264 @ 0x1257094e0] Terminating thread with return code 0 (success)
[vist#0:0/h264 @ 0x12570ecf0] All consumers of this stream are done
[in#0/mov,mp4,m4a,3gp,3g2,mj2 @ 0x6000014ec100] All consumers are done
[in#0/mov,mp4,m4a,3gp,3g2,mj2 @ 0x6000014ec100] Terminating thread with return code 0 (success)
[aost#0:1/aac @ 0x1257084b0] Terminating thread with return code 0 (success)
[out#0/mp4 @ 0x600001de8000] Nothing was written into output file, because at least one of its streams received no packets.
frame= 0 fps=0.0 q=0.0 Lsize= 0KiB time=N/A bitrate=N/A dup=0 drop=301 speed=N/A 
[aac @ 0x1257087b0] Qavg: 645.507
[AVIOContext @ 0x125708d60] Statistics: 0 bytes written, 0 seeks, 0 writeouts
[in#0/mov,mp4,m4a,3gp,3g2,mj2 @ 0x6000014ec100] Input file #0 (test.mp4):
[in#0/mov,mp4,m4a,3gp,3g2,mj2 @ 0x6000014ec100] Input stream #0:0 (video): 1219 packets read (1479521 bytes); 1201 frames decoded; 0 decode errors; 
[in#0/mov,mp4,m4a,3gp,3g2,mj2 @ 0x6000014ec100] Input stream #0:1 (audio): 1741 packets read (646974 bytes); 1732 frames decoded; 0 decode errors (1773568 samples); 
[in#0/mov,mp4,m4a,3gp,3g2,mj2 @ 0x6000014ec100] Total: 2960 packets (2126495 bytes) demuxed
[AVIOContext @ 0x125705640] Statistics: 2699615 bytes read, 0 seeks
Conversion failed!




If I remove the setpts step after the trim, the above command will work as expected. What is the problem with using trim and setpts, and then, passing the output to the select filter ?
Note : Using trim is important as per my current flow.


-
How to adjust audio volume with AVFilter API from FFmpeg in Linux ?
20 décembre 2024, par wangt13I am working on an embedded Linux system (kernel-5.10.24), and developing an audio player by using FFmpeg and ALSA libraries.


Now the basic functions are done, and I can play MP3 file by using AVCodec and SWresample interfaces of FFmpeg.


int decode_play(void)
{
 .....
 while (1) {
 if (av_read_frame(pfmtctx, packet) < 0) {
 avcodec_flush_buffers(pcodectx);
 printf("Got end of media, breaking\n");
 break;
 }
 if (packet->stream_index != stream) {
 continue;
 }
 int res = avcodec_send_packet(pcodectx, packet);
 if (res < 0) {
 printf("Error in decoding audio frame.\n");
 break;
 }

 while (res >= 0) {
 res = avcodec_receive_frame(pcodectx, pframe);
 if (res == AVERROR(EAGAIN)) {
 break;
 } else if (res == AVERROR_EOF) {
 break;
 } else if (res >= 0) {
 int outsamples = swr_convert(swrctx, &buf, pcodectx->frame_size, (const uint8_t **)pframe->data, pframe->nb_samples);
 snd_pcm_write(pcm_handle, buf, outsamples);
 }
 }
 }
}



Now, I want to add
volume
changing to this audio player.

I found that there isAVfilter
functions in FFmpeg, which can be used to adjust audio's volume. How can I use it in current design ?
I am not sure what filters should I use, and where should I plugin the filters ?
Should I put the filters beforeswr_convert
or after theswr_convert
?

With Erdal's help, I changed the player as follows,


int decode_play(void)
{
 /* Init filter graph as filter_audio.c does */
 init_filter_graph(&graph, &src, &sink);

 while (1) {
 if (av_read_frame(pfmtctx, packet) < 0) {
 avcodec_flush_buffers(pcodectx);
 printf("Got end of media, breaking\n");
 break;
 }
 if (packet->stream_index != stream) {
 continue;
 }
 int res = avcodec_send_packet(pcodectx, packet);
 if (res < 0) {
 printf("Error in decoding audio frame.\n");
 break;
 }

 while (res >= 0) {
 res = avcodec_receive_frame(pcodectx, pframe);
 if (res == AVERROR(EAGAIN)) {
 break;
 } else if (res == AVERROR_EOF) {
 break;
 } else if (res >= 0) {
 int ret = av_buffersrc_add_frame(src, pframe);
 if (ret < 0) {
 continue;
 }
 while ((ret = av_buffersink_get_frame(sink, filt_frame)) >= 0) {
 int nb_samples = av_rescale_rnd(filt_frame->nb_samples, RESAMPLE_SAMPLE_RATE, filt_frame->sample_rate, AV_ROUND_UP);
 printf("nb_samples: %d, f.nb_sample: %d, f.sr: %d\n", nb_samples, filt_frame->nb_samples, filt_frame->sample_rate);

 int outs = snd_pcm_writei(playback_handle, filt_frame->extended_data[0], nb_samples);
 if (outs < 0) {
 snd_pcm_prepare(playback_handle);
 }
 }
 }
 }
 }
}



The original audio in format of 44100 Hz, stereo, fltp. And I chose to use
aformat
to do resampling instead ofswresample
as follows.

snprintf(options_str, sizeof(options_str),
 "sample_fmts=%s:sample_rates=%d:channel_layouts=stereo",
 av_get_sample_fmt_name(AV_SAMPLE_FMT_S16), 32000);
 if (avfilter_init_str(aformat_ctx, options_str) < 0) {
 printf("error init aformat filter");
 return -1;
 }



I succeeded playing the resampled audio with
Avfilter
.

-
hwcontext_qsv : Try to select a matching VAAPI device by default
6 mai 2019, par Mark Thompsonhwcontext_qsv : Try to select a matching VAAPI device by default
Tries to find a device backed by the i915 kernel driver and loads the iHD
VAAPI driver to use with it. This reduces confusion on machines with
multiple DRM devices and removes the surprising requirement to set the
LIBVA_DRIVER_NAME environment variable to use libmfx at all.