
Recherche avancée
Médias (1)
-
Rennes Emotion Map 2010-11
19 octobre 2011, par
Mis à jour : Juillet 2013
Langue : français
Type : Texte
Autres articles (82)
-
Contribute to a better visual interface
13 avril 2011MediaSPIP is based on a system of themes and templates. Templates define the placement of information on the page, and can be adapted to a wide range of uses. Themes define the overall graphic appearance of the site.
Anyone can submit a new graphic theme or template and make it available to the MediaSPIP community. -
Multilang : améliorer l’interface pour les blocs multilingues
18 février 2011, parMultilang est un plugin supplémentaire qui n’est pas activé par défaut lors de l’initialisation de MediaSPIP.
Après son activation, une préconfiguration est mise en place automatiquement par MediaSPIP init permettant à la nouvelle fonctionnalité d’être automatiquement opérationnelle. Il n’est donc pas obligatoire de passer par une étape de configuration pour cela. -
ANNEXE : Les plugins utilisés spécifiquement pour la ferme
5 mars 2010, parLe site central/maître de la ferme a besoin d’utiliser plusieurs plugins supplémentaires vis à vis des canaux pour son bon fonctionnement. le plugin Gestion de la mutualisation ; le plugin inscription3 pour gérer les inscriptions et les demandes de création d’instance de mutualisation dès l’inscription des utilisateurs ; le plugin verifier qui fournit une API de vérification des champs (utilisé par inscription3) ; le plugin champs extras v2 nécessité par inscription3 (...)
Sur d’autres sites (5268)
-
Freeze when writing ffmpeg execution result to io.Pipe
7 novembre 2023, par alexI am writing a wrapper to work with
exec.Cmd
to work withio.Pipe
. The wrapper is intended to simplify work with the file system, I want to convert a video, write the result of the conversion toio.Pipe
, read it in the goroutine and transfer it to make a preview of the new converted file. For this purpose I useFFmpeg
. But I've encountered a problem, when I start the test the execution just hangs and I can't get any result, but there are no errors, everything just hangs.

CmdRunner source code


type CmdRunner struct {
 commander Commander
 StdIn io.ReadCloser
 StdoutWriter io.WriteCloser
 StdErrWriter io.Writer
}

func (c *CmdRunner) RunByPipe(ctx context.Context) error {
 //done := make(chan error)
 name, args := c.commander.Command()
 cmd := exec.CommandContext(ctx, name, args...)

 if c.StdIn != nil {
 fmt.Print("RunByPipe STDIN\n")
 cmd.Stdin = c.StdIn
 }

 if c.StdoutWriter != nil {
 fmt.Print("RunByPipe STDOUT\n")
 cmd.Stdout = c.StdoutWriter
 }

 stderr := bytes.Buffer{}
 cmd.Stderr = &stderr

 if err := cmd.Start(); err != nil {
 return err
 }

 if err := cmd.Wait(); err != nil {
 return err
 }

 if stderr.String() != "" {
 return fmt.Errorf("want empty stderr, but got %s", stderr.String())
 }

 return nil
}




Unit test code


type TestCommander struct {
 name string
 args []string
}

func (c *TestCommander) SetCommand(name string, args []string) {
 c.name = name
 c.args = args
}

func (c *TestCommander) Command() (string, []string) {
 return c.name, c.args
}

func TestConvert(t *testing.T) {
 ctx := context.Background()
 filePath := "testdata/input_mp4.mp4"
 data, err := convertFile(filePath, ctx)
 outFile := "testdata/output_mp4.mp4"
 if err != nil {
 fmt.Print("ERR: ", err, "\n")
 }

 os.WriteFile(outFile, data, 0644)

}

func convertFile(filePath string, ctx context.Context) (bytes []byte, err error) {
 // Create a CmdRunner instance with your custom Commander.
 runner := &CmdRunner{}
 commander := &TestCommander{}
 args := []string{
 "-nostats",
 "-i", filePath,
 "-y",
 "-loglevel", "0",
 "-filter:v", "fps=30, crop=trunc(iw/2)*2:trunc(ih/2)*2",
 "-c:v", "libx264",
 "-c:a", "aac",
 "-pix_fmt", "yuv420p",
 "-movflags", "frag_keyframe+faststart",
 "-bufsize", "24M",
 "-maxrate", "12M",
 "-f", "mp4",
 "pipe:1",
 }

 commander.SetCommand("ffmpeg", args)
 runner.SetCommander(commander)
 outputPipeReader, outputPipeWriter := io.Pipe()
 runner.SetStdOutWriter(outputPipeWriter)

 wg := &sync.WaitGroup{}
 wg.Add(1)
 go func() {
 defer outputPipeReader.Close()
 defer wg.Done()

 // Read data from output pipe
 bytes, err = io.ReadAll(outputPipeReader)
 if err != nil {
 fmt.Print("\nReadAll err: ", err, "\n")
 }
 }()

 err = runner.RunByPipe(ctx)
 if err != nil {
 fmt.Print("\nRunByPipe err: ", err, "\n")
 return
 }

 wg.Wait()

 return
}



I can't find a clue as to what might have gone wrong.
P.S : But if I remove
if err := cmd.Wait(); err != nil { return err }
Then the problem goes away, but there will be no data, because nothing is written toio.Pipe
.Why ?

-
How to create a video from svg files using a pipe with ffmpeg ?
5 juillet 2023, par Max Chr.I want to create a video from svg graphic stored in a database. My procedure would be the following to archive that :


- 

- connect to database
- create ffmpeg command which takes a pipe as input
- spawn the ffmpeg child process
- Wait for the output of the process.










start another thread :
For all svg files do :


- 

- download the svg from the database into a byte buffer
- write the byte buffer to stdin of the ffmpeg child process






When running my code I encounter a problem when piping the svg files to ffmpeg.
Another possibility would be to download all the svg files to a temp directory and then using ffmpeg, but I want to avoid this.


I used
ffmpeg -f image2pipe -c:v svg -i - -c:v libx264 -y Downloads/out.mp4
. But then ffmpeg gives me the following error :

[image2pipe @ 0x562ebd74c300] Could not find codec parameters for stream 0 (Video: svg (librsvg), none): unspecified size
Consider increasing the value for the 'analyzeduration' (0) and 'probesize' (5000000) options



I found out that there's a
svg_pipe
format in ffmpeg, so I tried that - without success, same error.

Do you have any ideas how to make this work ?


-
Broken Pipe Error [Errno 32] after saving more than ten PNG images using PIL
6 septembre 2019, par BlinkoI am using the ffmpeg pipeline to compress a series of png frames and output an mp4 video, while also saving each frame as a separate png image. The problem is that every time I run the script, I get a Broken Pipe error on the 11th image :
Traceback (most recent call last):
File "/anaconda3/envs/tensorflow/lib/python3.6/site-packages/PIL/ImageFile.py", line 487, in _save
fh = fp.fileno()
AttributeError: '_idat' object has no attribute 'fileno'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "gen_clip.py", line 173, in <module>
main()
File "gen_clip.py", line 167, in main
ts_pos = (0,frame.samplesperbeam-50)
File "/Users/Amanda/Desktop/data/pyARIS.py", line 1028, in make_video
im.save(pipe.stdin, 'PNG')
File "/anaconda3/envs/tensorflow/lib/python3.6/site-packages/PIL/Image.py", line 1994, in save
save_handler(self, fp, filename)
File "/anaconda3/envs/tensorflow/lib/python3.6/site-packages/PIL/PngImagePlugin.py", line 868, in _save
[("zip", (0, 0)+im.size, 0, rawmode)])
File "/anaconda3/envs/tensorflow/lib/python3.6/site-packages/PIL/ImageFile.py", line 502, in _save
fp.write(d)
File "/anaconda3/envs/tensorflow/lib/python3.6/site-packages/PIL/PngImagePlugin.py", line 730, in write
self.chunk(self.fp, b"IDAT", data)
File "/anaconda3/envs/tensorflow/lib/python3.6/site-packages/PIL/PngImagePlugin.py", line 717, in putchunk
fp.write(data)
BrokenPipeError: [Errno 32] Broken pipe
</module>I am not too familiar with PIL or ffmpeg, so I am not sure whether it’s a problem with the pipe parameters that I am passing in or something to do with the code itself. No matter what the starting frame number is, the error always appears after 10 images are saved.
Here is the array of pipe parameters I’m sending to the command prompt :
command = ['ffmpeg',
'-y',
'-f', 'image2pipe',
'-vcodec', 'png',
'-r', '1',
'-r', str(fps), # frames per second
'-i', '-', # The input comes from a pipe
'-an', # Tells FFMPEG not to expect any audio
'-vcodec', 'mpeg4',
'-b:v', '5000k',
'../'+filename+"/"+filename+".mp4",
'-hide_banner',
'-loglevel', 'panic']This is the loop that generates and saves each image :
for i in tqdm.tqdm(range(start_frame, end_frame)):
frame = FrameRead(data, i)
frame_image = np.zeros([ydim, xdim], dtype=np.uint8)
frame_image[image_write_rows, image_write_cols] = frame.frame_data[sample_read_rows, sample_read_cols]
all_frame_data.append(frame.frame_data)
im = Image.fromarray(cm(frame_image, bytes=True))
if timestamp == True:
ts = str(datetime.datetime.fromtimestamp(frame.sonartimestamp/1000000, pytz.timezone('UTC')).strftime('%Y-%m-%d %H:%M:%S'))
text = "%s\n%d" % (ts, i)
draw = ImageDraw.Draw(im)
draw.text(ts_pos,text,font=font, fill = 'white')
im.save(directory+filename+'/frames/'+str(i)+'_'+str(frame.sonartimestamp)+'_'+filename+'.png' , "PNG")
im.save(pipe.stdin, 'PNG')
j += 1I am running this on MacOS, Python 3.6. Help on the cause of the error and/or possible solutions will be greatly appreciated !