Jump to content


Photo

Need help troubleshooting permissions for ffmpeg (raspberry Pi, OMX)

ffmpeg permissions transcoding OMX

  • Please log in to reply
18 replies to this topic

#1 cachaca OFFLINE  

cachaca

    Member

  • Members
  • 20 posts
  • Local time: 08:04 PM

Posted 25 April 2017 - 12:51 AM

Ok.. I have been able to compile and install a custom ffmpeg with OMX (hardware encoding enabled)

 

https://emby.media/c...-of-x264/page-2

 

But when enabled in the Emby server.. it silently fails.. 

 

HOWEVER...

When I copy/paste the command (for example):

 

ffmpeg -i file:"/media/usb0/TV Shows/SpongeBob SquarePants (1999-2015) [480p] [720p] [HEVC] [x265]/Season 01/[pseudo] S01E02 Reef Blower [480p] [h.265].mkv" -map_metadata -1 -map_chapters -1 -threads 0 -map 0:0 -map 0:1 -map -0:s -codec:v:0 h264_omx  -b:v 2211644 -maxrate 2211644 -bufsize 4423288 -force_key_frames "expr:gte(t,n_forced*3)" -vf "scale=trunc(min(max(iw\,ih*dar)\,1280)/2)*2:trunc(ow/dar/2)*2" -copyts -vsync -1 -codec:a:0 aac -strict experimental -ac 2 -ab 192000  -f segment -max_delay 5000000 -avoid_negative_ts disabled -start_at_zero -segment_time 3  -individual_header_trailer 0 -segment_format mpegts -segment_list_type m3u8 -segment_start_number 0 -segment_list "/tmp/transcoding-temp/e438c53f7db6725b084b892f6c3028cf.m3u8" -y "/tmp/transcoding-temp/e438c53f7db6725b084b892f6c3028cf%d.ts"

 

and sudo as ROOT ... it DOES work.

 

I am really confused.. tried changing the temp folder... and properly installing the ffmpeg (instead of running it from its source folder where I compiled it).

 

so.. the fact that ROOT can run it.. leads me to think it is a permissions issue.. the funny thing is that without ANY other changes.. by simply switching OMX off in the Emby config.. it WORKS.  It is as if the omx extension inside ffmpeg is trying to do something... like accessing hardware or another path.. that user emby does not have access to.

 

It is a near silent failure... (since error 255 really does not mean anything).

 

"

2017-04-25 04:22:01.7063 Info HttpServer: HTTP Response 500 to 192.168.50.74. Time: 28122ms (slow). http://192.168.50.60...KeyFrames=False
2017-04-25 04:22:01.7081 Info App: ffmpeg -i file:"/media/usb0/TV Shows/SpongeBob SquarePants (1999-2015) [480p] [720p] [HEVC] [x265]/Season 01/[pseudo] S01E03 Tea at the Treedome [480p] [h.265].mkv" -map_metadata -1 -map_chapters -1 -threads 0 -map 0:0 -map 0:1 -map -0:s -codec:v:0 h264_omx  -b:v 1122230 -maxrate 1122230 -bufsize 2244460 -force_key_frames "expr:gte(t,n_forced*3)" -vf "scale=trunc(min(max(iw\,ih*dar)\,1280)/2)*2:trunc(ow/dar/2)*2" -copyts -vsync -1 -codec:a:0 aac -strict experimental -ac 2 -ab 192000  -f segment -max_delay 5000000 -avoid_negative_ts disabled -start_at_zero -segment_time 3  -individual_header_trailer 0 -segment_format mpegts -segment_list_type m3u8 -segment_start_number 0 -segment_list "/var/tmp/transcoding-temp/transcoding-temp/aa6d990b7ad85df3cb9e9a131f4da08d.m3u8" -y "/var/tmp/transcoding-temp/transcoding-temp/aa6d990b7ad85df3cb9e9a131f4da08d%d.ts"
2017-04-25 04:22:02.1496 Info App: FFMpeg exited with code 255
2017-04-25 04:22:02.1643 Info App: returning /var/tmp/transcoding-temp/transcoding-temp/aa6d990b7ad85df3cb9e9a131f4da08d0.ts

"

 

And again.. if I take that line to my prompt and run it with sudo.. it WORKS:

root@avcenter:/tmp# ffmpeg -i file:"/media/usb0/TV Shows/SpongeBob SquarePants (1999-2015) [480p] [720p] [HEVC] [x265]/Season 01/[pseudo] S01E03 Tea at the Treedome [480p] [h.265].mkv" -map_metadata -1 -map_chapters -1 -threads 0 -map 0:0 -map 0:1 -map -0:s -codec:v:0 h264_omx  -b:v 1122230 -maxrate 1122230 -bufsize 2244460 -force_key_frames "expr:gte(t,n_forced*3)" -vf "scale=trunc(min(max(iw\,ih*dar)\,1280)/2)*2:trunc(ow/dar/2)*2" -copyts -vsync -1 -codec:a:0 aac -strict experimental -ac 2 -ab 192000  -f segment -max_delay 5000000 -avoid_negative_ts disabled -start_at_zero -segment_time 3  -individual_header_trailer 0 -segment_format mpegts -segment_list_type m3u8 -segment_start_number 0 -segment_list "/var/tmp/transcoding-temp/transcoding-temp/aa6d990b7ad85df3cb9e9a131f4da08d.m3u8" -y "/var/tmp/transcoding-temp/transcoding-temp/aa6d990b7ad85df3cb9e9a131f4da08d%d.ts"
ffmpeg version N-85641-gdd49eff Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 4.9.2 (Raspbian 4.9.2-10)
  configuration: --enable-gpl --enable-nonfree --enable-mmal --enable-omx --enable-omx-rpi --enable-libmp3lame --enable-libx264 --enable-libvorbis
  libavutil      55. 61.100 / 55. 61.100
  libavcodec     57. 93.100 / 57. 93.100
  libavformat    57. 72.101 / 57. 72.101
  libavdevice    57.  7.100 / 57.  7.100
  libavfilter     6. 86.100 /  6. 86.100
  libswscale      4.  7.101 /  4.  7.101
  libswresample   2.  8.100 /  2.  8.100
  libpostproc    54.  6.100 / 54.  6.100
Input #0, matroska,webm, from 'file:/media/usb0/TV Shows/SpongeBob SquarePants (1999-2015) [480p] [720p] [HEVC] [x265]/Season 01/[pseudo] S01E03 Tea at the Treedome [480p] [h.265].mkv':
  Metadata:
    encoder         : libebml v1.3.1 + libmatroska v1.4.2
    creation_time   : 2016-02-06T18:59:27.000000Z
  Duration: 00:11:03.73, start: 0.000000, bitrate: 561 kb/s
    Stream #0:0: Video: hevc (Main), yuv420p(tv), 704x480 [SAR 10:11 DAR 4:3], 29.97 fps, 29.97 tbr, 1k tbn, 29.97 tbc (default)
    Metadata:
      BPS             : 469945
      BPS-eng         : 469945
      DURATION        : 00:11:03.729000000
      DURATION-eng    : 00:11:03.729000000
      NUMBER_OF_FRAMES: 19892
      NUMBER_OF_FRAMES-eng: 19892
      NUMBER_OF_BYTES : 38989538
      NUMBER_OF_BYTES-eng: 38989538
      _STATISTICS_WRITING_APP: mkvmerge v8.4.0 ('A better way to fly') 64bit
      _STATISTICS_WRITING_APP-eng: mkvmerge v8.4.0 ('A better way to fly') 64bit
      _STATISTICS_WRITING_DATE_UTC: 2016-02-06 18:59:27
      _STATISTICS_WRITING_DATE_UTC-eng: 2016-02-06 18:59:27
      _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
    Stream #0:1(eng): Audio: aac (LC), 48000 Hz, stereo, fltp (default)
    Metadata:
      BPS             : 88626
      BPS-eng         : 88626
      DURATION        : 00:11:03.701000000
      DURATION-eng    : 00:11:03.701000000
      NUMBER_OF_FRAMES: 31111
      NUMBER_OF_FRAMES-eng: 31111
      NUMBER_OF_BYTES : 7352727
      NUMBER_OF_BYTES-eng: 7352727
      _STATISTICS_WRITING_APP: mkvmerge v8.4.0 ('A better way to fly') 64bit
      _STATISTICS_WRITING_APP-eng: mkvmerge v8.4.0 ('A better way to fly') 64bit
      _STATISTICS_WRITING_DATE_UTC: 2016-02-06 18:59:27
      _STATISTICS_WRITING_DATE_UTC-eng: 2016-02-06 18:59:27
      _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
Stream mapping:
  Stream #0:0 -> #0:0 (hevc (native) -> h264 (h264_omx))
  Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
[h264_omx @ 0x1d336a0] Using OMX.broadcom.video_encode
Output #0, segment, to '/var/tmp/transcoding-temp/transcoding-temp/aa6d990b7ad85df3cb9e9a131f4da08d%d.ts':
  Metadata:
    encoder         : Lavf57.72.101
    Stream #0:0: Video: h264 (h264_omx), yuv420p, 704x528 [SAR 1:1 DAR 4:3], q=2-31, 1122 kb/s, 29.97 fps, 90k tbn, 29.97 tbc (default)
    Metadata:
      encoder         : Lavc57.93.100 h264_omx
    Stream #0:1: Audio: aac (LC), 48000 Hz, stereo, fltp, 192 kb/s (default)
    Metadata:
      encoder         : Lavc57.93.100 aac

frame= 7342 fps= 24 q=-0.0 Lsize=N/A time=00:04:05.16 bitrate=N/A speed=0.793x
video:34589kB audio:5817kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
[aac @ 0x1d34aa0] Qavg: 1460.591
Exiting normally, received signal 2.

I tried once changing the emby default user to root.. but it did nothing.

 

 

ANY help would be greatly appreciated.. I feel like I survived the desert to die at the water fountain with a broken handle.

 

TTFN


Edited by cachaca, 25 April 2017 - 12:54 AM.


#2 wowbutters OFFLINE  

wowbutters

    Member

  • Members
  • 20 posts

Posted 25 April 2017 - 12:56 AM

You may need to chown the folder to the Emby user or add the Emby user to the pi user grp. chmod ugo+rw -R /path/to/folder may help aswell.

Sent from my SM-G935V using Tapatalk

#3 cachaca OFFLINE  

cachaca

    Member

  • Members
  • 20 posts
  • Local time: 08:04 PM

Posted 25 April 2017 - 01:24 AM

Thax for responding mate.

It is a great idea....and I nearly rushed to implement it.

 

HOWEVER.... it makes no sense when you consider that when I disable OMX and make NO OTHER change... it works again.  If directory permissions were the issue.. it would fail under both settings of the transcoder.

 

It fails with OMX enabled as non root.

It works with OMX disabled as user emby (or root)

 

If you watch the screen output of ffmpeg.. it is neatly structured... the section that "stops working" is absolutely the omx section.  The log outputs are identical up to that point.  Why would the subsection of ffmpeg that handles the low level hardware interface require root?  well... it should!  :) I am not that familiar with the driver model of Linux... but I dont have to be root to use my USB accessories.  There has to be a proxy process that handles the direct hardware layer access and relays it to non root users.  I expect the same should be happening to the OMX decoding/encoding hardware access.

 

It makes sense to me that Root privileges are required.. but this problem has already been solved.. right?  I mean.. Architecturally.

 

I did some googling... could not find ANY references of any specific permissions required by any implementation of any other coder/decoder.  Which drives me mad... NOBODY has seen this?  That ffmpeg cant run unless run as root?  Is that a fact or there is something wrong in my environment/compilation flags/configs/etc.

 

I am lost... throw ideas at me... this ffmpeg is an order of magnitude faster... I tasted it.. now I cant go back to that slow a$$$ stock non OMX version. :)



#4 wowbutters OFFLINE  

wowbutters

    Member

  • Members
  • 20 posts

Posted 25 April 2017 - 01:44 AM

https://emby.media/c...nstead-of-x264/

According to this it may be a rpi/ffmpeg issue? I run my server on a homebuilt ubuntu box, X code works flawless except on the TV directly connected to it. My gpu is probably just too slow for the TV. And even then the only real issue is subs lining up when I play thru kodi. I use kodi on 2 other laptops and a raspbian rpi3 and neither of them have an issue. I've also test ran 3 separate X coded files simultaneously 1 on chrome cast one on a laptop and the 3rd on my 50in smart TV non-issue.

So unfortunately, we may now be out of my area. I was just hoping for your sake it was a Linux problem not specifically rpi. Sorry. Hope it works out for you.

Sent from my SM-G935V using Tapatalk

#5 cachaca OFFLINE  

cachaca

    Member

  • Members
  • 20 posts
  • Local time: 08:04 PM

Posted 25 April 2017 - 03:45 AM

I had already seen that thread..even posted on it... thx though.

 

So... You used xubuntu?  14?

I am just getting started.. and I could switch to xutbuntu... no heartbreak ... I like Raspbian, but I am not married to it.  I could get a new girlfriend.

 

Just to confirm. under Ubuntu.. you compiled ffmpeg and successfully use it against Emby?

 

Did you notice significant speed improvements?

 

Kind regards,



#6 wowbutters OFFLINE  

wowbutters

    Member

  • Members
  • 20 posts

Posted 25 April 2017 - 03:54 AM

Ubuntu 16.04. Couldn't tell you on differences I followed a guide when I first set it up I am using the VA api with ffmpeg and as I said it works great for me. If you plan on Ubuntu for rpi I believe you'll need ubuntu mate 16.04 https://ubuntu-mate.org/raspberry-pi/. I haven't gotten around to playing with settings yet. More of a if it ain't t broke.

Sent from my SM-G935V using Tapatalk

#7 wowbutters OFFLINE  

wowbutters

    Member

  • Members
  • 20 posts

Posted 25 April 2017 - 03:55 AM

Apologies should have mentuoned that from the start, that's the point I was making that I wasn't using opx.

Sent from my SM-G935V using Tapatalk

#8 wowbutters OFFLINE  

wowbutters

    Member

  • Members
  • 20 posts

Posted 25 April 2017 - 03:57 AM

Actually I lied. I started with the Nvidia xcode and it was a dead crawl so I Googled optimal settings and found a setup guide with the VA buried in Google.

Sent from my SM-G935V using Tapatalk

#9 cachaca OFFLINE  

cachaca

    Member

  • Members
  • 20 posts
  • Local time: 08:04 PM

Posted 25 April 2017 - 09:34 AM

so.. you are not using a Raspberry pI?

I certainly cant speak for other architectures at this point... my problem is specific to OMX acceleration on the Pi3.



#10 wowbutters OFFLINE  

wowbutters

    Member

  • Members
  • 20 posts

Posted 25 April 2017 - 10:25 AM

No I guess I was a bit confusing. My server is on a full Linux box. One of my kodi installs is on a rpi3.

Sent from my SM-G935V using Tapatalk

#11 cachaca OFFLINE  

cachaca

    Member

  • Members
  • 20 posts
  • Local time: 08:04 PM

Posted 25 April 2017 - 11:25 AM

well.. According to the Web page for Ubuntu Mate:

"Ubuntu MATE 16.04 also fully supports the built-in Bluetooth and Wifi on the Raspberry Pi 3 and features hardware accelerated video playback in VLC and hardware accelerated decoding and encoding in ffmpeg"

https://ubuntu-mate.org/raspberry-pi/

 

So.. I am taking another SD card and giving it a shot.. I want to be done with this project... There are more projects on the docket :)

 

Cheers



#12 wowbutters OFFLINE  

wowbutters

    Member

  • Members
  • 20 posts

Posted 25 April 2017 - 12:10 PM

well.. According to the Web page for Ubuntu Mate:
"Ubuntu MATE 16.04 also fully supports the built-in Bluetooth and Wifi on the Raspberry Pi 3 and features hardware accelerated video playback in VLC and hardware accelerated decoding and encoding in ffmpeg"
https://ubuntu-mate.org/raspberry-pi/

So.. I am taking another SD card and giving it a shot.. I want to be done with this project... There are more projects on the docket :)

Cheers

Good luck mate.

Sent from my SM-G935V using Tapatalk

#13 cachaca OFFLINE  

cachaca

    Member

  • Members
  • 20 posts
  • Local time: 08:04 PM

Posted 25 April 2017 - 09:11 PM

well.. I am DONE.

 

After another few hours of installation and configuration.. the Ubuntu deployed ffmpeg behaves EXACTLY the same way.

I mean. exactly.  Which validates the integrity of my personal Raspbian deployment (as it pertains to ffmpeg and its deplendencies)

 

close this thread... I will move on without the OMX accelleration.  I wont turn this install upside down and run emby as root.. a media server connected to the Internet... all due respect to the developers of Emby.. and the many plugins I could use.. but I think the focus is on features.. not security.  Running it as "emby" limits the amount of damage a potential hacker may do.

 

Anyway. thank you for the help ... and let this be a warning to others.. it requires root.  ... and I suspect it is an undocumented requirement of the omx library subsection of the ffmpeg binary.

 

************

side note.. ubuntu 16LTS Mate is GARBAGE.  Absolute Garbage.  I have used beta distributions from smaller teams that installed and self configured with far less problems than this garbage distro.

I just turned it off.. without even shutting it down.  I will never use it again, and this MicroSD card will be wiped clean soon.

 

What is so bad about it?  I wont list all the problems.. and many config changes I had to do manually to a brand new system.. but here are the most glaring flaws:

 - no swap file created or defined

 - ssh would only start AFTER a successful login at the console... AND a graphical dialog box showed up (even though I used sudo at the prompt) asking me for a password

 - vnc not installed by default.. and even after installed.. I had to manually configure X (tried 2 different vnc servers)

 - and the crown jewel:

    -> first thing you do after getting a new distro: update the OS.  "sorry, you dont have enough disk space in /boot to perform your updates".  I had to do a NEW install, resizing the 64Meg boot partition to a larger size BEFORE installing the OS. (oh.. and because I resized partitions BEFORE the install, the INstaller did not extend the actual / partition to the rest of the SD card.. so the install failed again)

 

Not that I could not deal with these problems.. but seriously.. needing to log in at the console before ssh worked.. WTF  Was the Canonical guy on shrooms?  I had not used ubuntu in a long time.. and I completely turned off.  What an AWFUL experience.

 

TTFN gents.. on to the next project. (ok.. I stil have work with Emby.. but the server will run like a champ now)

10211551-227043200_10-s4-v1.png?transpar



#14 Luke OFFLINE  

Luke

    System Architect

  • Administrators
  • 124437 posts
  • Local time: 08:04 PM

Posted 25 April 2017 - 11:40 PM

What about VA API?



#15 cachaca OFFLINE  

cachaca

    Member

  • Members
  • 20 posts
  • Local time: 08:04 PM

Posted 27 April 2017 - 10:49 PM

FOUND THE ANSWER:

 

https://emby.media/c...-x264/?p=444447

 

8363918-227043200_10-s4-v1.png?transpare


  • Luke likes this

#16 wowbutters OFFLINE  

wowbutters

    Member

  • Members
  • 20 posts

Posted 27 April 2017 - 11:19 PM

And boom goes the dynamite.
Aces Charles.
And anymore congratulatory tv/movie quotes you would like to add.

Sent from my SM-G935V using Tapatalk

#17 db414813 OFFLINE  

db414813

    Member

  • Members
  • 11 posts
  • Local time: 08:04 PM

Posted 14 January 2018 - 12:48 AM

Anyone try this in 2018? I am not a noob but I am not a pro. I compiled ffmpeg with the following "sudo ./configure --arch=armel --target-os=linux --enable-gpl --enable-omx --enable-omx-rpi --enable-nonfree --enable-mmal" and make install blah. Installed emby. Tried to stream would not stream. Enabled openmax hwaccel in settings still nothing. I am not sure how to post logs here. Im new :)



#18 db414813 OFFLINE  

db414813

    Member

  • Members
  • 11 posts
  • Local time: 08:04 PM

Posted 14 January 2018 - 09:23 PM

Nevermind. I recompiled ffmpeg with lame and libass. Then I increased gpu mem to 256 mb and it works now.



#19 Luke OFFLINE  

Luke

    System Architect

  • Administrators
  • 124437 posts
  • Local time: 08:04 PM

Posted 14 January 2018 - 10:15 PM

@db414813, you might be interested in trying this:

 

https://emby.media/c...docker-arm32v7/

 

You won't have to worry about ffmpeg setup at all.







Also tagged with one or more of these keywords: ffmpeg, permissions, transcoding, OMX

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users