1

I am trying to use raspivid as an input for ffmpeg

I'm testing the {code from this question}(How can I stream H.264 video from the Raspberry Pi camera module via a web server?). Initially I was using my own code, but I want to see if I can get it working under identical circumstances that they did.

However, I am recieving the following error:

pi@raspberrypi ~ $ /usr/share/nginx/www/video.sh 
ffmpeg version N-75462-g01770bf Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 4.6 (Debian 4.6.3-14+rpi1)
  configuration: 
  libavutil      55.  2.100 / 55.  2.100
  libavcodec     57.  3.100 / 57.  3.100
  libavformat    57.  2.100 / 57.  2.100
  libavdevice    57.  0.100 / 57.  0.100
  libavfilter     6.  6.100 /  6.  6.100
  libswscale      4.  0.100 /  4.  0.100
  libswresample   2.  0.100 /  2.  0.100
Input #0, h264, from 'pipe:':
  Duration: N/A, bitrate: N/A
    Stream #0:0: Video: h264 (High), yuv420p, 720x404, 25 fps, 25 tbr, 1200k tbn, 50 tbc
[stream_segment,ssegment @ 0x1fadbd0] Failed to open segment 'segments/00000000.ts'
Output #0, stream_segment,ssegment, to 'segments/%08d.ts':
  Metadata:
    encoder         : Lavf57.2.100
    Stream #0:0: Video: h264, yuv420p, 720x404, q=2-31, 25 fps, 25 tbr, 25 tbn, 25 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Could not write header for output file #0 (incorrect codec parameters ?): No such file or directory
rm: cannot remove `stream.m3u8': No such file or directory
rm: cannot remove `segments/*.ts': No such file or directory

I can see that it's capturing video because the light lights up, but it's saying it's failing to open the "segments" file, then later saying it cannot write the file 0. I've checked the permissions and added www-data to group, but it does not appear to have fixed it.

Any idea how to get raspivid streaming as an input to ffmpeg?

EDIT: By request, here is `video.sh'

#!/bin/bash

base="/usr/share/nginx/www/"

cd $base

raspivid -n -w 720 -h 405 -fps 25 -vf -t 86400000 -b 1800000 -ih -o - \
| ffmpeg -y \
    -i - \
    -c:v copy \
    -map 0:0 \
    -f ssegment \
    -segment_time 4 \
    -segment_format mpegts \
    -segment_list "$base/stream.m3u8" \
    -segment_list_size 720 \
    -segment_list_flags live \
    -segment_list_type m3u8 \
    "segments/%08d.ts"


trap "rm stream.m3u8 segments/*.ts" EXIT

# vim:ts=2:sw=2:sts=2:et:ft=sh

The full instructions is available in the link at the top.

jfa
  • 121
  • 8
  • can you show the ffmpeg command line parameters – Jaromanda X Sep 21 '15 at 05:22
  • I can't see the contents of plcvideo.sh from here, so you'll have to post it so I can see the command line parameters for ffmpeg – Jaromanda X Sep 21 '15 at 05:25
  • It's the one from the link I posted; raspivid -n -w 720 -h 405 -fps 25 -vf -t 86400000 -b 1800000 -ih -o -
    | ffmpeg -y
    -i -
    -c:v copy
    -map 0:0
    -f ssegment
    -segment_time 4
    -segment_format mpegts
    -segment_list "$base/stream.m3u8"
    -segment_list_size 720
    -segment_list_flags live
    -segment_list_type m3u8
    "segments/%08d.ts"
    – jfa Sep 21 '15 at 05:26
  • ok, your base is /data/live as per that script? and you do have a segments folder in the nginx/www folder? – Jaromanda X Sep 21 '15 at 05:28
  • No sorry, you're right, base is the www folder, /usr/share/nginx/www/ – jfa Sep 21 '15 at 05:29
  • Good call, it was the folder segments. I somehow accidentally created it in the wrong folder. Once I moved it and set the permissions and ownership correctly, then ran as root it worked. Thank you, it seemed like a permissions issue, I just could not figure it out. – jfa Sep 21 '15 at 05:36
  • @JaromandaX any idea why I can't see the stream in the browser? – jfa Sep 21 '15 at 05:58
  • which browser are you using? – Jaromanda X Sep 21 '15 at 09:32
  • @JaromandaX IceWeasel, though I'm trying to create the stream and send it to another box in nginx as the goal. – jfa Sep 25 '15 at 03:07

0 Answers0