Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FFmpeg error while embedding subtitles in lynda.com videos #9063

Closed
xty opened this issue Apr 2, 2016 · 7 comments
Closed

FFmpeg error while embedding subtitles in lynda.com videos #9063

xty opened this issue Apr 2, 2016 · 7 comments
Labels

Comments

@xty
Copy link

@xty xty commented Apr 2, 2016

Make sure you are using the latest version: run youtube-dl --version and ensure your version is 2016.04.01.

  • I've verified and I assure that I'm running youtube-dl 2016.04.01

Before submitting an issue make sure you have:

  • At least skimmed through README and most notably FAQ and BUGS sections
  • Searched the bugtracker for similar issues including closed ones

What is the purpose of your issue?

  • Bug report (encountered problems with youtube-dl)
  • Site support request (request for adding support for a new site)
  • Feature request (request for a new functionality)
  • Question
  • Other

If the purpose of this issue is a bug report, site support request or you are not completely sure provide the full verbose output as follows:

$ youtube-dl -v -o '%(playlist_index)s - %(title)s.%(ext)s' --write-sub --embed-subs --cookies cookies.txt 'https://www.lynda.com/JavaScript-tutorials/JavaScript-Essential-Training/81266-2.html'
[debug] System config: []
[debug] User config: []
[debug] Command-line args: [u'-v', u'-o', u'%(playlist_index)s - %(title)s.%(ext)s', u'--write-sub', u'--embed-subs', u'--cookies', u'cookies.txt', u'https://www.lynda.com/JavaScript-tutorials/JavaScript-Essential-Training/81266-2.html']
[debug] Encodings: locale UTF-8, fs UTF-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2016.04.01
[debug] Python version 2.7.9 - Linux-3.19.0-42-generic-x86_64-with-Ubuntu-15.04-vivid
[debug] exe versions: ffmpeg 2.5.10-0ubuntu0.15.04.1, ffprobe 2.5.10-0ubuntu0.15.04.1, rtmpdump 2.4
[debug] Proxy map: {}
[lynda:course] 81266: Downloading course JSON
[download] Downloading playlist: JavaScript Essential Training
[lynda:course] playlist JavaScript Essential Training: Collected 56 video ids (downloading 56 of them)
[download] Downloading video 1 of 56
[lynda] 87513: Downloading video JSON
[lynda] 87513: Checking 1-540 video format URL
[lynda] 87513: Checking 1-360 video format URL
[lynda] 87513: Checking 0-540 video format URL
[lynda] 87513: Checking 0-360 video format URL
[lynda] 87513: Checking 2-540 video format URL
[lynda] 87513: Checking 2-360 video format URL
[info] Writing video subtitles to: 01 - Welcome.en.srt
[debug] Invoking downloader on u'http://files2.lynda.com/secure/courses/81266/VBR_MP4h264_main_SD/81266_00_01_SC03_Welcome.mp4?c3.ri=3774139467965391321&hashval=1459631490_5c50bed6d920146788086cfc83296f5b'
[download] Destination: 01 - Welcome.mp4
[download] 100% of 5.13MiB in 00:02
[ffmpeg] Embedding subtitles in '01 - Welcome.mp4'
[debug] ffmpeg command line: ffmpeg -y -i 'file:01 - Welcome.mp4' -i 'file:01 - Welcome.en.srt' -map 0 -c copy -map -0:s -c:s mov_text -map 1:0 -metadata:s:s:0 language=eng 'file:01 - Welcome.temp.mp4'
ERROR: Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
Traceback (most recent call last):
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 1771, in post_process
    files_to_delete, info = pp.run(info)
  File "/usr/local/bin/youtube-dl/youtube_dl/postprocessor/ffmpeg.py", line 381, in run
    self.run_ffmpeg_multiple_files(input_files, temp_filename, opts)
  File "/usr/local/bin/youtube-dl/youtube_dl/postprocessor/ffmpeg.py", line 168, in run_ffmpeg_multiple_files
    raise FFmpegPostProcessorError(msg)
FFmpegPostProcessorError


Description of your issue, suggested solution and other information

As suggested in the title, the problem occurs when FFmpeg attempts to merge the downloaded .srt file into the .mp4 file. Consequently, the program halted, the merge failed and the downloads of all other videos in the sequence did not proceed. It is noteworthy that the only video and subtitles files that did get downloaded are complete, uncorrupted and play together nicely.

This problem was previously identified by @horusra in #8434 after it was closed:

It seems the error only occurs if I enable to embed subtitles.

Considering the aforementioned thread was closed and left unattended, and it would be ill-advised to dump various issues into one ticket, I am filing a separate issue here to make the problem resurface.

Please note that the problem is also reproducible without the use of the --username, --password (for individual login) or--cookies (for organizational login) options, as the first couple of videos in each lynda.com course are accessible even when the viewer is not logged in. That being said, I am more than willing to provide my credentials should they be required for further testing.

@jaimeMF
Copy link
Collaborator

@jaimeMF jaimeMF commented Apr 2, 2016

There seems to be some problem in the downloaded file, ffprobe <filename> report this:

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'foo.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 1
    compatible_brands: isommp41avc1
    creation_time   : 2011-07-20 02:18:20
  Duration: 00:01:01.70, start: 0.000000, bitrate: 697 kb/s
    Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv), 960x540 [SAR 1:1 DAR 16:9], 567 kb/s, 30 fps, 30 tbr, 600 tbn, 60 tbc (default)
    Metadata:
      creation_time   : 2011-07-20 02:18:20
      handler_name    : ?Apple Video Media Handler
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 126 kb/s (default)
    Metadata:
      creation_time   : 2011-07-20 02:18:20
      handler_name    : ?Apple Sound Media Handler
    Stream #0:2(eng): Data: none (mp4s / 0x7334706D), 0 kb/s (default)
    Metadata:
      creation_time   : 2011-07-20 02:18:20
      handler_name    : ?
    Stream #0:3(eng): Data: none (mp4s / 0x7334706D), 0 kb/s (default)
    Metadata:
      creation_time   : 2011-07-20 02:18:20
Unsupported codec with id 0 for input stream 2
Unsupported codec with id 0 for input stream 3

For developers: changing in the commandline -map 0 -c copy to -map 0:v -map 0:a seems to pick only the working streams, but I'm not sure that its is the correct solution and don't know if there's any downside when using them.

@xty
Copy link
Author

@xty xty commented Apr 2, 2016

This problem could potentially be related to #8855.

@jaimeMF I just tested with a dozen other lynda.com courses. All but one latest course (published on Mar 24, 2016) are giving the same error; examining the downloaded .mp4 files using ffprobe <filename> produces similar results – all of them contain stream #0:2 and stream #0:3 with no data. Effectively, subtitles cannot be embedded in most lynda.com videos using youtube-dl commands as of now.

@xty xty changed the title FFmpeg error while embedding subtitles FFmpeg error while embedding subtitles in lynda.com videos Apr 2, 2016
@jaimeMF
Copy link
Collaborator

@jaimeMF jaimeMF commented Apr 3, 2016

Yes, it seems to be the same problem.

yan12125 added a commit that referenced this issue Jul 9, 2016
[ffmpeg] Fix embedding subtitles (#9063)
@yan12125
Copy link
Collaborator

@yan12125 yan12125 commented Jul 9, 2016

Should be fixed as #9288 got merged.

Note to developers:

  1. In #9288 data and attachments are not copied. In the provided sample file mentioned above, copying data brings problems.
  2. ffmpeg's -ignore_unknown seems a better option than #9288, but it's not implemented in avconv.
@yan12125 yan12125 closed this Jul 9, 2016
yan12125 added a commit that referenced this issue Jul 15, 2016
This reverts commit ccff2c4.

Fixes #10081.

The new approach breaks embedding subtitles into video-only or
audio-only files. FFMpeg provides a trick: add '?' after the argument of
'-map' so that a missing stream is ignored. For example:

opts = [
    '-map', '0:v?',
    '-c:v', 'copy',
    '-map', '0:a?',
    '-c:a', 'copy',
    # other options...
]

Unfortunately, such a format is not implemented in avconv, either.
I guess adding '-ignore_unknown' if self.basename == 'ffmpeg' is the
best solution. However, the example mentioned in #9063 no longer serves
problematic files, so I can't test it. I'll reopen #9063 and wait for
another example so that I can test '-ignore_unknown'.
@yan12125 yan12125 reopened this Jul 15, 2016
@yan12125
Copy link
Collaborator

@yan12125 yan12125 commented Jul 15, 2016

The latest change in subtitle embedding breaks in some cases (#10081). The example above no longer serves problematic files. Do you have other examples? @xiatianyu @reyyed

@tabby-jun
Copy link
Contributor

@tabby-jun tabby-jun commented Jul 18, 2016

Hi, I'm sorry that I did not consider the cases where subtitles are embedded into video or audio only files.

The example which I relied on previously was Jekyll for Web Designers.

I've tried downloading it with the latest build of youtube-dl and did not encounter any ffmpeg error.

It's possible that there have been efforts by lynda to fix the files since both @xiatianyu and my examples no longer give problematic files.

@yan12125
Copy link
Collaborator

@yan12125 yan12125 commented Jul 18, 2016

OK I'm closing this now until someone else finds another example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.