m1k1o / go-transcode

On-demand transcoding origin server for live inputs and static files in Go using ffmpeg. Also with NVIDIA GPU hardware acceleration.
Apache License 2.0
208 stars 38 forks source link

Usage examples #28

Closed rezaalimorady closed 1 year ago

rezaalimorady commented 2 years ago

Hello could you share some of usage example for this module? TNX

rezaalimorady commented 2 years ago

for example i have a mp4 file in /media directory 4f9c8335-90b1-4551-a59d-7534bc553057_360.mp4

and i want the index file -> with this url http://localhost:8080/vod/4f9c8335-90b1-4551-a59d-7534bc553057_360.mp4/index.m3u8 and it returns : 500 unable to preload metadata

docker-compose logs:

go-transcode    | 12:08PM WRN unable to preload metadata error="unable probe media for metadata: exit status 1" module=hlsvod
go-transcode    | 12:08PM DBG request complete (500) module=http req={"agent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36","id":"b7e509d9545f/KM6lrEb4VP-000020","method":"GET","proto":"HTTP/1.1","remote":"172.18.0.1:35092","scheme":"http","uri":"http://localhost:8080/vod/4f9c8335-90b1-4551-a59d-7534bc553057_360.mp4/index.m3u8"} res={"bytes":31,"elapsed":22.711615,"status":500,"time":"Sun, 05 Dec 2021 12:08:20 UTC"}

config.yaml file :

# allow debug outputs
debug: true

# mount debug pprof endpoint at /debug/pprof/
pprof: true

# bind server to IP:PORT (use :8888 for all connections)
bind: localhost:8080

# serve static files from this directory (optional)
static: /var/www/html

# TODO: issue #4
proxy: true

# For live streaming
streams:
  cam: rtmp://localhost/live/cam
  ch1_hd: http://localhost:9981/stream/channelid/85
  ch2_hd: http://localhost:9981/stream/channelid/43

# For static files
vod:
  # Source, where are static files, that will be transcoded
  media-dir: ./media
  # Temporary transcode output directory, if empty, default tmp folder will be used
  transcode-dir: ./transcode
  # Available video profiles
  video-profiles:
    360p:
      width: 640 # px
      height: 360 # px
      bitrate: 800 # kbps
    540p:
      width: 960
      height: 540
      bitrate: 1800
    720p:
      width: 1280
      height: 720
      bitrate: 2800
    1080p:
      width: 1920
      height: 1080
      bitrate: 5000
  # Use video keyframes as existing reference for chunks split
  # Using this might cause long probing times in order to get
  # all keyframes - therefore they should be cached
  video-keyframes: false
  # Single audio profile used
  audio-profile:
    bitrate: 192 # kbps
  # If cache is enabled
  cache: true
  # If dir is empty, cache will be stored in the same directory as media source
  # If not empty, cache files will be saved to specified directory
  cache-dir: ./cache
  # Use custom ffmpeg & ffprobe binary paths
  ffmpeg-binary: ffmpeg
  ffprobe-binary: ffmpeg

# For proxying HLS streams
hls-proxy:
  my_server: http://localhost:9981

what should i do for index.m3u8 file for a mp4?

rezaalimorady commented 2 years ago

Any document for this module?

m1k1o commented 2 years ago

Yes, adding usage examples for all modules would be needed.

Quick question, do you have ffmpeg installed? If it cannot preload metdata, it might be because of missing ffmpeg. Or do you use docker image?

And you say your files are in /media but in config it is ./media. Is that expected?

rezaalimorady commented 2 years ago

Thanks ffmpeg installed before

image

i used your docker-compose for build I think its about my media-dir: /media

i use /media directory for videos. what should i put in config.yaml -> media-dir: -----

m1k1o commented 2 years ago

If you use /media, then media-dir: /media should be the correct entry.

rezaalimorady commented 2 years ago

image

still problem exist

m1k1o commented 2 years ago

Your config file is mounted as volume to docker, right? And after changing it you restarted the container and it does not work, correct?

rezaalimorady commented 2 years ago

absolutely yes

image

and this is my /media directory.

image

m1k1o commented 2 years ago

Can you try to execute ffprobe on that file inside container, to rule out all permissions issues?

Something like this:

docker-compose exec go-transcode ffprobe /media/4f9c8335-90b1-4551-a59d-7534bc553057_360.mp4
rezaalimorady commented 2 years ago

could not find the file from inside docker

image

from outside container it works

image

m1k1o commented 2 years ago

Is it mounted correctly? With - ./media:/media.

version: "3"

services:
  go-transcode:
    build: . # path to go-transcode repository
    container_name: go-transcode
    restart: unless-stopped
    ports:
      - "8080:8080"
    volumes:
      - ./config.yaml:/app/config.yaml
      - ./media:/media
    command: serve -d

UPDATE: or - /media:/media.

rezaalimorady commented 2 years ago

ffprobe fixed when i correct my docker-compose

image

but the URL -> http://localhost:8080/vod/4f9c8335-90b1-4551-a59d-7534bc553057_360.mp4/index.m3u8 still dosn't return anything

docker-compose logs -f

go-transcode    | 1:17PM WRN unable to preload metadata error="unable probe media for metadata: exit status 1" module=hlsvod
go-transcode    | 1:17PM DBG request complete (500) module=http req={"agent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36","id":"d03e06e9d058/03MFNWvPjp-000002","method":"GET","proto":"HTTP/1.1","remote":"172.18.0.1:56356","scheme":"http","uri":"http://localhost:8080/vod/4f9c8335-90b1-4551-a59d-7534bc553057_360.mp4/index.m3u8"} res={"bytes":31,"elapsed":22.090266,"status":500,"time":"Sun, 05 Dec 2021 13:17:36 UTC"}
go-transcode    | 1:17PM INF fetching metadata module=hlsvod submodule=manager
rezaalimorady commented 2 years ago

image

m1k1o commented 2 years ago

Just noticed! I have mistake in readme:

  ffmpeg-binary: ffmpeg
  ffprobe-binary: ffmpeg

ffprobe-binary should be ffprobe, but it is ffmpeg. That is why show_format is unrecognized. Gonna fix that, thanks!

rezaalimorady commented 2 years ago

No problem dear. i change it but still same problem image

its into docker image: image

m1k1o commented 2 years ago

It looks like, error persists and ffmpeg is still called (because of the show_format error). Could you try to recreate your container, to be sure, changes were applied?

rezaalimorady commented 2 years ago

completly remove it image

config inside docker image image

and ffprobe error not show there is another error :) image

m1k1o commented 2 years ago

I see that your cache dir does not exist. I just noticed that might be error and fixed in https://github.com/m1k1o/go-transcode/commit/c26cba02f9f846736afd1980ff8eddfa404e8a05.

If you want to keep your cache along with the files, you can remove cache-dir: ./bin/cache this line. Or specify directory, that exists (mount it in docker compose).

m1k1o commented 2 years ago

Added usage examples.

rezaalimorady commented 2 years ago

Thanks bro. I pulled last changes and problem fixed. but this url -> http://localhost:8080/vod/4f9c8335-90b1-4551-a59d-7534bc553057_360.mp4/index.m3u8 not retun completly manifest file image

and of course using `ffplay` . return err
http://localhost:8080/vod/4f9c8335-90b1-4551-a59d-7534bc553057_360.mp4/index.m3u8: Invalid data found when processing input
rezaalimorady commented 2 years ago

Thanks for adding usage examples :) please add usage example for profile or multi probile/bitrate manifest. and how can add new profile or change current profile

m1k1o commented 2 years ago

If the master playlist is empty, that can mean, your video resolution is lower than the lowest profile. You can try to get the profile directly. E.g. http://localhost:8080/vod/4f9c8335-90b1-4551-a59d-7534bc553057_360.mp4/360p.m3u8 and it should work.

I consider adding the lowest profile all the time, because it should never return empty playlist.

rezaalimorady commented 2 years ago

Thanks It play when i using to get all of this urls http://localhost:8080/vod/4f9c8335-90b1-4551-a59d-7534bc553057_360.mp4/360p.m3u8 http://localhost:8080/vod/4f9c8335-90b1-4551-a59d-7534bc553057_360.mp4/720p.m3u8 http://localhost:8080/vod/4f9c8335-90b1-4551-a59d-7534bc553057_360.mp4/1080p.m3u8

but i need the master file. how could i get the master file?

m1k1o commented 2 years ago

What is the resolution of the video? There is also no point in upscaling, if it is not 1080p. I can though leave at least the lowest one in all cases.

rezaalimorady commented 2 years ago

i use a 1080 video -> http://localhost:8080/vod/17bb20ab-4028-4e2f-acb4-619e4d79c8da_1080.mp4/index.m3u8

the output is like :

#EXTM3U
#EXT-X-STREAM-INF:BANDWIDTH=945000,RESOLUTION=640x360,NAME=360p
360p.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=1995000,RESOLUTION=960x540,NAME=540p
540p.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=3045000,RESOLUTION=1280x720,NAME=720p
720p.m3u8

why 1080 profile not in index file? how could i config these.

rezaalimorady commented 2 years ago

and how about subtitles? how could i add subtitle track?

rezaalimorady commented 2 years ago

I hope your team write powerfull document for this module. really needed

m1k1o commented 2 years ago

why 1080 profile not in index file?

It looks like a bug, I'll look into this. It should be visible.

I hope your team write powerful document for this module.

My team consist of only me right now. Contributors are welcomed. This module is experimental now and thanks to the people who use it and give me feedback, like you, I can catch lots of bugs and make it better for everyone.

and how about subtitles?

That is on roadmap. Hopefully soon will be supported.

rezaalimorady commented 2 years ago

Thank you for your patient response :) Hopefully being best.