
Recherche avancée
Autres articles (58)
-
Submit bugs and patches
13 avril 2011Unfortunately a software is never perfect.
If you think you have found a bug, report it using our ticket system. Please to help us to fix it by providing the following information : the browser you are using, including the exact version as precise an explanation as possible of the problem if possible, the steps taken resulting in the problem a link to the site / page in question
If you think you have solved the bug, fill in a ticket and attach to it a corrective patch.
You may also (...) -
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 -
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
Sur d’autres sites (14162)
-
FFMPEG - infinite file video stream to RTMP server
5 août 2022, par samoht9277I'm trying to create an infinite video stream that I can push to a local RTMP server.


I believe it's worth mentioning that I'm not very good with
ffmpeg
, I started using it some weeks ago.

Here is a similat question, but it doesn't fully answer what I need.


What I tried


At my first attempt, I made a bash script that spawned a new
ffmpeg
instance for each video I was trying to stream. I noticed that that the few seconds that takes to spawn the new instance interrupts the stream.

After I noticed this problem, I decided to google some kind of queue system, and I found that
ffmpeg
has a concat function, that reads a file with a custom syntax and queues it.

So I made a script that lists the files in the directory where I store all my videos, modifies the output with
sed
, shuffles it (so the episodes are random), and then it redirects the output to aplaylist.txt


find /mnt/episode/ -print | sed '/**.mp4/!d' | sed "s/^/file '/; s/$/'/" | shuf > playlist.txt



playlist.txt


example :


...
file '/mnt/episode/9/1.mp4'
file '/mnt/episode/8/4.mp4'
file '/mnt/episode/5/11.mp4'
file '/mnt/episode/7/15.mp4'
...



This creates 2 problems :


- 

- For some reason, while using the playlist/queue method, when it finishes a video... it takes like 30 seconds to switch to the next video.




ffmpeg -f concat -safe 0 -i playlist.txt -f v4l2 /dev/video0



(simplified command, using /dev/video0 device for testing purposes)


ffmpeg
does output something after the first video, but i'm not quite sure what it means.

[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55c8abc1b900] st: 1 edit list: 1 Missing key frame while searching for timestamp: 0
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55c8abc1b900] st: 1 edit list 1 Cannot find an index entry before timestamp: 0.



- 

- Once the playlist finishes, the stream is over. I could run the script that generates the playlist again, but that would mean that the stream cuts, which I don't want.





What I want


I need a way to pick a random file, stream it normally via RTMP and once it finished, automatically pick another one without interrupting the streaming, and keep doing this until I decide to turn it off.


This is the directory format :


episodes
│
├── 1
│   ├── 1.mp4
│   ├── 2.mp4
│   ├── 3.mp4
│ ...
├── 2
│   ├── 1.mp4
│   ├── 2.mp4
│   ├── 3.mp4
│ ...
├── 3
│   ├── 1.mp4
│   ├── 2.mp4
│   ├── 3.mp4
│ ...
├── 4
│   ├── 1.mp4
│   ├── 2.mp4
│   ├── 3.mp4
│ ...
├── 5
│   ├── 1.mp4
│   ├── 2.mp4
│   ├── 3.mp4
│ ...
├── 6
│   ├── 1.mp4
│   ├── 2.mp4
│   ├── 3.mp4
│ ...
├── 7
│   ├── 1.mp4
│   ├── 2.mp4
│   ├── 3.mp4
│ ...
├── 8
│   ├── 1.mp4
│   ├── 2.mp4
│   ├── 3.mp4
│ ...
└── 9
 ├── 1.mp4
 ├── 2.mp4
 ├── 3.mp4
 ...



Gladly appreciate some help here. I tried to make the problem as clear as possible.


Thanks <3


-
Error issuing complex shell command in python via subprocess
4 juillet 2018, par user16171I’ve converted about 100 video tapes and now have 100 folders full of .dv files (each folder’s name is a date). In each folder, I want to combine all of the .dv files into one x265 mp4. I have figured out the ffmpeg command to do this, and I’ve written a simple Python script to traverse the folder hierarchy and print out the ffmpeg command to do each folder’s conversion. I’d like to set it up to just run each folder in series - it will take about a week to do the entire conversion, leaving me with about 5GB of video to use/post, etc. vs the 1.5TB of raw .dv files.
The shell command looks like this :
ffmpeg -f concat -i <(for f in FULL_PATH_TO_FILES/*.dv; do echo "file '$f'"; done) \
-c:v libx265 -crf 28 -c:a aac -b:a 128k \
-strict -2 FULL_PATH_TO_FILES/FOLDERNAME.mp4I can run that as a shell command, and it works fine. I could use the python script to generate the 100 commands and just copy and paste them into my shell one at a time. But I’d rather just have them run in series.
I’ve tried various incarnations of os.system and subprocess.call or subprocess.Popen, and they all error.
I build up the command and issue subprocess.call(command), which gives this error :
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 522, in call
return Popen(*popenargs, **kwargs).wait()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 710, in init
errread, errwrite)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1335, in _execute_child
raise child_exception
OSError : [Errno 2] No such file or directoryI’ve also tried building up the command, as described in many of the other threads I’ve read, but it does not work, and I assume it’s because of the for-loop I have in the shell command.
So, what’s the best way to do this ? Obviously, a shell-jockey could just tell me how to do this via the shell, but I’m more comfortable using Python to traverse the directories and build up the ffmpeg command.
For what it’s worth, here is the whole script :
import os
import subprocess
t1 = "ffmpeg -f concat -i <(for f in "
t2 = "/*.dv; do echo \"file '$f'\"; done) -c:v libx265 -crf 28 -c:a aac -b:a 128k -strict -2 "
t3 = ".mp4"
rootDir = ROOTDIR
for dirName, subdirList, fileList in os.walk(rootDir):
S = dirName.split('/')
if S[-1] == "Media":
moviename = S[-2].split(".")[0] # e.g. "19991128_Thanksgiving"
command = t1 + dirName + t2 + dirName + "/" + moviename + t3
if sum([".mp4" in fname for fname in fileList]) == 0: # don't bother if there is already a mp4 file in the folder
cmd_list = [t1,dirName,t2,dirName,"/",moviename,t3]
print command
print
print
subprocess.call(command) -
Exception thrown at 0x00007FFC0B57BCEF (swscale-6.dll) in App.exe : 0xC0000005 : Access violation reading location 0xFFFFFFFFFFFFFFFF
9 novembre 2023, par JIUN-YUTrying to play a video using FFmpeg on visual studio 2022 on windows 10.
Exception is thrown at sws_scale in the code. Don't know why this is occurred.
It is worth noting that this error sometimes occurs when reading the camera and sometimes it does not.


here is my code


bool CalibrationPanel::video_reader_read_frame(VReaderState* state, cv::Mat cvimg)
{
 // Unpack members of state
 auto& width = state->width;
 auto& height = state->height;
 auto& av_format_ctx = state->av_format_ctx;
 auto& av_codec_ctx = state->av_codec_ctx;
 auto& video_stream_index = state->video_stream_index;
 auto& av_frame = state->av_frame;
 auto& av_packet = state->av_packet;
 auto& sws_scaler_ctx = state->sws_scaler_ctx;


 // Decode one frame
 int response;
 while (av_read_frame(av_format_ctx, av_packet) >= 0)
 {
 if (av_packet->stream_index != video_stream_index)
 {
 av_packet_unref(av_packet);
 continue;
 }

 response = avcodec_send_packet(av_codec_ctx, av_packet);
 if (response < 0)
 {
 char errStr[256] = {0};
 av_strerror(response, errStr, sizeof(errStr));
 printf("Failed to decode packet: %s\n", errStr);
 return false;
 }

 response = avcodec_receive_frame(av_codec_ctx, av_frame);
 if (response == AVERROR(EAGAIN) || response == AVERROR_EOF)
 {
 av_packet_unref(av_packet);
 continue;
 }
 else if (response < 0)
 {
 char errStr[256] = {0};
 av_strerror(response, errStr, sizeof(errStr));
 printf("Failed to decode packet: %s\n", errStr);
 return false;
 }

 av_packet_unref(av_packet);
 break;
 }
 int64_t* pts = &ppts;
 *pts = av_frame->pts;

 // Set up sws scaler
 if (!sws_scaler_ctx)
 {
 sws_scaler_ctx = sws_getContext(width, height, av_codec_ctx->pix_fmt,
 width, height, AV_PIX_FMT_BGR24,
 SWS_BILINEAR, NULL, NULL, NULL);
 if (!sws_scaler_ctx)
 {
 printf("Couldn't initialize sw scaler\n");
 return false;
 }
 }


 // Creating an image space to hold YUV images
 AVFrame* frameYUV = av_frame_alloc();
 auto* out_buffer = (unsigned char*)av_malloc(av_image_get_buffer_size(AV_PIX_FMT_BGR24, width, height, 1));
 av_image_fill_arrays(frameYUV->data, frameYUV->linesize, (const uint8_t*)out_buffer, AV_PIX_FMT_BGR24, width, height, 1);

 uint8_t* dest[4] = {cvimg.data, NULL, NULL, NULL};
 sws_scale(sws_scaler_ctx, av_frame->data, av_frame->linesize, 0, av_frame->height, dest, frameYUV->linesize);

 return true;
}



fixed this bug, so it's not luck that makes the camera turn on every time.