Sound doesn't recording if running FFMPEG as other user











up vote
0
down vote

favorite












Works:



I'm trying to record video from my Logitech webcam and sound from the headset. I can record it without a problem from the terminal using the following logged in as "myuser":



/usr/bin/ffmpeg -y -video_size 320x240 -framerate 30 -f v4l2 -i $videoSource -f pulse -ac 2 -i $audioSource -t 00:00:$duration -vcodec h264 -strict -2 /var/www/html/tmp/temp.mp4 2>/var/www/html/log/ffmpeg.$currentDate.log


Doesn't work



But, if I try to run it through PHP exec() in my /var/www/html folder (this is owned by www-data) it still runs, but the audio is missing.



shell_exec("sudo -u myuser /usr/bin/ffmpeg -y -video_size 320x240 -framerate 30 -f v4l2 -i $videoSource -f pulse -ac 2 -i $audioSource -t 00:00:$duration -vcodec h264 -strict -2 /var/www/html/tmp/temp.mp4 2>/var/www/html/log/ffmpeg.$currentDate.log")


Even from the terminal, It doesn't record sound if I use the sudo -u myuser I already added the users to audio, pulse and pulse-access groups.



I have the same result if I switch pulse to alsa



Here is my log:



            ffmpeg version N-92489-g277fd9c Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.10) 20160609
configuration: --prefix=/home/myuser/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/home/myuser/ffmpeg_build/include --extra-ldflags=-L/home/myuser/ffmpeg_build/lib --extra-libs='-lpthread -lm' --bindir=/home/myuser/bin --enable-gpl --enable-libaom --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --disable-libaom --enable-libpulse --enable-nonfree
libavutil 56. 23.101 / 56. 23.101
libavcodec 58. 39.100 / 58. 39.100
libavformat 58. 22.100 / 58. 22.100
libavdevice 58. 6.100 / 58. 6.100
libavfilter 7. 45.100 / 7. 45.100
libswscale 5. 4.100 / 5. 4.100
libswresample 3. 4.100 / 3. 4.100
libpostproc 55. 4.100 / 55. 4.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/var/www/html/ready/recorded_20181122091147_preview.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.22.100
Duration: 00:00:30.02, start: 0.000000, bitrate: 241 kb/s
Stream #0:0(und): Video: h264 (High 4:2:2) (avc1 / 0x31637661), yuv422p, 320x240, 105 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
handler_name : SoundHandler
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> mjpeg (native))
Press [q] to stop, [?] for help
[swscaler @ 0x22ccc00] deprecated pixel format used, make sure you did set range correctly
Output #0, image2, to '/var/www/html/ready/recorded_20181122091147_preview.jpg':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.22.100
Stream #0:0(und): Video: mjpeg, yuvj422p(pc), 320x240, q=2-31, 200 kb/s, 30 fps, 30 tbn, 30 tbc (default)
Metadata:
handler_name : VideoHandler
encoder : Lavc58.39.100 mjpeg
Side data:
cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
frame= 1 fps=0.0 q=2.1 Lsize=N/A time=00:00:00.03 bitrate=N/A speed=2.48x
video:4kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown









share|improve this question


























    up vote
    0
    down vote

    favorite












    Works:



    I'm trying to record video from my Logitech webcam and sound from the headset. I can record it without a problem from the terminal using the following logged in as "myuser":



    /usr/bin/ffmpeg -y -video_size 320x240 -framerate 30 -f v4l2 -i $videoSource -f pulse -ac 2 -i $audioSource -t 00:00:$duration -vcodec h264 -strict -2 /var/www/html/tmp/temp.mp4 2>/var/www/html/log/ffmpeg.$currentDate.log


    Doesn't work



    But, if I try to run it through PHP exec() in my /var/www/html folder (this is owned by www-data) it still runs, but the audio is missing.



    shell_exec("sudo -u myuser /usr/bin/ffmpeg -y -video_size 320x240 -framerate 30 -f v4l2 -i $videoSource -f pulse -ac 2 -i $audioSource -t 00:00:$duration -vcodec h264 -strict -2 /var/www/html/tmp/temp.mp4 2>/var/www/html/log/ffmpeg.$currentDate.log")


    Even from the terminal, It doesn't record sound if I use the sudo -u myuser I already added the users to audio, pulse and pulse-access groups.



    I have the same result if I switch pulse to alsa



    Here is my log:



                ffmpeg version N-92489-g277fd9c Copyright (c) 2000-2018 the FFmpeg developers
    built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.10) 20160609
    configuration: --prefix=/home/myuser/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/home/myuser/ffmpeg_build/include --extra-ldflags=-L/home/myuser/ffmpeg_build/lib --extra-libs='-lpthread -lm' --bindir=/home/myuser/bin --enable-gpl --enable-libaom --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --disable-libaom --enable-libpulse --enable-nonfree
    libavutil 56. 23.101 / 56. 23.101
    libavcodec 58. 39.100 / 58. 39.100
    libavformat 58. 22.100 / 58. 22.100
    libavdevice 58. 6.100 / 58. 6.100
    libavfilter 7. 45.100 / 7. 45.100
    libswscale 5. 4.100 / 5. 4.100
    libswresample 3. 4.100 / 3. 4.100
    libpostproc 55. 4.100 / 55. 4.100
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/var/www/html/ready/recorded_20181122091147_preview.mp4':
    Metadata:
    major_brand : isom
    minor_version : 512
    compatible_brands: isomiso2avc1mp41
    encoder : Lavf58.22.100
    Duration: 00:00:30.02, start: 0.000000, bitrate: 241 kb/s
    Stream #0:0(und): Video: h264 (High 4:2:2) (avc1 / 0x31637661), yuv422p, 320x240, 105 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
    Metadata:
    handler_name : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
    handler_name : SoundHandler
    Stream mapping:
    Stream #0:0 -> #0:0 (h264 (native) -> mjpeg (native))
    Press [q] to stop, [?] for help
    [swscaler @ 0x22ccc00] deprecated pixel format used, make sure you did set range correctly
    Output #0, image2, to '/var/www/html/ready/recorded_20181122091147_preview.jpg':
    Metadata:
    major_brand : isom
    minor_version : 512
    compatible_brands: isomiso2avc1mp41
    encoder : Lavf58.22.100
    Stream #0:0(und): Video: mjpeg, yuvj422p(pc), 320x240, q=2-31, 200 kb/s, 30 fps, 30 tbn, 30 tbc (default)
    Metadata:
    handler_name : VideoHandler
    encoder : Lavc58.39.100 mjpeg
    Side data:
    cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
    frame= 1 fps=0.0 q=2.1 Lsize=N/A time=00:00:00.03 bitrate=N/A speed=2.48x
    video:4kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown









    share|improve this question
























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      Works:



      I'm trying to record video from my Logitech webcam and sound from the headset. I can record it without a problem from the terminal using the following logged in as "myuser":



      /usr/bin/ffmpeg -y -video_size 320x240 -framerate 30 -f v4l2 -i $videoSource -f pulse -ac 2 -i $audioSource -t 00:00:$duration -vcodec h264 -strict -2 /var/www/html/tmp/temp.mp4 2>/var/www/html/log/ffmpeg.$currentDate.log


      Doesn't work



      But, if I try to run it through PHP exec() in my /var/www/html folder (this is owned by www-data) it still runs, but the audio is missing.



      shell_exec("sudo -u myuser /usr/bin/ffmpeg -y -video_size 320x240 -framerate 30 -f v4l2 -i $videoSource -f pulse -ac 2 -i $audioSource -t 00:00:$duration -vcodec h264 -strict -2 /var/www/html/tmp/temp.mp4 2>/var/www/html/log/ffmpeg.$currentDate.log")


      Even from the terminal, It doesn't record sound if I use the sudo -u myuser I already added the users to audio, pulse and pulse-access groups.



      I have the same result if I switch pulse to alsa



      Here is my log:



                  ffmpeg version N-92489-g277fd9c Copyright (c) 2000-2018 the FFmpeg developers
      built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.10) 20160609
      configuration: --prefix=/home/myuser/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/home/myuser/ffmpeg_build/include --extra-ldflags=-L/home/myuser/ffmpeg_build/lib --extra-libs='-lpthread -lm' --bindir=/home/myuser/bin --enable-gpl --enable-libaom --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --disable-libaom --enable-libpulse --enable-nonfree
      libavutil 56. 23.101 / 56. 23.101
      libavcodec 58. 39.100 / 58. 39.100
      libavformat 58. 22.100 / 58. 22.100
      libavdevice 58. 6.100 / 58. 6.100
      libavfilter 7. 45.100 / 7. 45.100
      libswscale 5. 4.100 / 5. 4.100
      libswresample 3. 4.100 / 3. 4.100
      libpostproc 55. 4.100 / 55. 4.100
      Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/var/www/html/ready/recorded_20181122091147_preview.mp4':
      Metadata:
      major_brand : isom
      minor_version : 512
      compatible_brands: isomiso2avc1mp41
      encoder : Lavf58.22.100
      Duration: 00:00:30.02, start: 0.000000, bitrate: 241 kb/s
      Stream #0:0(und): Video: h264 (High 4:2:2) (avc1 / 0x31637661), yuv422p, 320x240, 105 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
      Metadata:
      handler_name : VideoHandler
      Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
      Metadata:
      handler_name : SoundHandler
      Stream mapping:
      Stream #0:0 -> #0:0 (h264 (native) -> mjpeg (native))
      Press [q] to stop, [?] for help
      [swscaler @ 0x22ccc00] deprecated pixel format used, make sure you did set range correctly
      Output #0, image2, to '/var/www/html/ready/recorded_20181122091147_preview.jpg':
      Metadata:
      major_brand : isom
      minor_version : 512
      compatible_brands: isomiso2avc1mp41
      encoder : Lavf58.22.100
      Stream #0:0(und): Video: mjpeg, yuvj422p(pc), 320x240, q=2-31, 200 kb/s, 30 fps, 30 tbn, 30 tbc (default)
      Metadata:
      handler_name : VideoHandler
      encoder : Lavc58.39.100 mjpeg
      Side data:
      cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
      frame= 1 fps=0.0 q=2.1 Lsize=N/A time=00:00:00.03 bitrate=N/A speed=2.48x
      video:4kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown









      share|improve this question













      Works:



      I'm trying to record video from my Logitech webcam and sound from the headset. I can record it without a problem from the terminal using the following logged in as "myuser":



      /usr/bin/ffmpeg -y -video_size 320x240 -framerate 30 -f v4l2 -i $videoSource -f pulse -ac 2 -i $audioSource -t 00:00:$duration -vcodec h264 -strict -2 /var/www/html/tmp/temp.mp4 2>/var/www/html/log/ffmpeg.$currentDate.log


      Doesn't work



      But, if I try to run it through PHP exec() in my /var/www/html folder (this is owned by www-data) it still runs, but the audio is missing.



      shell_exec("sudo -u myuser /usr/bin/ffmpeg -y -video_size 320x240 -framerate 30 -f v4l2 -i $videoSource -f pulse -ac 2 -i $audioSource -t 00:00:$duration -vcodec h264 -strict -2 /var/www/html/tmp/temp.mp4 2>/var/www/html/log/ffmpeg.$currentDate.log")


      Even from the terminal, It doesn't record sound if I use the sudo -u myuser I already added the users to audio, pulse and pulse-access groups.



      I have the same result if I switch pulse to alsa



      Here is my log:



                  ffmpeg version N-92489-g277fd9c Copyright (c) 2000-2018 the FFmpeg developers
      built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.10) 20160609
      configuration: --prefix=/home/myuser/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/home/myuser/ffmpeg_build/include --extra-ldflags=-L/home/myuser/ffmpeg_build/lib --extra-libs='-lpthread -lm' --bindir=/home/myuser/bin --enable-gpl --enable-libaom --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --disable-libaom --enable-libpulse --enable-nonfree
      libavutil 56. 23.101 / 56. 23.101
      libavcodec 58. 39.100 / 58. 39.100
      libavformat 58. 22.100 / 58. 22.100
      libavdevice 58. 6.100 / 58. 6.100
      libavfilter 7. 45.100 / 7. 45.100
      libswscale 5. 4.100 / 5. 4.100
      libswresample 3. 4.100 / 3. 4.100
      libpostproc 55. 4.100 / 55. 4.100
      Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/var/www/html/ready/recorded_20181122091147_preview.mp4':
      Metadata:
      major_brand : isom
      minor_version : 512
      compatible_brands: isomiso2avc1mp41
      encoder : Lavf58.22.100
      Duration: 00:00:30.02, start: 0.000000, bitrate: 241 kb/s
      Stream #0:0(und): Video: h264 (High 4:2:2) (avc1 / 0x31637661), yuv422p, 320x240, 105 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
      Metadata:
      handler_name : VideoHandler
      Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
      Metadata:
      handler_name : SoundHandler
      Stream mapping:
      Stream #0:0 -> #0:0 (h264 (native) -> mjpeg (native))
      Press [q] to stop, [?] for help
      [swscaler @ 0x22ccc00] deprecated pixel format used, make sure you did set range correctly
      Output #0, image2, to '/var/www/html/ready/recorded_20181122091147_preview.jpg':
      Metadata:
      major_brand : isom
      minor_version : 512
      compatible_brands: isomiso2avc1mp41
      encoder : Lavf58.22.100
      Stream #0:0(und): Video: mjpeg, yuvj422p(pc), 320x240, q=2-31, 200 kb/s, 30 fps, 30 tbn, 30 tbc (default)
      Metadata:
      handler_name : VideoHandler
      encoder : Lavc58.39.100 mjpeg
      Side data:
      cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
      frame= 1 fps=0.0 q=2.1 Lsize=N/A time=00:00:00.03 bitrate=N/A speed=2.48x
      video:4kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown






      sound pulseaudio ffmpeg






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 22 at 9:25









      Coron4extra

      64




      64



























          active

          oldest

          votes











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "89"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1095047%2fsound-doesnt-recording-if-running-ffmpeg-as-other-user%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown






























          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Ask Ubuntu!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1095047%2fsound-doesnt-recording-if-running-ffmpeg-as-other-user%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Biblatex bibliography style without URLs when DOI exists (in Overleaf with Zotero bibliography)

          ComboBox Display Member on multiple fields

          Is it possible to collect Nectar points via Trainline?