graham-walker / youtube-dl-react-viewer

Web app for youtube-dl/yt-dlp, created using the MERN stack
https://react.gwalkerux.com/
MIT License
92 stars 9 forks source link

Playback in Docker container not want to works #7

Closed kodxana closed 1 year ago

kodxana commented 3 years ago

When I try playback video downloaded I get unknown format error when I enable trans-coding I get this error in console.


node:events:306

      throw er; // Unhandled 'error' event

      ^

Error: Output stream closed

    at Timeout._onTimeout (/opt/youtube-dl-react-viewer/youtube-dl-express-backend/node_modules/fluent-ffmpeg/lib/processor.js:491:25)

    at listOnTimeout (node:internal/timers:556:17)

    at processTimers (node:internal/timers:499:7)

Emitted 'error' event on FfmpegCommand instance at:

    at emitEnd (/opt/youtube-dl-react-viewer/youtube-dl-express-backend/node_modules/fluent-ffmpeg/lib/processor.js:424:16)

    at Timeout._onTimeout (/opt/youtube-dl-react-viewer/youtube-dl-express-backend/node_modules/fluent-ffmpeg/lib/processor.js:491:17)

    at listOnTimeout (node:internal/timers:556:17)

    at processTimers (node:internal/timers:499:7)
JamoDevNich commented 3 years ago

Need some more info to try and figure out what is causing this issue.

As a workaround, you may be able to avoid transcoding by changing the downloaded video container from MKV to MP4. This is doneby going to the job settings, and modifying the format code to bestvideo[ext=mp4]+bestaudio[ext=m4a]/mp4. Under the advanced options, you would also need to remove --merge-output-format mkv. Please note this might cause issues when downloading videos from a site which does not provide MP4 files, and that it only applies to new downloads

kodxana commented 3 years ago
  1. Version: 1.1.0
  2. Only one in 240p one
  3. Yes video plays without problem on local PC (server do not have GUI :) )
JamoDevNich commented 3 years ago

Are any of the videos 'flv' files? The utilities to transcode those videos aren't in the docker image by default.


If you still are running into transcoding issues since updating to version 1.1.1, would it be possible for you to add some extra logging to the transcoder? This involves modifying some of the code. This can be done with a one-liner in the shell, or manually if you prefer.

Both methods are provided below:

Option 1: Shell

Instructions:

  1. Launch a shell into your docker container
  2. Run the following script in the container shell:
    sed -i '/    ffmpeg(videoPath)/a .on('\''stderr'\'', function(stderrLine) {console.log('\''FFMPEG stderr: '\'' + stderrLine);}).on('\''error'\'', function(err, stdout, stderr) {console.log('\''FFMPEG cannot process video: '\'' + err.message);}).on('\''end'\'', function(stdout, stderr) {console.log('\''FFMPEG transcoding completed.'\'');})' /opt/youtube-dl-react-viewer/youtube-dl-express-backend/index.js
  3. Restart the container

OR

Option 2: Manually

Change the following lines in youtube-dl-express-backend/index.js: https://github.com/graham-walker/youtube-dl-react-viewer/blob/3c51b6d86db53459fbd3b5411aebe68cf3696f9a/youtube-dl-express-backend/index.js#L59-L66 to this

// Transcode videos
app.use('/transcoded/videos', globalPasswordMiddleware, (req, res) => {
    res.contentType('webm');
    const videoPath = path.join(outputDirectory, 'videos', decodeURIComponent(req.path));
    ffmpeg(videoPath)
        .on('stderr', function(stderrLine) {console.log('Stderr output: ' + stderrLine);})
        .on('error', function(err, stdout, stderr) {console.log('Cannot process video: ' + err.message);})
        .on('end', function(stdout, stderr) {console.log('Transcoding succeeded !');})
        .format('webm')
        .pipe(res, { end: true });
});
graham-walker commented 1 year ago

Transcoding is no longer a supported feature, please use the open in VLC button or recoding option instead.