Newest 'ffmpeg' Questions - Stack Overflow

http://stackoverflow.com/questions/tagged/ffmpeg

Les articles publiés sur le site

  • How to fix av_interleaved_write_frame() broken pipe error in php

    31 mars, par Adekunle Adeyeye

    I 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. Please assist, thanks!

  • I Need Help Making Our Driver Station Video Feed Faster [closed]

    30 mars, par Joshua Green

    I am currently using FFmpeg on a Raspberry Pi 4 Model B using an ArduCam UC-844 Rev. B as the camera. We do not need any audio and I don't care about the quality of the video. All we need is for the stream to be as fast as possible. The video from the camera is being streamed to the driver station via FFmpeg and being picked up on the driver station via FFplay. Right now we are getting a delay that we wish could go away or be significantly shortened. These are the commands we are using.

    • Raspberry Pi: ffmpeg -i /dev/video0 -c:v libx264 -crf 45 -maxrate 1M -bufsize 1.2M -preset ultrafast -tune zerolatency -filter:v fps=30 -f mpegts -omit_video_pes_length 0 udp://10.2.33.5:554

    • Driver Station: ffplay -fflags nobuffer -flags low_delay -probesize 32 -analyzeduration 0 -f mpegts -vf setpts=0 udp://10.2.33.5:554

  • Restream with FFmpeg

    30 mars, par boyuna1720

    I have iptv playlist file with inside VODs and Channel links. I want to restream it from my server becouse provider allows only one user to watch. When i am using Nginx with RTMP and FFmpeG i am getting this error. please tell me if anyone can help to fix this issue.

    ffmpeg -re -i "http://excel90095.cdn-akm.me:80/23a9a158d8d8/2dd736a985/325973" -c:v copy -c:a aac -f flv "rtmp://localhost/live/test"

    enter image description here

  • I Need Help Making Our FIRST Robotics Competition Driver Station Video Feed Faster [closed]

    30 mars, par Joshua Green

    I am currently using FFmpeg on a Raspberry Pi 4 Model B using an ArduCam UC-844 Rev. B as the camera. We do not need any audio and I don't care about the quality of the video. All we need is for the stream to be as fast as possible. The video from the camera is being streamed to the driver station via FFmpeg and being picked up on the driver station via FFplay. Right now we are getting a delay that we wish could go away or be significantly shortened. These are the commands we are using.

    • Raspberry Pi: ffmpeg -i /dev/video0 -c:v libx264 -crf 45 -maxrate 1M -bufsize 1.2M -preset ultrafast -tune zerolatency -filter:v fps=30 -f mpegts -omit_video_pes_length 0 udp://10.2.33.5:554

    • Driver Station: ffplay -fflags nobuffer -flags low_delay -probesize 32 -analyzeduration 0 -f mpegts -vf setpts=0 udp://10.2.33.5:554

  • ffmpeg produces video I cannot load on latest Safari on iOS

    30 mars, par Michael Heuberger

    When I encode two videos (mp4 and webm) with these ffmpeg parameters (based on images), I cannot play the mp4 it produces on latest Safari (inside a tag) inside my iPhone 6s using the latest iOS too:

    ffmpeg 
    -framerate 15.2 
    -f image2 
    -thread_queue_size 64 
    -i /home/michael-heuberger/abcd/frames/%d.webp 
    -y 
    -an 
    -vcodec libx264 
    -vf scale=trunc(iw/2)*2:trunc(ih/2)*2 
    -crf 16 
    -preset fast 
    -profile:v baseline 
    -pix_fmt yuv420p 
    -movflags +faststart 
    /home/michael-heuberger/abcd/videomail_good.mp4 
    -vcodec libvpx 
    -vf scale=trunc(iw/2)*2:trunc(ih/2)*2 
    -crf 8 
    -deadline good 
    -cpu-used 1 
    -pix_fmt yuv420p 
    -movflags +faststart /home/michael-heuberger/abcd/videomail_good.webm
    

    I think the above parameters should be solid. I am adding baseline and yuv420p, yet no luck on Safari 9. Why?

    And here is the whole ffmpeg output (just ignore the paths to the images/videos):

    ffmpeg stdout: ffmpeg version 2.7.6-0ubuntu0.15.10.1 Copyright (c) 2000-2016 the FFmpeg developers
      built with gcc 5.2.1 (Ubuntu 5.2.1-22ubuntu2) 20151010
      configuration: --prefix=/usr --extra-version=0ubuntu0.15.10.1 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --enable-shared --disable-stripping --enable-avresample --enable-avisynth --enable-frei0r --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-openal --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libxvid --enable-libzvbi --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-libssh --enable-libsoxr --enable-libx264 --enable-libopencv --enable-libx265
      WARNING: library configuration mismatch
      avcodec     configuration: --prefix=/usr --extra-version=0ubuntu0.15.10.1 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --enable-shared --disable-stripping --enable-avresample --enable-avisynth --enable-frei0r --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-openal --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libxvid --enable-libzvbi --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-libssh --enable-libsoxr --enable-libx264 --enable-libopencv --enable-libx265 --enable-version3 --disable-doc --disable-programs --disable-avdevice --disable-avfilter --disable-avformat --disable-avresample --disable-postproc --disable-swscale --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libvo_aacenc --enable-libvo_amrwbenc
      libavutil      54. 27.100 / 54. 27.100
      libavcodec     56. 41.100 / 56. 41.100
      libavformat    56. 36.100 / 56. 36.100
      libavdevice    56.  4.100 / 56.  4.100
      libavfilter     5. 16.101 /  5. 16.101
      libavresample   2.  1.  0 /  2.  1.  0
      libswscale      3.  1.101 /  3.  1.101
      libswresample   1.  2.100 /  1.  2.100
      libpostproc    53.  3.100 / 53.  3.100
    Input #0, image2, from '/home/michael-heuberger/binarykitchen/code/videomail.io/var/local/tmp/clients/videomail.io/11e5-f576-676eaa40-b0ac-89a86db14ea0/frames/%d.webp':
      Duration: 00:00:00.59, start: 0.000000, bitrate: N/A
        Stream #0:0: Video: webp, yuv420p(tv, bt470bg/unknown/unknown), 400x300, 15.17 fps, 15.20 tbr, 15.20 tbn, 15.20 tbc
    [libx264 @ 0xfc2760] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2
    [libx264 @ 0xfc2760] profile Constrained Baseline, level 2.1
    [libx264 @ 0xfc2760] 264 - core 146 r2555 0c21480 - H.264/MPEG-4 AVC codec - Copyleft 2003-2015 - http://www.videolan.org/x264.html - options: cabac=0 ref=2 deblock=1:0:0 analyse=0x1:0x111 me=hex subme=6 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=250 keyint_min=15 scenecut=40 intra_refresh=0 rc_lookahead=30 rc=crf mbtree=1 crf=16.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
    [libvpx @ 0xfc5da0] v1.4.0
    Output #0, mp4, to '/home/michael-heuberger/binarykitchen/code/videomail.io/var/local/uploads/videomail.io/videomail/11e5/f5/76/11e5-f576-676eaa40-b0ac-89a86db14ea0/videomail_good.mp4':
      Metadata:
        encoder         : Lavf56.36.100
        Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 400x300, q=-1--1, 15.20 fps, 19456 tbn, 15.20 tbc
        Metadata:
          encoder         : Lavc56.41.100 libx264
    Output #1, webm, to '/home/michael-heuberger/binarykitchen/code/videomail.io/var/local/uploads/videomail.io/videomail/11e5/f5/76/11e5-f576-676eaa40-b0ac-89a86db14ea0/videomail_good.webm':
      Metadata:
        encoder         : Lavf56.36.100
        Stream #1:0: Video: vp8 (libvpx), yuv420p, 400x300, q=-1--1, 200 kb/s, 15.20 fps, 1k tbn, 15.20 tbc
        Metadata:
          encoder         : Lavc56.41.100 libvpx
    Stream mapping:
      Stream #0:0 -> #0:0 (webp (native) -> h264 (libx264))
      Stream #0:0 -> #1:0 (webp (native) -> vp8 (libvpx))
    Press [q] to stop, [?] for help
    [mp4 @ 0xfc16c0] Starting second pass: moving the moov atom to the beginning of the file
    frame=    9 fps=0.0 q=-1.0 Lq=0.0 size=      62kB time=00:00:00.59 bitrate= 856.1kbits/s    
    video:82kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
    [libx264 @ 0xfc2760] frame I:1     Avg QP:15.45  size: 10341
    [libx264 @ 0xfc2760] frame P:8     Avg QP:15.95  size:  6442
    [libx264 @ 0xfc2760] mb I  I16..4: 17.1%  0.0% 82.9%
    [libx264 @ 0xfc2760] mb P  I16..4:  6.8%  0.0% 11.3%  P16..4: 36.7% 31.6% 10.8%  0.0%  0.0%    skip: 2.8%
    [libx264 @ 0xfc2760] coded y,uvDC,uvAC intra: 67.5% 60.4% 43.0% inter: 60.5% 68.4% 5.4%
    [libx264 @ 0xfc2760] i16 v,h,dc,p: 32% 29% 21% 18%
    [libx264 @ 0xfc2760] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 32% 23% 20%  3%  4%  6%  5%  4%  3%
    [libx264 @ 0xfc2760] i8c dc,h,v,p: 60% 21% 14%  5%
    [libx264 @ 0xfc2760] ref P L0: 59.3% 40.7%
    [libx264 @ 0xfc2760] kb/s:836.04
    

    This makes it difficult for me to play videomails recorded on www.videomail.io on iOS devices.

    Am I missing something here? Already did lots of research and tried various combinations, no luck.

    If you want to reproduce that, it's easy: just record a video on www.videomail.io and after that, copy the link of the recorded video page to your iPhone or just download it for local investigation.