m1k1o/go-transcode

Usage examples

rezaalimorady opened this issue ยท 29 comments

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

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?

Any document for this module?

m1k1o commented

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?

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

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

image

still problem exist

m1k1o commented

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

absolutely yes

image

and this is my /media directory.

image

m1k1o commented

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

could not find the file from inside docker

image

from outside container it works

image

m1k1o commented

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.

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

m1k1o commented

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!

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

its into docker image:
image

m1k1o commented

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?

completly remove it
image

config inside docker image
image

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

m1k1o commented

I see that your cache dir does not exist. I just noticed that might be error and fixed in c26cba0.

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

Added usage examples.

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

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

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.

m1k1o commented

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.

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.

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

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

m1k1o commented

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.

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