
Recherche avancée
Médias (1)
-
Bug de détection d’ogg
22 mars 2013, par
Mis à jour : Avril 2013
Langue : français
Type : Video
Autres articles (42)
-
Demande de création d’un canal
12 mars 2010, parEn fonction de la configuration de la plateforme, l’utilisateur peu avoir à sa disposition deux méthodes différentes de demande de création de canal. La première est au moment de son inscription, la seconde, après son inscription en remplissant un formulaire de demande.
Les deux manières demandent les mêmes choses fonctionnent à peu près de la même manière, le futur utilisateur doit remplir une série de champ de formulaire permettant tout d’abord aux administrateurs d’avoir des informations quant à (...) -
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 -
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 (7943)
-
How can I pipe JPEG files into FFMPEG and create an RTSP, H.264 stream ?
25 janvier 2023, par Michael SchmidtI have an input RTSP stream that I would like to manipulate on a frame-by-frame basis using openCV. After these changes are applied, I'd like to create a separate RTSP stream from those frames. I'm piping the resulting JPEG images to FFMPEG via STDIN. I need the intermediate frame to be a JPEG.


In other words, I must conform to this pattern :
RTSP IN -> Create JPEG as input -> manipulation, JPEG out -> RTSP


The PROBLEM I'm trying to solve deals with a codec at this point. See the last few lines of FFMPEG's output error message.


Here is what I have :


def open_ffmpeg_stream_process():
 args = (
 "ffmpeg -re -stream_loop -1 "
 "-f jpeg_pipe "
 "-s 512x288 "
 "-i pipe:0 "
 "-c:v h264 "
 "-f rtsp "
 "rtsp://localhost:8100/out0"
 ).split()
 return subprocess.Popen(args, stdin=subprocess.PIPE)

video_source = cv2.VideoCapture('rtsp://localhost:9100/in0')

frame_cnt = 0
FRAME_SKIP = 30

ffmpeg_process = open_ffmpeg_stream_process()
while video_source.isOpened():

 frame_cnt += 1
 if frame_cnt % FRAME_SKIP:
 continue
 else:
 frame_cnt = 0

 _, frame = video_source.read()
 _, jpg = cv2.imencode('.jpg', frame)

 # Work on the JPEG occurs here, and the output will be a JPEG

 ffmpeg_process.stdin.write(jpg.astype(np.uint8).tobytes())

 if cv2.waitKey(1) & 0xFF == ord('q'):
 break

video_source.release()



Here is FFMPEG's output :


ffmpeg version 4.4.2-0ubuntu0.22.04.1 Copyright (c) 2000-2021 the FFmpeg developers
 built with gcc 11 (Ubuntu 11.2.0-19ubuntu1)
 configuration: ---- noisy configuration stuff ----
 libavutil 56. 70.100 / 56. 70.100
 libavcodec 58.134.100 / 58.134.100
 libavformat 58. 76.100 / 58. 76.100
 libavdevice 58. 13.100 / 58. 13.100
 libavfilter 7.110.100 / 7.110.100
 libswscale 5. 9.100 / 5. 9.100
 libswresample 3. 9.100 / 3. 9.100
 libpostproc 55. 9.100 / 55. 9.100
Input #0, jpeg_pipe, from 'pipe:0':
 Duration: N/A, bitrate: N/A
 Stream #0:0: Video: mjpeg, rgb24(bt470bg/unknown/unknown), 512x288, 25 fps, 25 tbr, 25 tbn, 25 tbc
Stream mapping:
 Stream #0:0 -> #0:0 (mjpeg (native) -> h264 (libx264))
[libx264 @ 0x562a1ffc5840] using SAR=1/1
[libx264 @ 0x562a1ffc5840] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x562a1ffc5840] profile High, level 3.1, 4:2:0, 8-bit
[libx264 @ 0x562a1ffc5840] 264 - core 163 r3060 5db6aa6 - H.264/MPEG-4 AVC codec - Copyleft 2003-2021 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=18 lookahead_threads=3 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
[tcp @ 0x562a20826c00] Connection to tcp://localhost:8100?timeout=0 failed: Connection refused
Could not write header for output file #0 (incorrect codec parameters ?): Connection refused
Error initializing output stream 0:0 -- 
Conversion failed!



How does one create an H.264, RTSP stream from a series of JPEG frames using FFMPEG.


Notes : The FFMPEG command/subproccess might need unrelated improvements, feel free to comment on my crappy code.


Edit : Oof, I just found out the FFMPEG command doesn't even work stand alone.


-
ffmpeg Live Streaming Error : av_interleaved_write_frame() : Broken pipe
5 octobre 2022, par KrishnakumarI am trying to stream video live using ffmpeg, Input is from a UDP Source. Most of the time it works fine, but I could see the following log lines and ffmpeg stop's the conversion/feed push to the rtmp server. Few log lines below for reference. Is this issue related to network on reaching the destination or source or something that i need to change in the ffmpeg command ?



Wed Jun 17 07:53:22 2020 av_interleaved_write_frame(): Broken pipe
Wed Jun 17 07:53:48 2020 Last message repeated 1 times
Wed Jun 17 07:53:48 2020 av_interleaved_write_frame(): End of file
Wed Jun 17 07:53:49 2020 Last message repeated 1 times
Wed Jun 17 07:53:49 2020 [flv @ 0x40c87c0] Failed to update header with correct duration.
Wed Jun 17 07:53:49 2020 [flv @ 0x40c87c0] Failed to update header with correct filesize.
Wed Jun 17 07:53:49 2020 Error writing trailer of rtmp://ipaddress:1935/rtmp/push/test1: Broken pipe
Wed Jun 17 07:53:49 2020 [flv @ 0x48fe140] Failed to update header with correct duration.
Wed Jun 17 07:53:49 2020 [flv @ 0x48fe140] Failed to update header with correct filesize.
Wed Jun 17 07:53:49 2020 Error writing trailer of rtmp://ipaddress:1935/rtmp/push/test2: Broken pipe
Wed Jun 17 07:53:49 2020 [flv @ 0x4ccb5c0] Failed to update header with correct duration.
Wed Jun 17 07:53:49 2020 [flv @ 0x4ccb5c0] Failed to update header with correct filesize.
Wed Jun 17 07:53:49 2020 Error writing trailer of rtmp://ipaddress:1935/rtmp/push/test3: End of file
Wed Jun 17 07:53:49 2020 [flv @ 0x4725840] Failed to update header with correct duration.
Wed Jun 17 07:53:49 2020 [flv @ 0x4725840] Failed to update header with correct filesize.
Wed Jun 17 07:53:49 2020 Error writing trailer of rtmp://ipaddress:1935/rtmp/push/test4: Broken pipe
Wed Jun 17 07:53:49 2020 video:10594389kB audio:678081kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Wed Jun 17 07:53:49 2020 [libx264 @ 0x410c540] frame I:12400 Avg QP:19.58 size: 11797
Wed Jun 17 07:53:49 2020 [libx264 @ 0x410c540] frame P:359585 Avg QP:23.19 size: 1317




Adding the ffmpeg command below :



ffmpeg -err_detect aggressive -fflags discardcorrupt -i udp://230.1.1.2:11000?fifo_size=5000000&overrun_nonfatal=1 -analyzeduration 25M -probesize 50M -threads 0 -vsync 1 -filter_complex [i:0x202]yadif,setdar=16/9[1out1];[i:0x202]yadif,setdar=16/9[1out2];[i:0x202]yadif,setdar=16/9[1out3];[i:0x202]yadif,setdar=16/9[1out4] -map [1out1] -map i:0x29e -c:v libx264 -x264-params nal-hrd=cbr -b:v 200k -maxrate 200k -bufsize 300k -r 15 -g 30 -profile:v baseline -level 3.0 -pix_fmt yuv420p -c:a libfdk_aac -b:a 32k -ac 2 -ar 48000 -sc_threshold 0 -s 256x144 -tune film -af aresample=async=1:min_hard_comp=0.100000:first_pts=0 -x264opts opencl -f flv rtmp://ipaddress:1935/rtmp/push/test1-map [1out2] -map i:0x29e -c:v libx264 -x264-params nal-hrd=cbr -b:v 500k -maxrate 500k -bufsize 750k -r 25 -g 50 -profile:v baseline -level 3.0 -pix_fmt yuv420p -c:a libfdk_aac -b:a 64k -ac 2 -ar 48000 -sc_threshold 0 -s 512x288 -tune film -af aresample=async=1:min_hard_comp=0.100000:first_pts=0 -x264opts opencl -f flv rtmp://ipaddress:1935/rtmp/push/test2 -map [1out3] -map i:0x29e -c:v libx264 -x264-params nal-hrd=cbr -b:v 1000k -maxrate 1000k -bufsize 1500k -r 25 -g 50 -profile:v main -level 3.0 -pix_fmt yuv420p -c:a libfdk_aac -b:a 64k -ac 2 -ar 48000 -sc_threshold 0 -s 1024x576 -tune film -af aresample=async=1:min_hard_comp=0.100000:first_pts=0 -x264opts opencl -f flv rtmp://ipaddress:1935/rtmp/push/test3 -map [1out4] -map i:0x29e -c:v libx264 -x264-params nal-hrd=cbr -b:v 1800k -maxrate 1800k -bufsize 2700k -r 25 -g 50 -profile:v main -level 3.1 -pix_fmt yuv420p -c:a libfdk_aac -b:a 64k -ac 2 -ar 48000 -sc_threshold 0 -s 1280x720 -tune film -af aresample=async=1:min_hard_comp=0.100000:first_pts=0 -x264opts opencl -f flv rtmp://ipaddress:1935/rtmp/push/test4



-
How to fix av_interleaved_write_frame() broken pipe error in php
31 mars, par Adekunle AdeyeyeI have an issue using ffmpeg to stream audio and parse to google cloud speech to text in PHP.


It returns this output.
I have tried delaying some part of the script, that did not solve it.
I have also checked for similar questions. however, they are mostly in python and none of the solutions actually work for this.


built with gcc 8 (GCC)
 cpudetect
 libavutil 56. 31.100 / 56. 31.100
 libavcodec 58. 54.100 / 58. 54.100
 libavformat 58. 29.100 / 58. 29.100
 libavdevice 58. 8.100 / 58. 8.100
 libavfilter 7. 57.100 / 7. 57.100
 libavresample 4. 0. 0 / 4. 0. 0
 libswscale 5. 5.100 / 5. 5.100
 libswresample 3. 5.100 / 3. 5.100
 libpostproc 55. 5.100 / 55. 5.100
Input #0, mp3, from 'https://npr-ice.streamguys1.com/live.mp3':
 Metadata:
 icy-br : 96
 icy-description : NPR Program Stream
 icy-genre : News and Talk
 icy-name : NPR Program Stream
 icy-pub : 0
 StreamTitle :
 Duration: N/A, start: 0.000000, bitrate: 96 kb/s
 Stream #0:0: Audio: mp3, 32000 Hz, stereo, fltp, 96 kb/s
Stream mapping:
 Stream #0:0 -> #0:0 (mp3 (mp3float) -> pcm_s16le (native))
Press [q] to stop, [?] for help
Output #0, s16le, to 'pipe:':
 Metadata:
 icy-br : 96
 icy-description : NPR Program Stream
 icy-genre : News and Talk
 icy-name : NPR Program Stream
 icy-pub : 0
 StreamTitle :
 encoder : Lavf58.29.100
 Stream #0:0: Audio: pcm_s16le, 16000 Hz, mono, s16, 256 kb/s
 Metadata:
 encoder : Lavc58.54.100 pcm_s16le
**av_interleaved_write_frame(): Broken pipe** 256.0kbits/s speed=1.02x
**Error writing trailer of pipe:: Broken pipe**
size= 54kB time=00:00:01.76 bitrate= 250.8kbits/s speed=0.465x
video:0kB audio:55kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Conversion failed!



this is my PHP code


require_once 'vendor/autoload.php';
 
 $projectId = "xxx-45512";
 putenv('GOOGLE_APPLICATION_CREDENTIALS=' . __DIR__ . '/xxx-45512-be3eb805f1d7.json');
 
 // Database connection
 $pdo = new PDO('mysql:host=localhost;dbname=', '', '');
 $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
 
 $url = "https://npr-ice.streamguys1.com/live.mp3";
 
 $ffmpegCmd = "ffmpeg -re -i $url -acodec pcm_s16le -ac 1 -ar 16000 -f s16le -";
 
 $fp = popen($ffmpegCmd, "r");
 if (!$fp) {
 die("Failed to open FFmpeg stream.");
 }
 sleep(5);

 try {
 $client = new SpeechClient(['transport' => 'grpc', 'credentials' => json_decode(file_get_contents(getenv('GOOGLE_APPLICATION_CREDENTIALS')), true)]);
 } catch (Exception $e) {
 echo 'Error: ' . $e->getMessage(); 
 exit;
 }
 
 $recognitionConfig = new RecognitionConfig([
 'auto_decoding_config' => new AutoDetectDecodingConfig(),
 'language_codes' => ['en-US'],
 'model' => 'long',
 ]);
 
 $streamingConfig = new StreamingRecognitionConfig([
 'config' => $recognitionConfig,
 ]);
 
 $configRequest = new StreamingRecognizeRequest([
 'recognizer' => "projects/$projectId/locations/global/recognizers/_",
 'streaming_config' => $streamingConfig,
 ]);
 
 
 function streamAudio($fp)
 {
 while (!feof($fp)) {
 yield fread($fp, 4096);
 }
 }
 
 $responses = $client->streamingRecognize([
 'requests' => (function () use ($configRequest, $fp) {
 yield $configRequest; // Send initial config
 foreach (streamAudio($fp) as $audioChunk) {
 yield new StreamingRecognizeRequest(['audio' => $audioChunk]);
 }
 })()]
 );
 
 // $responses = $speechClient->streamingRecognize();
 // $responses->writeAll([$request,]);
 
 foreach ($responses as $response) {
 foreach ($response->getResults() as $result) {
 $transcript = $result->getAlternatives()[0]->getTranscript();
 // echo "Transcript: $transcript\n";
 
 // Insert into the database
 $stmt = $pdo->prepare("INSERT INTO transcriptions (transcript) VALUES (:transcript)");
 $stmt->execute(['transcript' => $transcript]);
 }
 }
 
 
 pclose($fp);
 $client->close();



I'm not sure what the issue is at this time.


UPDATE


I've done some more debugging and i have gotten the error to clear and to stream actually starts.
However, I expect the audio to transcribe and update my database but instead I get this error when i close the stream




this is my updated code


$handle = popen($ffmpegCommand, "r");

 try {
 $client = new SpeechClient(['transport' => 'grpc', 'credentials' => json_decode(file_get_contents(getenv('GOOGLE_APPLICATION_CREDENTIALS')), true)]);
 } catch (Exception $e) {
 echo 'Error: ' . $e->getMessage(); 
 exit;
 }
 
 try {
 $recognitionConfig = (new RecognitionConfig())
 ->setAutoDecodingConfig(new AutoDetectDecodingConfig())
 ->setLanguageCodes(['en-US'], ['en-UK'])
 ->setModel('long');
 } catch (Exception $e) {
 echo 'Error: ' . $e->getMessage(); 
 exit;
 }
 
 try {
 $streamConfig = (new StreamingRecognitionConfig())
 ->setConfig($recognitionConfig);
 } catch (Exception $e) {
 echo 'Error: ' . $e->getMessage();
 exit;
 }
 try {
 $configRequest = (new StreamingRecognizeRequest())
 ->setRecognizer("projects/$projectId/locations/global/recognizers/_")
 ->setStreamingConfig($streamConfig);
 } catch (Exception $e) {
 echo 'Error: ' . $e->getMessage(); 
 exit;
 }
 
 $stream = $client->streamingRecognize();
 $stream->write($configRequest);
 
 mysqli_query($conn, "INSERT INTO transcriptions (transcript) VALUES ('bef')");
 
 while (!feof($handle)) {
 $chunk = fread($handle, 25600);
 // printf('chunk: ' . $chunk);
 if ($chunk !== false) {
 try {
 $request = (new StreamingRecognizeRequest())
 ->setAudio($chunk);
 $stream->write($request);
 } catch (Exception $e) {
 printf('Errorc: ' . $e->getMessage());
 }
 }
 }
 
 
 $insr = json_encode($stream);
 mysqli_query($conn, "INSERT INTO transcriptions (transcript) VALUES ('$insr')");
 
 foreach ($stream->read() as $response) {
 mysqli_query($conn, "INSERT INTO transcriptions (transcript) VALUES ('loop1')");
 foreach ($response->getResults() as $result) {
 mysqli_query($conn, "INSERT INTO transcriptions (transcript) VALUES ('loop2')");
 foreach ($result->getAlternatives() as $alternative) {
 $trans = $alternative->getTranscript();
 mysqli_query($conn, "INSERT INTO transcriptions (transcript) VALUES ('$trans')");
 }
 }
 }
 
 pclose($handle);
 $stream->close();
 $client->close();```