
Recherche avancée
Médias (91)
-
DJ Z-trip - Victory Lap : The Obama Mix Pt. 2
15 septembre 2011
Mis à jour : Avril 2013
Langue : English
Type : Audio
-
Matmos - Action at a Distance
15 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
DJ Dolores - Oslodum 2004 (includes (cc) sample of “Oslodum” by Gilberto Gil)
15 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Danger Mouse & Jemini - What U Sittin’ On ? (starring Cee Lo and Tha Alkaholiks)
15 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Cornelius - Wataridori 2
15 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
The Rapture - Sister Saviour (Blackstrobe Remix)
15 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
Autres articles (41)
-
Encoding and processing into web-friendly formats
13 avril 2011, parMediaSPIP automatically converts uploaded files to internet-compatible formats.
Video files are encoded in MP4, Ogv and WebM (supported by HTML5) and MP4 (supported by Flash).
Audio files are encoded in MP3 and Ogg (supported by HTML5) and MP3 (supported by Flash).
Where possible, text is analyzed in order to retrieve the data needed for search engine detection, and then exported as a series of image files.
All uploaded files are stored online in their original format, so you can (...) -
Creating farms of unique websites
13 avril 2011, parMediaSPIP platforms can be installed as a farm, with a single "core" hosted on a dedicated server and used by multiple websites.
This allows (among other things) : implementation costs to be shared between several different projects / individuals rapid deployment of multiple unique sites creation of groups of like-minded sites, making it possible to browse media in a more controlled and selective environment than the major "open" (...) -
Ajouter notes et légendes aux images
7 février 2011, parPour pouvoir ajouter notes et légendes aux images, la première étape est d’installer le plugin "Légendes".
Une fois le plugin activé, vous pouvez le configurer dans l’espace de configuration afin de modifier les droits de création / modification et de suppression des notes. Par défaut seuls les administrateurs du site peuvent ajouter des notes aux images.
Modification lors de l’ajout d’un média
Lors de l’ajout d’un média de type "image" un nouveau bouton apparait au dessus de la prévisualisation (...)
Sur d’autres sites (4354)
-
YouTube_dl doesn't find ffmpeg
10 octobre 2019, par user702846I would like to download a set of youtube file as audio, mp3.
import youtube_dl
ydl_opts = {
'format': 'bestaudio/best',
'postprocessors': [{
'key': 'FFmpegExtractAudio',
'preferredcodec': 'mp3',
'preferredquality': '192',
}],
}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
ydl.download(['https://www.youtube.com/watch?v=cmNEDz7YZSw'])It successfully download the file as m4a - however complains about ffmpeg installation.
ERROR: ffprobe/avprobe and ffmpeg/avconv not found. Please install one.
I do have ffmpeg installed and located at /usr/local/bin/ffmpeg and also have added to my PATH using
os.environ["PATH"] += '/usr/local/bin/ffmpeg'
but still the error is there. I am using MacOS Mojave and my ffmpeg specification are as following,
fmpeg version 4.1.3 Copyright (c) 2000-2019 the FFmpeg developers
built with Apple LLVM version 10.0.1 (clang-1001.0.46.4)
configuration: --disable-encoder=vorbis --enable-libvorbis --enable-libmp3lame --disable-x86asm -
How to improve the sharpness of the output video on centOS ?
11 octobre 2019, par Mads LeeI’m using the same ffmpeg cmd on Windows and centOS to add timecode for the input video, the output video on centOS has low sharpness and mosaic.
ffmpeg version :
ffmpeg on Windows: 4.1.3 built with gcc 8.3.1 (gcc) 20190414
ffmpeg on centOS: 4.1.0 built with gcc 5.8.5(gcc) 20150623 (Red Hat 4.8.5-16)ffmpeg cmd :
ffmpeg -i \input.mp4 -vf drawtext="timecode='00\:00\:00\:00':rate=30:x=10:y=10:text=qwer:fontsize=50:fontcolor=yellow:boxcolor=black" \output.mp4
Video screenshot :
full log on centOS :
[root@3b8e5c174983 installfile]# ls
ffmpeg-4.1.3 ffmpeg-4.1.3.tar.gz input.mp4 yasm-1.3.0 yasm-1.3.0.tar.gz
[root@3b8e5c174983 installfile]# ffmpeg -i /installfile/input.mp4 -vf drawtext="fontfile=/usr/share/fonts/lyx/simhei.ttf:timecode='00\:00\:00\:00':rate=30:x=10:y=10:text=qwer:fontsize=50:fontcolor=black" /installfile/output.mp4
ffmpeg version 4.1.3 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-16)
configuration: --enable-libfreetype
libavutil 56. 22.100 / 56. 22.100
libavcodec 58. 35.100 / 58. 35.100
libavformat 58. 20.100 / 58. 20.100
libavdevice 58. 5.100 / 58. 5.100
libavfilter 7. 40.101 / 7. 40.101
libswscale 5. 3.100 / 5. 3.100
libswresample 3. 3.100 / 3. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/installfile/input.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.25.100
Duration: 00:00:25.68, start: 0.000000, bitrate: 3620 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, smpte170m/bt709/bt709), 1920x1080, 3490 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 127 kb/s (default)
Metadata:
handler_name : SoundHandler
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> mpeg4 (native))
Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
Output #0, mp4, to '/installfile/output.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.20.100
Stream #0:0(und): Video: mpeg4 (mp4v / 0x7634706D), yuv420p, 1920x1080, q=2-31, 200 kb/s, 30 fps, 15360 tbn, 30 tbc (default)
Metadata:
handler_name : VideoHandler
encoder : Lavc58.35.100 mpeg4
Side data:
cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
handler_name : SoundHandler
encoder : Lavc58.35.100 aac
frame= 769 fps=108 q=31.0 Lsize= 10290kB time=00:00:25.70 bitrate=3279.4kbits/s speed=3.62x
video:9870kB audio:397kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.222400%
[aac @ 0x37dbec0] Qavg: 2346.057
[root@3b8e5c174983 installfile]#it’s about the version of ffmpeg ?
-
libav seeking to n seconds in a video and saving frames there onwards
7 juillet 2022, par Sam KoreI've been trying to seek in a mpegts video file. After exploring many codes, I've come up to the following stage of fetching frames and saving them.
However after using av_seek_frame also I'm getting following results :


- 

- Initial 7-8 frames are saved as grey frames.
- Thereafter frames are fetched from beginning of the video only. i.e. 0 seconds onwards, while I'm trying to seek from say 12th seconds onwards.






Can you please explain how should I be calculating the timestamp and do the things correctly ?



int main(int argc, const char *argv[])
{

 int stream_id;
 int64_t timestamp;
 char ts_buf[60];


 if (argc < 2) {
 printf("You need to specify a media file.\n");
 return -1;
 }
 
 logging("initializing all the containers, codecs and protocols.");

 
 AVFormatContext *pFormatContext = avformat_alloc_context();
 if (!pFormatContext) {
 logging("ERROR could not allocate memory for Format Context");
 return -1;
 }

 logging("opening the input file (%s) and loading format (container) header", argv[1]);
 
 if (avformat_open_input(&pFormatContext, argv[1], NULL, NULL) != 0) {
 logging("ERROR could not open the file");
 return -1;
 }

 logging("format %s, duration %lld us, bit_rate %lld", pFormatContext->iformat->name, pFormatContext->duration, pFormatContext->bit_rate);

 logging("finding stream info from format");
 
 if (avformat_find_stream_info(pFormatContext, NULL) < 0) {
 logging("ERROR could not get the stream info");
 return -1;
 }

 AVCodec *pCodec = NULL;
 AVCodecParameters *pCodecParameters = NULL;
 int video_stream_index = -1;

 // loop though all the streams and print its main information
 for (int i = 0; i < pFormatContext->nb_streams; i++)
 {
 AVCodecParameters *pLocalCodecParameters = NULL;
 pLocalCodecParameters = pFormatContext->streams[i]->codecpar;
 logging("AVStream->time_base before open coded %d/%d", pFormatContext->streams[i]->time_base.num, pFormatContext->streams[i]->time_base.den);
 logging("AVStream->r_frame_rate before open coded %d/%d", pFormatContext->streams[i]->r_frame_rate.num, pFormatContext->streams[i]->r_frame_rate.den);
 logging("AVStream->start_time %" PRId64, pFormatContext->streams[i]->start_time);
 logging("AVStream->duration %" PRId64, pFormatContext->streams[i]->duration);

 logging("finding the proper decoder (CODEC)");

 AVCodec *pLocalCodec = NULL;

 pLocalCodec = avcodec_find_decoder(pLocalCodecParameters->codec_id);

 if (pLocalCodec==NULL) {
 logging("ERROR unsupported codec!");
 // In this example if the codec is not found we just skip it
 continue;
 }

 // when the stream is a video we store its index, codec parameters and codec
 if (pLocalCodecParameters->codec_type == AVMEDIA_TYPE_VIDEO) {
 if (video_stream_index == -1) {
 video_stream_index = i;
 pCodec = pLocalCodec;
 pCodecParameters = pLocalCodecParameters;
 }

 logging("Video Codec: resolution %d x %d", pLocalCodecParameters->width, pLocalCodecParameters->height);
 } else if (pLocalCodecParameters->codec_type == AVMEDIA_TYPE_AUDIO) {
 logging("Audio Codec: %d channels, sample rate %d", pLocalCodecParameters->channels, pLocalCodecParameters->sample_rate);
 }

 // print its name, id and bitrate
 logging("\tCodec %s ID %d bit_rate %lld", pLocalCodec->name, pLocalCodec->id, pLocalCodecParameters->bit_rate);
 }

 if (video_stream_index == -1) {
 logging("File %s does not contain a video stream!", argv[1]);
 return -1;
 }

 AVCodecContext *pCodecContext = avcodec_alloc_context3(pCodec);
 if (!pCodecContext)
 {
 logging("failed to allocated memory for AVCodecContext");
 return -1;
 }

 if (avcodec_parameters_to_context(pCodecContext, pCodecParameters) < 0)
 {
 logging("failed to copy codec params to codec context");
 return -1;
 }

 if (avcodec_open2(pCodecContext, pCodec, NULL) < 0)
 {
 logging("failed to open codec through avcodec_open2");
 return -1;
 }

 AVFrame *pFrame = av_frame_alloc();
 if (!pFrame)
 {
 logging("failed to allocate memory for AVFrame");
 return -1;
 }

 AVPacket *pPacket = av_packet_alloc();
 if (!pPacket)
 {
 logging("failed to allocate memory for AVPacket");
 return -1;
 }

 /*seek for 20 seconds*/
 int64_t incr, pos = 5;

 int64_t seek_target = (pos * AV_TIME_BASE), stream_index = 0, how_many_packets_to_process = 50, response = 0;

 printf("seek_target before : %lu\n", seek_target);
 seek_target = av_rescale_q(seek_target, AV_TIME_BASE_Q, pFormatContext->streams[stream_index]->time_base);

 printf("seek_target after: %lu\n", seek_target);

 do
 {
 response = decode_packet(pFormatContext, pPacket, pCodecContext, pFrame, seek_target);
 if (response < 0)
 break;
 avcodec_flush_buffers(pCodecContext);

 /*av_frame_unref(pFrame);
 av_packet_unref(pPacket);*/
 // stop it, otherwise we'll be saving hundreds of frames
 if (--how_many_packets_to_process <= 0) 
 break;

 }while(1);

logging("releasing all the resources");

 avformat_close_input(&pFormatContext);
 av_packet_free(&pPacket);
 av_frame_free(&pFrame);
 avcodec_free_context(&pCodecContext);
 return 0;
}


int decode_packet(AVFormatContext *pFormatContext, AVPacket *pPacket, AVCodecContext *pCodecContext, AVFrame *pFrame, int64_t seek_target)
{
 if(av_seek_frame(pFormatContext, 0, /*(startTime + frameTimestamp) / 10*/seek_target, AVSEEK_FLAG_BACKWARD) < 0)
 {
 printf("error while seeking\n"/*, pFormatContext->filename*/);
 return -1;
 }
 avcodec_flush_buffers(pCodecContext);

 while(1)
 {
 if(av_read_frame(pFormatContext, pPacket) < 0)
 {
 logging("av_read_frame failure");
 break;
 }

 /* I'm not able to get to correct timestamp to discard prior frames upto desired seconds. This if hasn't worked out well as of now. */
 if((av_q2d(pFormatContext->streams[0]->time_base) * pPacket->pts) < (seek_target * 1000))
 {
 printf("skipping the frame\npFormatContext->streams[0]->time_base: %d %d\tpckt.pts: %lu\tseek: %lu", pFormatContext->streams[0]->time_base.num, pFormatContext->streams[0]->time_base.den, pPacket->pts, seek_target);
 av_packet_unref(pPacket);
 continue;
 }

 // Send Packet for decoding
 int response = avcodec_send_packet(pCodecContext, pPacket);

 if (response < 0) {
 logging("Error while sending a packet to the decoder: %s", av_err2str(response));
 return response;
 }

 while (response >= 0)
 {
 response = avcodec_receive_frame(pCodecContext, pFrame);
 if (response == AVERROR(EAGAIN) || response == AVERROR_EOF) {
 break;
 } else if (response < 0) {
 logging("Error while receiving a frame from the decoder: %s", av_err2str(response));
 return response;
 }

 if (response >= 0) {
 logging(
 "Frame %d (type=%c, size=%d bytes, format=%d) pts %d key_frame %d [DTS %d]: %d",
 pCodecContext->frame_number,
 av_get_picture_type_char(pFrame->pict_type),
 pFrame->pkt_size,
 pFrame->format,
 pFrame->pts,
 pFrame->key_frame,
 pFrame->coded_picture_number,
 pPacket->dts
 );

 char frame_filename[1024];
 snprintf(frame_filename, sizeof(frame_filename), "%s-%d.pgm", "im/frame", pCodecContext->frame_number);

 if (pFrame->format != AV_PIX_FMT_YUV420P)
 {
 logging("Warning: the generated file may not be a grayscale image, but could e.g. be just the R component if the video format is RGB");
 }
 // save a grayscale frame into a .pgm file
 save_gray_frame(pFrame->data[0], pFrame->linesize[0], pFrame->width, pFrame->height, frame_filename);

 av_frame_unref(m_pAVFrame);
 
 }
 }
 }
 return 0;
}