From 26ec945921fc62037cf1ca25f84aae801b4a38eb Mon Sep 17 00:00:00 2001 From: jb-alvarado Date: Wed, 12 Jun 2024 10:16:00 +0200 Subject: [PATCH] remove ffpapi references --- .gitignore | 1 - README.md | 4 --- debian/postinst | 2 +- docker/Dockerfile | 5 +--- docker/README.md | 2 +- docker/fromSource.Dockerfile | 4 +-- docker/nvidia-centos7.Dockerfile | 3 +- docs/advanced_settings.md | 2 +- docs/api.md | 47 +++++++++--------------------- docs/install.md | 18 ++++-------- docs/output.md | 2 +- ffplayout/build.rs | 4 +-- ffplayout/src/api/routes.rs | 10 +++---- ffplayout/src/main.rs | 2 +- ffplayout/src/utils/mod.rs | 2 +- migrations/00001_create_tables.sql | 2 +- scripts/build.sh | 18 +++++------- scripts/man_create.sh | 6 ++-- 18 files changed, 45 insertions(+), 89 deletions(-) diff --git a/.gitignore b/.gitignore index ae60ba83..a7d04f9a 100644 --- a/.gitignore +++ b/.gitignore @@ -20,7 +20,6 @@ *.deb *.rpm ffplayout.1.gz -ffpapi.1.gz /assets/*.db* /dist/ /public/ diff --git a/README.md b/README.md index f2eeb1a9..fc05f43f 100644 --- a/README.md +++ b/README.md @@ -59,10 +59,6 @@ For preview stream, read: [/docs/preview_stream.md](/docs/preview_stream.md) **\* Experimental features do not guarantee the same stability and may fail under unusual circumstances. Code and configuration options may change in the future.** -## **ffplayout-api (ffpapi)** - -ffpapi serves the [frontend](https://github.com/ffplayout/ffplayout-frontend) and it acts as a [REST API](/ffplayout-api/README.md) for controlling the engine, manipulate playlists, add settings etc. - ### Requirements - RAM and CPU depends on video resolution, minimum 4 threads and 3GB RAM for 720p are recommend diff --git a/debian/postinst b/debian/postinst index b8614c43..9fc8005e 100644 --- a/debian/postinst +++ b/debian/postinst @@ -19,7 +19,7 @@ if [ ! -d "/usr/share/ffplayout/db" ]; then IP=$(hostname -I | cut -d ' ' -f1) - /usr/bin/ffpapi -i -d "${IP}:8787" + /usr/bin/ffplayout -i -d "${IP}:8787" chown -R ${sysUser}: "/usr/share/ffplayout" chown -R ${sysUser}: "/var/lib/ffplayout" diff --git a/docker/Dockerfile b/docker/Dockerfile index fdc9191e..96e9d4a2 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -29,12 +29,9 @@ RUN dnf update -y && \ RUN [[ -f /tmp/ffplayout-${FFPLAYOUT_VERSION}-1.x86_64.rpm ]] || wget -q "https://github.com/ffplayout/ffplayout/releases/download/v${FFPLAYOUT_VERSION}/ffplayout-${FFPLAYOUT_VERSION}-1.x86_64.rpm" -P /tmp/ && \ dnf install -y /tmp/ffplayout-${FFPLAYOUT_VERSION}-1.x86_64.rpm && \ rm /tmp/ffplayout-${FFPLAYOUT_VERSION}-1.x86_64.rpm && \ - sed -i "s/User=ffpu/User=root/g" /usr/lib/systemd/system/ffpapi.service && \ sed -i "s/User=ffpu/User=root/g" /usr/lib/systemd/system/ffplayout.service && \ - sed -i "s/User=ffpu/User=root/g" /usr/lib/systemd/system/ffplayout@.service && \ systemctl enable ffplayout && \ - systemctl enable ffpapi && \ - ffpapi -u admin -p admin -m contact@example.com + ffplayout -u admin -p admin -m contact@example.com EXPOSE 8787 diff --git a/docker/README.md b/docker/README.md index 90be9e3f..cdb45f8e 100644 --- a/docker/README.md +++ b/docker/README.md @@ -26,7 +26,7 @@ You can take a look at the [Dockerfile](Dockerfile) ## Storage There are some folders/files that are important for ffplayout to work well such as: - - **/usr/share/ffplayout/db** => where all the data for the `ffpapi` are stored (user/pass etc) + - **/usr/share/ffplayout/db** => where all the data are stored (user/pass etc) - **/var/lib/ffplayout/tv-media** => where the media are stored by default (configurable) - **/var/lib/ffplayout/playlists** => where playlists are stored (configurable) - **/etc/ffplayout/ffplayout.yml** => the core config file diff --git a/docker/fromSource.Dockerfile b/docker/fromSource.Dockerfile index 7a6a1ef2..59a27ea7 100644 --- a/docker/fromSource.Dockerfile +++ b/docker/fromSource.Dockerfile @@ -139,7 +139,6 @@ ENV LD_LIBRARY_PATH=/usr/local/lib64:/usr/local/lib COPY --from=build /usr/local/ /usr/local/ ADD ./overide.conf /etc/systemd/system/ffplayout.service.d/overide.conf -ADD ./overide.conf /etc/systemd/system/ffpapi.service.d/overide.conf RUN \ dnf update -y \ @@ -155,8 +154,7 @@ RUN \ rm /tmp/ffplayout-${FFPLAYOUT_VERSION}-1.x86_64.rpm && \ mkdir -p /home/ffpu && chown -R ffpu: /home/ffpu && \ systemctl enable ffplayout && \ - systemctl enable ffpapi && \ - ffpapi -u admin -p admin -m contact@example.com + ffplayout -u admin -p admin -m contact@example.com EXPOSE 8787 diff --git a/docker/nvidia-centos7.Dockerfile b/docker/nvidia-centos7.Dockerfile index 02a36bcc..f1fd376b 100644 --- a/docker/nvidia-centos7.Dockerfile +++ b/docker/nvidia-centos7.Dockerfile @@ -102,8 +102,7 @@ RUN yum update -y \ && echo 'Docker!' | passwd --stdin root \ && rm /tmp/ffplayout-${FFPLAYOUT_VERSION}-1.x86_64.rpm \ && mkdir -p /home/ffpu && chown -R ffpu: /home/ffpu \ - && systemctl enable ffplayout \ - && systemctl enable ffpapi + && systemctl enable ffplayout EXPOSE 8787 RUN echo "/usr/local/lib" >> /etc/ld.so.conf.d/nvidia.conf diff --git a/docs/advanced_settings.md b/docs/advanced_settings.md index 5aca7a0f..94641836 100644 --- a/docs/advanced_settings.md +++ b/docs/advanced_settings.md @@ -1,6 +1,6 @@ ## Advanced settings -Within **/etc/ffplayout/advanced.yml** you can control all ffmpeg inputs/decoder output and filters. +With **advanced settings** you can control all ffmpeg inputs/decoder output and filters. > **_Note:_** Changing these settings is for advanced users only! There will be no support or guarantee that it will work and be stable after changing them! diff --git a/docs/api.md b/docs/api.md index 531403cc..d65dda68 100644 --- a/docs/api.md +++ b/docs/api.md @@ -1,9 +1,9 @@ -## Possible endpoints +### Possible endpoints Run the API thru the systemd service, or like: ```BASH -ffpapi -l 127.0.0.1:8787 +ffplayout -l 127.0.0.1:8787 ``` For all endpoints an (Bearer) authentication is required.\ @@ -72,7 +72,7 @@ curl -X GET 'http://127.0.0.1:8787/api/user/2' -H 'Content-Type: application/jso -H 'Authorization: Bearer ' ``` -#### ffpapi Settings +#### Settings **Get Settings from Channel** @@ -87,9 +87,7 @@ curl -X GET http://127.0.0.1:8787/api/channel/1 -H "Authorization: Bearer ```BASH curl -X PATCH http://127.0.0.1:8787/api/channel/1 -H "Content-Type: application/json" \ --d '{ "id": 1, "name": "Channel 1", "preview_url": "http://localhost/live/stream.m3u8", "config_path": "/etc/ffplayout/ffplayout.yml", "extra_extensions": "jpg,jpeg,png"}' \ +-d '{ "id": 1, "name": "Channel 1", "preview_url": "http://localhost/live/stream.m3u8", "extra_extensions": "jpg,jpeg,png"}' \ -H "Authorization: Bearer " ``` @@ -112,7 +110,7 @@ curl -X PATCH http://127.0.0.1:8787/api/channel/1 -H "Content-Type: application/ ```BASH curl -X POST http://127.0.0.1:8787/api/channel/ -H "Content-Type: application/json" \ --d '{ "name": "Channel 2", "preview_url": "http://localhost/live/channel2.m3u8", "config_path": "/etc/ffplayout/channel2.yml", "extra_extensions": "jpg,jpeg,png", "service": "ffplayout@channel2.service" }' \ +-d '{ "name": "Channel 2", "preview_url": "http://localhost/live/channel2.m3u8", "extra_extensions": "jpg,jpeg,png" }' \ -H "Authorization: Bearer " ``` @@ -130,7 +128,7 @@ curl -X DELETE http://127.0.0.1:8787/api/channel/2 -H "Authorization: Bearer ' ``` -Response is a JSON object from the ffplayout.yml +Response is a JSON object from the ffplayout.toml **Update Config** @@ -210,38 +208,19 @@ curl -X GET http://127.0.0.1:8787/api/control/1/media/current **Response:** ```JSON -{ - "jsonrpc": "2.0", - "result": { - "current_media": { + { + "media": { "category": "", "duration": 154.2, "out": 154.2, - "seek": 0.0, + "in": 0.0, "source": "/opt/tv-media/clip.mp4" }, "index": 39, - "play_mode": "playlist", - "played_sec": 67.80771999300123, - "remaining_sec": 86.39228000699876, - "start_sec": 24713.631999999998, - "start_time": "06:51:53.631" - }, - "id": 1 -} -``` - -**Get next Clip** - -```BASH -curl -X GET http://127.0.0.1:8787/api/control/1/media/next -H 'Authorization: Bearer ' -``` - -**Get last Clip** - -```BASH -curl -X GET http://127.0.0.1:8787/api/control/1/media/last --H 'Content-Type: application/json' -H 'Authorization: Bearer ' + "ingest": false, + "mode": "playlist", + "played": 67.808 + } ``` #### ffplayout Process Control diff --git a/docs/install.md b/docs/install.md index 1193472d..16a79efc 100644 --- a/docs/install.md +++ b/docs/install.md @@ -7,32 +7,26 @@ ffplayout provides ***.deb** and ***.rpm** packages, which makes it more easy to 3. install ffmpeg/ffprobe, or compile and copy it to **/usr/local/bin/** 4. activate systemd services: - `systemctl enable ffplayout` - - `systemctl enable --now ffpapi` -5. add admin user to ffpapi: - - `ffpapi -a` +5. add admin: + - `ffplayout -a` 6. use a revers proxy for SSL, Port is **8787**. 7. login with your browser, address without proxy would be: **http://[IP ADDRESS]:8787** Default location for playlists and media files are: **/var/lib/ffplayout/**. -When you don't need the frontend and API, skip enable the systemd service **ffpapi**. - When playlists are created and the ffplayout output is configured, you can start the process: `systemctl start ffplayout`, or click start in frontend. -If you want to configure ffplayout over terminal, you can edit **/etc/ffplayout/ffplayout.yml**. - ### Manual Install ----- - install ffmpeg/ffprobe, or compile and copy it to **/usr/local/bin/** - download the latest archive from [release](https://github.com/ffplayout/ffplayout/releases/latest) page -- copy the ffplayout and ffpapi binary to `/usr/bin/` +- copy the ffplayout binary to `/usr/bin/` - copy **assets/ffplayout.yml** to `/etc/ffplayout` - create folder `/var/log/ffplayout` - create system user **ffpu** - give ownership from `/etc/ffplayout` and `/var/log/ffplayout` to **ffpu** -- copy **assets/ffpapi.service**, **assets/ffplayout.service** and **assets/ffplayout@.service** to `/etc/systemd/system` -- copy **assets/11-ffplayout** to `/etc/sudoers.d/` -- copy **assets/ffpapi.1.gz** and **assets/ffplayout.1.gz** to `/usr/share/man/man1/` +- copy **assets/ffplayout.service** to `/etc/systemd/system` +- copy **assets/ffplayout.1.gz** to `/usr/share/man/man1/` - copy **public** folder to `/usr/share/ffplayout/` -- activate service and run it: `systemctl enable --now ffpapi ffplayout` +- activate service and run it: `systemctl enable --now ffplayout` diff --git a/docs/output.md b/docs/output.md index ba9874f8..f238b164 100644 --- a/docs/output.md +++ b/docs/output.md @@ -72,7 +72,7 @@ In this mode you can output directly to a hls playlist. The nice thing here is, HLS output is currently the default, mostly because it works out of the box and don't need a streaming target. In default settings it saves the segments to **/usr/share/ffplayout/public/live/**. -**It is recommend to serve the HLS stream with nginx or another web server, and not with ffpapi (which is more meant for previewing).** +**It is recommend to serve the HLS stream with nginx or another web server, and not with ffplayout (which is more meant for previewing).** **HLS multiple outputs example:** diff --git a/ffplayout/build.rs b/ffplayout/build.rs index df50d511..f8a856e0 100644 --- a/ffplayout/build.rs +++ b/ffplayout/build.rs @@ -2,10 +2,10 @@ use static_files::NpmBuild; fn main() -> std::io::Result<()> { if !cfg!(debug_assertions) && cfg!(feature = "embed_frontend") { - NpmBuild::new("../ffplayout-frontend") + NpmBuild::new("../frontend") .install()? .run("generate")? - .target("../ffplayout-frontend/.output/public") + .target("../frontend/.output/public") .change_detection() .to_resource_dir() .build() diff --git a/ffplayout/src/api/routes.rs b/ffplayout/src/api/routes.rs index b2509501..546f0e5f 100644 --- a/ffplayout/src/api/routes.rs +++ b/ffplayout/src/api/routes.rs @@ -3,7 +3,7 @@ /// Run the API thru the systemd service, or like: /// /// ```BASH -/// ffpapi -l 127.0.0.1:8787 +/// ffplayout -l 127.0.0.1:8787 /// ``` /// /// For all endpoints an (Bearer) authentication is required.\ @@ -377,7 +377,7 @@ async fn remove_user( } } -/// #### ffpapi Settings +/// #### Settings /// /// **Get Settings from Channel** /// @@ -392,9 +392,7 @@ async fn remove_user( /// "id": 1, /// "name": "Channel 1", /// "preview_url": "http://localhost/live/preview.m3u8", -/// "config_path": "/etc/ffplayout/ffplayout.toml", /// "extra_extensions": "jpg,jpeg,png", -/// "service": "ffplayout.service", /// "utc_offset": "+120" /// } /// ``` @@ -430,7 +428,7 @@ async fn get_all_channels(pool: web::Data>) -> Result" /// ``` #[patch("/channel/{id}")] @@ -454,7 +452,7 @@ async fn patch_channel( /// /// ```BASH /// curl -X POST http://127.0.0.1:8787/api/channel/ -H "Content-Type: application/json" \ -/// -d '{ "name": "Channel 2", "preview_url": "http://localhost/live/channel2.m3u8", "config_path": "/etc/ffplayout/channel2.toml", "extra_extensions": "jpg,jpeg,png", "service": "ffplayout@channel2.service" }' \ +/// -d '{ "name": "Channel 2", "preview_url": "http://localhost/live/channel2.m3u8", "extra_extensions": "jpg,jpeg,png" }' \ /// -H "Authorization: Bearer " /// ``` #[post("/channel/")] diff --git a/ffplayout/src/main.rs b/ffplayout/src/main.rs index a46310a8..d6ff4715 100644 --- a/ffplayout/src/main.rs +++ b/ffplayout/src/main.rs @@ -230,7 +230,7 @@ async fn main() -> std::io::Result<()> { .run() .await } else { - error!("Run ffpapi with listen parameter!"); + error!("Run ffplayout with listen parameter!"); Ok(()) } diff --git a/ffplayout/src/utils/mod.rs b/ffplayout/src/utils/mod.rs index eccab888..0d76ab27 100644 --- a/ffplayout/src/utils/mod.rs +++ b/ffplayout/src/utils/mod.rs @@ -318,7 +318,7 @@ pub async fn run_args() -> Result<(), i32> { let mut args = ARGS.clone(); if args.listen.is_none() && !args.ask && args.username.is_none() { - eprintln!("Wrong number of arguments! Run ffpapi --help for more information."); + eprintln!("Wrong number of arguments! Run ffplayout --help for more information."); return Err(0); } diff --git a/migrations/00001_create_tables.sql b/migrations/00001_create_tables.sql index 15bd5ea5..693a1a60 100644 --- a/migrations/00001_create_tables.sql +++ b/migrations/00001_create_tables.sql @@ -120,7 +120,7 @@ CREATE TABLE task_help TEXT NOT NULL DEFAULT "Run an external program with a given media object. The media object is in json format and contains all the information about the current clip. The external program can be a script or a binary, but should only run for a short time.", task_enable INTEGER NOT NULL DEFAULT 0, task_path TEXT NOT NULL DEFAULT "", - output_help TEXT NOT NULL DEFAULT "The final playout compression. Set the settings to your needs. 'mode' has the options 'desktop', 'hls', 'null', 'stream'. Use 'stream' and adjust 'output_param:' settings when you want to stream to a rtmp/rtsp/srt/... server.\nIn production don't serve hls playlist with ffpapi, use nginx or another web server!", + output_help TEXT NOT NULL DEFAULT "The final playout compression. Set the settings to your needs. 'mode' has the options 'desktop', 'hls', 'null', 'stream'. Use 'stream' and adjust 'output_param:' settings when you want to stream to a rtmp/rtsp/srt/... server.\nIn production don't serve hls playlist with ffplayout, use nginx or another web server!", output_mode TEXT NOT NULL DEFAULT "hls", output_param TEXT NOT NULL DEFAULT "-c:v libx264 -crf 23 -x264-params keyint=50:min-keyint=25:scenecut=-1 -maxrate 1300k -bufsize 2600k -preset faster -tune zerolatency -profile:v Main -level 3.1 -c:a aac -ar 44100 -b:a 128k -flags +cgop -f hls -hls_time 6 -hls_list_size 600 -hls_flags append_list+delete_segments+omit_endlist -hls_segment_filename /usr/share/ffplayout/public/live/stream-%d.ts /usr/share/ffplayout/public/live/stream.m3u8", FOREIGN KEY (channel_id) REFERENCES channels (id) ON UPDATE CASCADE ON DELETE CASCADE diff --git a/scripts/build.sh b/scripts/build.sh index e5a09ac7..bab16705 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -3,7 +3,7 @@ source $(dirname "$0")/man_create.sh target=$1 -if [ ! -f 'ffplayout-frontend/package.json' ]; then +if [ ! -f 'frontend/package.json' ]; then git submodule update --init fi @@ -34,10 +34,9 @@ for target in "${targets[@]}"; do cross build --release --target=$target - cp ./target/${target}/release/ffpapi.exe . cp ./target/${target}/release/ffplayout.exe . - zip -r "ffplayout-v${version}_${target}.zip" assets docker docs LICENSE README.md CHANGELOG.md ffplayout.exe ffpapi.exe -x *.db -x *.db-shm -x *.db-wal -x '11-ffplayout' -x *.service - rm -f ffplayout.exe ffpapi.exe + zip -r "ffplayout-v${version}_${target}.zip" assets docker docs LICENSE README.md CHANGELOG.md ffplayout.exe -x *.db -x *.db-shm -x *.db-wal -x '11-ffplayout' -x *.service + rm -f ffplayout.exe else if [[ -f "ffplayout-v${version}_${target}.tar.gz" ]]; then rm -f "ffplayout-v${version}_${target}.tar.gz" @@ -45,20 +44,19 @@ for target in "${targets[@]}"; do cross build --release --target=$target - cp ./target/${target}/release/ffpapi . cp ./target/${target}/release/ffplayout . - tar -czvf "ffplayout-v${version}_${target}.tar.gz" --exclude='*.db' --exclude='*.db-shm' --exclude='*.db-wal' assets docker docs LICENSE README.md CHANGELOG.md ffplayout ffpapi - rm -f ffplayout ffpapi + tar -czvf "ffplayout-v${version}_${target}.tar.gz" --exclude='*.db' --exclude='*.db-shm' --exclude='*.db-wal' assets docker docs LICENSE README.md CHANGELOG.md ffplayout + rm -f ffplayout fi echo "" done if [[ "${#targets[@]}" == "5" ]] || [[ $targets == "x86_64-unknown-linux-musl" ]]; then - cargo deb --no-build --target=x86_64-unknown-linux-musl -p ffplayout --manifest-path=ffplayout-engine/Cargo.toml -o ffplayout_${version}-1_amd64.deb - cargo generate-rpm --payload-compress none --target=x86_64-unknown-linux-musl -p ffplayout-engine -o ffplayout-${version}-1.x86_64.rpm + cargo deb --no-build --target=x86_64-unknown-linux-musl -p ffplayout --manifest-path=ffplayout/Cargo.toml -o ffplayout_${version}-1_amd64.deb + cargo generate-rpm --payload-compress none --target=x86_64-unknown-linux-musl -p ffplayout -o ffplayout-${version}-1.x86_64.rpm fi if [[ "${#targets[@]}" == "5" ]] || [[ $targets == "aarch64-unknown-linux-gnu" ]]; then - cargo deb --no-build --target=aarch64-unknown-linux-gnu --variant=arm64 -p ffplayout --manifest-path=ffplayout-engine/Cargo.toml -o ffplayout_${version}-1_arm64.deb + cargo deb --no-build --target=aarch64-unknown-linux-gnu --variant=arm64 -p ffplayout --manifest-path=ffplayout/Cargo.toml -o ffplayout_${version}-1_arm64.deb fi diff --git a/scripts/man_create.sh b/scripts/man_create.sh index 56ce34ca..006c61f6 100755 --- a/scripts/man_create.sh +++ b/scripts/man_create.sh @@ -1,11 +1,11 @@ #!/usr/bin/bash yes | rm -f assets/ffplayout.1.gz -yes | rm -f assets/ffpapi.1.gz engine_docs=( "README.md" - "ffplayout-engine/README.md" + "docs/api.md" + "ffplayout/README.md" "docs/install.md" "docs/output.md" "docs/live_ingest.md" @@ -18,7 +18,5 @@ api_docs=( ) pandoc "${engine_docs[@]}" -s --wrap=preserve -t man -o assets/ffplayout.1 -pandoc "${api_docs[@]}" -s --wrap=preserve -t man -o assets/ffpapi.1 gzip assets/ffplayout.1 -gzip assets/ffpapi.1