
Recherche avancée
Médias (91)
-
Richard Stallman et le logiciel libre
19 octobre 2011, par
Mis à jour : Mai 2013
Langue : français
Type : Texte
-
Stereo master soundtrack
17 octobre 2011, par
Mis à jour : Octobre 2011
Langue : English
Type : Audio
-
Elephants Dream - Cover of the soundtrack
17 octobre 2011, par
Mis à jour : Octobre 2011
Langue : English
Type : Image
-
#7 Ambience
16 octobre 2011, par
Mis à jour : Juin 2015
Langue : English
Type : Audio
-
#6 Teaser Music
16 octobre 2011, par
Mis à jour : Février 2013
Langue : English
Type : Audio
-
#5 End Title
16 octobre 2011, par
Mis à jour : Février 2013
Langue : English
Type : Audio
Autres articles (46)
-
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" (...) -
List of compatible distributions
26 avril 2011, parThe table below is the list of Linux distributions compatible with the automated installation script of MediaSPIP. Distribution nameVersion nameVersion number Debian Squeeze 6.x.x Debian Weezy 7.x.x Debian Jessie 8.x.x Ubuntu The Precise Pangolin 12.04 LTS Ubuntu The Trusty Tahr 14.04
If you want to help us improve this list, you can provide us access to a machine whose distribution is not mentioned above or send the necessary fixes to add (...) -
Taille des images et des logos définissables
9 février 2011, parDans beaucoup d’endroits du site, logos et images sont redimensionnées pour correspondre aux emplacements définis par les thèmes. L’ensemble des ces tailles pouvant changer d’un thème à un autre peuvent être définies directement dans le thème et éviter ainsi à l’utilisateur de devoir les configurer manuellement après avoir changé l’apparence de son site.
Ces tailles d’images sont également disponibles dans la configuration spécifique de MediaSPIP Core. La taille maximale du logo du site en pixels, on permet (...)
Sur d’autres sites (3183)
-
How to set video duration using python ?
2 mars 2015, par shoujsI write a python program to record streaming video. I can play the recorded video using VLC. I find the duration will be 1 hour whatever how much time I take to record the video.
Here is the code snippet :
f = open(filename, 'wb')
block_size = 1024
duration = 2 * 60 # 2 mins
start = datetime.now()
end = start + timedelta(seconds=duration)
while datetime.now() < end:
try:
buffer = response.read(block_size)
if not buffer:
break
f.write(buffer)
except:
pass
f.close()I use ffmpeg to inspect the video. It tells me 1 hour of duration.
So is there a way to set the correct duration for the streaming video recording ?
The medata data for the video inspected by ffmpeg
-
Getting an error when I use live555+ffmpeg to play rtsp (h.264 )
11 septembre 2011, par moonvanThis is the debug info .I am a beginner for this. Can you tell me what the error mean ?
Sending request: OPTIONS rtsp://218.204.223.237:554/live/1/66251FC11353191F/e7ooqwcfbqjoo80j.sdp RTSP/1.0
CSeq: 1
User-Agent: LIVE555 Streaming Media v2010.04.09
Received OPTIONS response: RTSP/1.0 200 OK
Server: PVSS/0.0.1 (Build/20100101; Platform/Win32; Darwin; )
Cseq: 1
Public: DESCRIBE, SETUP, TEARDOWN, PLAY, PAUSE, OPTIONS, ANNOUNCE, RECORD
Sending request: DESCRIBE rtsp://218.204.223.237:554/live/1/66251FC11353191F/e7ooqwcfbqjoo80j.sdp RTSP/1.0
CSeq: 2
Accept: application/sdp
User-Agent: LIVE555 Streaming Media v2010.04.09
Received DESCRIBE response: RTSP/1.0 200 OK
Server: PVSS/0.0.1 (Build/20100101; Platform/Win32; Darwin; )
Cseq: 2
Content-length: 413
Date: Sun, 11 Sep 2011 13:41:27 GMT
Expires: Sun, 11 Sep 2011 13:41:27 GMT
Content-Type: application/sdp
x-Accept-Retransmit: our-retransmit
x-Accept-Dynamic-Rate: 1
Content-Base: rtsp://218.204.223.237:554/live/1/66251FC11353191F/e7ooqwcfbqjoo80j.sdp/
Need to read 413 extra bytes
Read 413 extra bytes: v=0
o=- 1 1 IN IP4 0.0.0.0
s=RTSP Session
i=Jabsco Stream(JCO-jy9757acx1eve7nm-a104aea23c1e17bbc776656f5069bbf7)
c=IN IP4 218.204.223.237
t=0 0
a=range:npt=now-
a=control:*
m=video 0 RTP/AVP 96
b=AS:200
a=rtpmap:96 MP4V-ES/90000
a=fmtp:96 profile-level-id=1;config=000001b001000001b509000001010000012000844ea628582120a21f;decode_buf=115200
a=framerate:15
a=framesize:96 352-288
a=control:trackID=1
2011-09-11 21:41:28.344 rtsp[3568:ef03] getSDP: --> v=0
o=- 1 1 IN IP4 0.0.0.0
s=RTSP Session
i=Jabsco Stream(JCO-jy9757acx1eve7nm-a104aea23c1e17bbc776656f5069bbf7)
c=IN IP4 218.204.223.237
t=0 0
a=range:npt=now-
a=control:*
m=video 0 RTP/AVP 96
b=AS:200
a=rtpmap:96 MP4V-ES/90000
a=fmtp:96 profile-level-id=1;config=000001b001000001b509000001010000012000844ea628582120a21f;decode_buf=115200
a=framerate:15
a=framesize:96 352-288
a=control:trackID=1
Sending request: SETUP rtsp://218.204.223.237:554/live/1/66251FC11353191F/e7ooqwcfbqjoo80j.sdp/trackID=1 RTSP/1.0
CSeq: 3
Transport: RTP/AVP/TCP;unicast;interleaved=0-1
User-Agent: LIVE555 Streaming Media v2010.04.09
Received SETUP response: RTSP/1.0 200 OK
Server: PVSS/0.0.1 (Build/20100101; Platform/Win32; Darwin; )
Cseq: 3
Session: 30185030182557
Date: Sun, 11 Sep 2011 13:41:27 GMT
Expires: Sun, 11 Sep 2011 13:41:27 GMT
Transport: RTP/AVP/TCP;unicast;interleaved=0-1
2011-09-11 21:41:28.495 rtsp[3568:ef03] RTP
2011-09-11 21:41:28.496 rtsp[3568:ef03] MP4V-ES
2011-09-11 21:41:28.497 rtsp[3568:ef03] video
2011-09-11 21:41:28.498 rtsp[3568:ef03] 0
2011-09-11 21:41:28.499 rtsp[3568:ef03] 0
Sending request: PLAY rtsp://218.204.223.237:554/live/1/66251FC11353191F/e7ooqwcfbqjoo80j.sdp/ RTSP/1.0
CSeq: 4
Session: 30185030182557
Range: npt=0.000-
User-Agent: LIVE555 Streaming Media v2010.04.09
Received PLAY response: RTSP/1.0 200 OK
Server: PVSS/0.0.1 (Build/20100101; Platform/Win32; Darwin; )
Cseq: 4
Session: 30185030182557
RTP-Info: url=rtsp://218.204.223.237:554/live/1/66251FC11353191F/e7ooqwcfbqjoo80j.sdp/trackID=1;seq=0;rtptime=0
2011-09-11 21:41:28.650 rtsp[3568:ef03] error: --> liveMedia4
2011-09-11 21:41:28.886 rtsp[3568:ef03] Packet size===>8782
[h264 @ 0x7859800]non-existing PPS 0 referenced
[h264 @ 0x7859800]decode_slice_header error
[h264 @ 0x7859800]no frame!
2011-09-11 21:41:28.886 rtsp[3568:ef03] Res value===>-1
2011-09-11 21:41:28.887 rtsp[3568:ef03] frame data===>107521264
2011-09-11 21:41:28.888 rtsp[3568:ef03] Failed to decode frame
2011-09-11 21:41:28.921 rtsp[3568:ef03] 2011-09-11 13:41:14 +0000
2011-09-11 21:41:28.922 rtsp[3568:ef03] Packet size===>1459
[h264 @ 0x688fc00]no frame!
2011-09-11 21:41:28.922 rtsp[3568:ef03] Res value===>-1
2011-09-11 21:41:28.923 rtsp[3568:ef03] frame data===>102427408
2011-09-11 21:41:28.923 rtsp[3568:ef03] Failed to decode frame
2011-09-11 21:41:28.951 rtsp[3568:ef03] 2011-09-11 13:41:14 +0000
2011-09-11 21:41:28.952 rtsp[3568:ef03] Packet size===>1258
2011-09-11 21:41:28.952 rtsp[3568:ef03] Res value===>-1
2011-09-11 21:41:28.953 rtsp[3568:ef03] frame data===>102426080
2011-09-11 21:41:28.953 rtsp[3568:ef03] Failed to decode frame
2011-09-11 21:41:28.976 rtsp[3568:ef03] 2011-09-11 13:41:14 +0000
2011-09-11 21:41:28.977 rtsp[3568:ef03] Packet size===>2731
Last message repeated 1 times
[h264 @ 0x705ce00]no frame!
2011-09-11 21:41:28.977 rtsp[3568:ef03] Res value===>-1
2011-09-11 21:41:28.978 rtsp[3568:ef03] frame data===>105438976
2011-09-11 21:41:28.979 rtsp[3568:ef03] Failed to decode frame
2011-09-11 21:41:29.002 rtsp[3568:ef03] 2011-09-11 13:41:14 +0000
2011-09-11 21:41:29.012 rtsp[3568:ef03] Packet size===>8782
[h264 @ 0x705ce00]non-existing PPS 0 referenced
[h264 @ 0x705ce00]decode_slice_header error
[h264 @ 0x705ce00]no frame!
2011-09-11 21:41:29.013 rtsp[3568:ef03] Res value===>-1
2011-09-11 21:41:29.014 rtsp[3568:ef03] frame data===>105438976
2011-09-11 21:41:29.014 rtsp[3568:ef03] Failed to decode frame
2011-09-11 21:41:29.043 rtsp[3568:ef03] 2011-09-11 13:41:15 +0000
2011-09-11 21:41:29.044 rtsp[3568:ef03] Packet size===>1459
[h264 @ 0xb04f000]no frame!
2011-09-11 21:41:29.044 rtsp[3568:ef03] Res value===>-1
2011-09-11 21:41:29.045 rtsp[3568:ef03] frame data===>178793376
2011-09-11 21:41:29.045 rtsp[3568:ef03] Failed to decode frame
2011-09-11 21:41:29.072 rtsp[3568:ef03] 2011-09-11 13:41:15 +0000
2011-09-11 21:41:29.073 rtsp[3568:ef03] Packet size===>1258
[h264 @ 0x705ce00]no frame!
2011-09-11 21:41:29.074 rtsp[3568:ef03] Res value===>-1
2011-09-11 21:41:29.074 rtsp[3568:ef03] frame data===>105438976
2011-09-11 21:41:29.075 rtsp[3568:ef03] Failed to decode frame
2011-09-11 21:41:29.099 rtsp[3568:ef03] 2011-09-11 13:41:15 +0000
2011-09-11 21:41:29.100 rtsp[3568:ef03] Packet size===>2731
2011-09-11 21:41:29.101 rtsp[3568:ef03] Res value===>-1
2011-09-11 21:41:29.101 rtsp[3568:ef03] frame data===>105438976
2011-09-11 21:41:29.102 rtsp[3568:ef03] Failed to decode frame
2011-09-11 21:41:29.125 rtsp[3568:ef03] 2011-09-11 13:41:15 +0000
2011-09-11 21:41:29.126 rtsp[3568:ef03] Packet size===>1224
Last message repeated 1 times -
How to convert multiple jpg images to MP4 format using FFmpeg ?
30 janvier 2024, par PDLAOZEI- 

-
I first used the FFmpeg command line to implement this function.

ffmpeg -framerate 1 -pattern_type glob -i "./image/*.jpg" -c:v libx264 -crf 25 -vf format=yuv420p -movflags +faststart test.mp4


-
Then I use FFmpeg's api to convert multiple jpg into MP4 format, the process is probably.








- 

- Find the AV_CODEC_ID_MPEG4 encoder.
- Turn on the encoder.
- Set video stream parameters.
- Open the output file.
- Write file header.
- Allocate image frame rate and buffer.
- Write each jpg image to the video (write in a loop).
7-1. read jpg image.
7-2. Find video stream information.
7-3. Decoded image frame.
7-4. Transcode to yuv420p.
7-5. Encode and write video frames.
- Finally, free memory.


















update the reproducible example


#include <iostream>
#include <vector>
#include <string>
#include <chrono>
#include <thread>

#include <filesystem>
#include <algorithm>
#include <iomanip>
#include <sys></sys>stat.h>

extern "C"
{
#include <libavcodec></libavcodec>avcodec.h>
#include <libavformat></libavformat>avformat.h>
#include <libswscale></libswscale>swscale.h>
#include <libavutil></libavutil>imgutils.h>
}

namespace fs = std::filesystem;

bool compareFilenames(const std::string &str1, const std::string &str2)
{
 //ToDo Sort
}

int main()
{
 
 fs::path folderPath = "" //replace your image foldePath

 std::vector imageFiles;
 for (const auto &entry : fs::directory_iterator(folderPath))
 {
 if (entry.is_regular_file() && entry.path().extension() == ".jpg")
 {
 imageFiles.push_back(entry.path());
 }
 }

 std::sort(imageFiles.begin(), imageFiles.end(), compareFilenames);

 std::string outputVideoFile = "output.mp4";

 AVFormatContext *formatContext = nullptr;
 AVCodecContext *codecContext = nullptr;
 AVStream *videoStream = nullptr;

 av_register_all();
 avformat_alloc_output_context2(&formatContext, nullptr, nullptr, outputVideoFile.c_str());


 AVCodec *codec = avcodec_find_encoder(AV_CODEC_ID_MPEG4);//AV_CODEC_ID_H264
 videoStream = avformat_new_stream(formatContext, codec);
 codecContext = avcodec_alloc_context3(codec);

 codecContext->codec_id = codec->id;
 codecContext->codec_type = AVMEDIA_TYPE_VIDEO;
 codecContext->pix_fmt = AV_PIX_FMT_YUV420P;
 codecContext->width = 1920;
 codecContext->height = 1080;
 codecContext->time_base = {1, 2}; 
 codecContext->bit_rate = 100000000;
 codecContext->gop_size = 1;

 avcodec_open2(codecContext, codec, nullptr);
 avcodec_parameters_from_context(videoStream->codecpar, codecContext);

 avio_open(&formatContext->pb, outputVideoFile.c_str(), AVIO_FLAG_WRITE);
 avformat_write_header(formatContext, NULL);

 AVFrame *frame = av_frame_alloc();

 std::vector imageBuffer(codecContext->width * codecContext->height * 3);
 AVPacket packet;

 for (const std::string &imageFile : imageFiles)
 {

 AVFormatContext *inputFormatContext = avformat_alloc_context();
 avformat_open_input(&inputFormatContext, imageFile.c_str(), nullptr, nullptr);

 avformat_find_stream_info(inputFormatContext, nullptr);

 AVCodec *inputCodec = nullptr;
 AVCodecContext *inputCodecContext = nullptr;
 int videoStreamIndex = -1;

 for (unsigned int i = 0; i < inputFormatContext->nb_streams; i++)
 {
 if (inputFormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
 {
 videoStreamIndex = i;
 inputCodec = avcodec_find_decoder(inputFormatContext->streams[i]->codecpar->codec_id);
 inputCodecContext = avcodec_alloc_context3(inputCodec);
 avcodec_parameters_to_context(inputCodecContext, inputFormatContext->streams[i]->codecpar);
 avcodec_open2(inputCodecContext, inputCodec, NULL);
 break;
 }
 }

 AVFrame *inputFrame = av_frame_alloc();
 while (av_read_frame(inputFormatContext, &packet) >= 0)
 {
 if (packet.stream_index == videoStreamIndex)
 {
 int response = avcodec_send_packet(inputCodecContext, &packet);

 while (response >= 0)
 {
 response = avcodec_receive_frame(inputCodecContext, inputFrame);
 if (response == AVERROR(EAGAIN) || response == AVERROR_EOF)
 {
 break;
 }
 else if (response < 0)
 {
 std::cerr << "Failed to receive frame from input decoder" << std::endl;
 break;
 }

 AVFrame *yuvFrame = av_frame_alloc();
 av_image_alloc(yuvFrame->data, yuvFrame->linesize, codecContext->width, codecContext->height, codecContext->pix_fmt, 1);

 SwsContext *yuvSwsContext = sws_getContext(inputFrame->width, inputFrame->height, AV_PIX_FMT_RGB24,
 codecContext->width, codecContext->height, codecContext->pix_fmt,
 0, nullptr, nullptr, nullptr);

 sws_scale(yuvSwsContext, inputFrame->data, inputFrame->linesize, 0, inputFrame->height,
 yuvFrame->data, yuvFrame->linesize);


 memcpy(imageBuffer.data(), yuvFrame->data[0], codecContext->width * codecContext->height);
 memcpy(imageBuffer.data() + codecContext->width * codecContext->height, yuvFrame->data[1], codecContext->width * codecContext->height / 4);
 memcpy(imageBuffer.data() + codecContext->width * codecContext->height * 5 / 4, yuvFrame->data[2], codecContext->width * codecContext->height / 4);

 frame->data[0] = imageBuffer.data();
 frame->data[1] = frame->data[0] + codecContext->width * codecContext->height;
 frame->data[2] = frame->data[1] + codecContext->width * codecContext->height / 4;
 frame->linesize[0] = codecContext->width;
 frame->linesize[1] = codecContext->width / 2;
 frame->linesize[2] = codecContext->width / 2;
 frame->width = codecContext->width;
 frame->height = codecContext->height;
 frame->format = codecContext->pix_fmt;
 frame->pts = av_rescale_q(videoStream->nb_frames, videoStream->time_base, videoStream->codec->time_base);

 av_init_packet(&packet);
 packet.data = nullptr;
 packet.size = 0;

 avcodec_send_frame(codecContext, frame);

 while (avcodec_receive_packet(codecContext, &packet) >= 0)
 {
 av_packet_rescale_ts(&packet, codecContext->time_base, videoStream->time_base);
 packet.stream_index = videoStream->index;

 av_write_frame(formatContext, &packet);
 av_packet_unref(&packet);
 }

 av_freep(&yuvFrame->data[0]);
 av_freep(&yuvFrame);
 sws_freeContext(yuvSwsContext);
 }
 }

 av_packet_unref(&packet);
 }

 av_frame_free(&inputFrame);
 avcodec_close(inputCodecContext);
 avformat_close_input(&inputFormatContext);
 }

 av_write_trailer(formatContext);

 av_frame_free(&frame);
 avcodec_close(codecContext);
 av_free(codecContext);
 avio_close(formatContext->pb);
 avformat_free_context(formatContext);

 return 0;
}


</iomanip></algorithm></filesystem></thread></chrono></string></vector></iostream>


But the encoding format is mpeg, which cannot be opened in the player included with windows, and the prompt is an unsupported format.


Although the vlc player can be opened and played normally, I need to play it normally on the player that comes with windows, because the output video will be played on the browser.


So I changed AV_CODEC_ID_MPEG4 to AV_CODEC_ID_H264, and the result is that although the file size of the output image is very large, only one picture is displayed during playback. I don't know what the problem is.


I was thinking about writing a new one, but I had no idea how to write a new one.
I would appreciate it if someone could write me an example.


-