graham-walker/youtube-dl-react-viewer

Playback in Docker container not want to works

Closed this issue · 4 comments

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)

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

  • Which version of youtube-dl-react-viewer is running in the container?
  • Are any other videos able to play with transcoding enabled?
  • Does the video play fine if downloaded to your local machine from the youtube-dl-react-viewer ui?

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

  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 :) )

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
  1. Restart the container

OR

Option 2: Manually

Change the following lines in youtube-dl-express-backend/index.js:

// Transcode videos
app.use('/transcoded/videos', globalPasswordMiddleware, (req, res) => {
res.contentType('webm');
const videoPath = path.join(outputDirectory, 'videos', decodeURIComponent(req.path));
ffmpeg(videoPath)
.format('webm')
.pipe(res, { end: true });
});

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 });
});

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