Difference between revisions of "Mythtranscode"
(→Choosing a Recording) |
Tastyllama (talk | contribs) (→Troubleshooting) |
||
(22 intermediate revisions by 9 users not shown) | |||
Line 3: | Line 3: | ||
= Usage = | = Usage = | ||
<pre> | <pre> | ||
− | + | Misc. Options: | |
− | + | --chanid Specify chanid of recording to operate on. | |
− | + | -i OR --infile Input video for transcoding. | |
+ | -o OR --outfile Optional output file for transcoding. | ||
+ | -O OR --override-setting Override a single setting defined by a key=value | ||
+ | pair. | ||
+ | --override-settings-file Define a file of key=value pairs to be loaded for | ||
+ | setting overrides. | ||
+ | --queue Add a new transcoding job of the specified recording | ||
+ | and profile to the jobqueue. Accepts an optional | ||
+ | string to define the hostname. | ||
+ | -b OR --buildindex Build new keyframe index. | ||
+ | -h OR --help OR --usage Display this help printout, or give detailed | ||
+ | information of selected option. | ||
+ | --version Display version information. | ||
+ | --starttime Specify start time of recording to operate on. | ||
+ | --video Specifies video is not a recording. | ||
− | + | Encoding Options: | |
− | + | --allkeys OR -k Specifies the outputfile should be entirely | |
− | + | keyframes. | |
− | + | --audiotrack Select specific audio track. | |
− | + | --avf Generate libavformat output file. | |
− | + | --audiobitrate Output Audio Bitrate (Kbits) | |
− | + | --bitrate Output Video Bitrate (Kbits) | |
− | + | --height Output Video Height | |
− | + | --width Output Video Width | |
− | + | --hls Generate HTTP Live Stream output. | |
− | + | --audiobitrate Output Audio Bitrate (Kbits) | |
− | + | --bitrate Output Video Bitrate (Kbits) | |
− | + | --height Output Video Height | |
+ | --hlsstreamid Stream ID to process | ||
+ | --maxsegments Max HTTP Live Stream segments | ||
+ | --noaudioonly Disable Audio-Only HLS Stream | ||
+ | --width Output Video Width | ||
+ | -m OR --mpeg2 Specifies that a lossless transcode should be used. | ||
+ | -e OR --ostream Output stream type: dvd, ts | ||
+ | --passthrough Pass through raw, unprocessed audio. | ||
+ | -p OR --profile Transcoding profile. | ||
+ | -ro OR --recorderOptions Comma separated list of recordingprofile overrides. | ||
− | + | Frame Server Options: | |
− | + | --cleancut Improve quality of cutting by performing it | |
− | + | partially by dropping data. Works only in fifodir | |
− | + | mode. | |
− | + | -f OR --fifodir Directory in which to write fifos to. | |
− | + | --fifoinfo Run in fifodir mode, but stop after displaying the | |
− | + | fifo data format. | |
+ | --fifosync Enforce fifo sync. | ||
+ | |||
+ | Logging Options: | ||
+ | --enable-dblog Enable logging to database. | ||
+ | --loglevel Set the logging level. All log messages at lower | ||
+ | levels will be discarded. | ||
+ | In descending order: emerg, alert, crit, err, | ||
+ | warning, notice, info, debug | ||
+ | defaults to info | ||
+ | --logpath Writes logging messages to a file in the directory | ||
+ | logpath with filenames in the format: | ||
+ | applicationName.date.pid.log. | ||
+ | This is typically used in combination with --daemon, | ||
+ | and if used in combination with --pidfile, this can | ||
+ | be used with log rotators, using the HUP call to | ||
+ | inform MythTV to reload the file | ||
+ | --nologserver Disable all logging but console. | ||
+ | -q OR --quiet Don't log to the console (-q). Don't log anywhere | ||
+ | (-q -q) | ||
+ | --showprogress Display status info in stdout | ||
+ | --syslog Set the syslog logging facility. | ||
+ | Set to "none" to disable, defaults to none. | ||
+ | -v OR --verbose Specify log filtering. Use '-v help' for level info. | ||
+ | |||
+ | Cutlist Options: | ||
+ | --inversecut Inverses the cutlist, leaving only the marked off | ||
+ | sections. | ||
+ | --honorcutlist Specifies whether to use the cutlist. (Takes an | ||
+ | optional cutlist as argument when used with -i) | ||
</pre> | </pre> | ||
+ | |||
== Choosing a Recording == | == Choosing a Recording == | ||
Two methods are available to choose which recording to work on. The first is to specify the channelid and start time, | Two methods are available to choose which recording to work on. The first is to specify the channelid and start time, | ||
Line 39: | Line 92: | ||
{{Note box|Specifying the filepath only works if the recording's filename is formatted the default way.}} | {{Note box|Specifying the filepath only works if the recording's filename is formatted the default way.}} | ||
− | When using the <code>--infile</code> option, mythtranscode will use the filename to lookup the recordings in the [[recorded table]] and find the corresponding chanid and start-time. Non-default filenames, such as those renamed with [[ | + | When using the <code>--infile</code> option, mythtranscode will use the filename to lookup the recordings in the [[recorded table]] and find the corresponding chanid and start-time. Non-default filenames, such as those renamed with [[mythrename.pl]], prevent mythtranscode from doing so (and it complains of this), but it still proceeds with the transcode anyway, confusing the user. The resulting mythtranscode run is useless because the utility doesn't know what [[recordedseek table|seektable]] to update with the data it found by scanning through the recording. The only way around this and have the transcoding succeed is: |
# First rename the recording back to the default format, or | # First rename the recording back to the default format, or | ||
# Instead of using the more-convenient --infile, manually specify the data mythtranscode needs with -c and -s. | # Instead of using the more-convenient --infile, manually specify the data mythtranscode needs with -c and -s. | ||
Line 55: | Line 108: | ||
* Converts the mpeg2 from a TS stream to a PS stream, possibly saving up to 20% of the file size! | * Converts the mpeg2 from a TS stream to a PS stream, possibly saving up to 20% of the file size! | ||
* Fixes Audio/Video sync issues in a similar fashion to ProjectX. | * Fixes Audio/Video sync issues in a similar fashion to ProjectX. | ||
+ | |||
+ | == Using the <code>--fifodir path</code> Option== | ||
+ | The <code>--fifodir</code> option causes mythtranscode to perform only the decoding part of transcoding, sending the raw video and raw audio to two pipes. No alteration is made to the original file. The path passed to the <code>--fifodir</code> option is assumed to refer to a directory. The two pipes will be created in that directory, with names audout and vidout. The intended use is for the raw data output to the pipes to be recompressed by an external program such as ffmpeg (that is how [[Nuvexport]] works). If <code>-v general</code> is also specified then the format of the data that will be output to the pipes is displayed. For example | ||
+ | <pre> | ||
+ | 2011-07-09 09:02:46.493 FifoVideoWidth 720 | ||
+ | 2011-07-09 09:02:46.493 FifoVideoHeight 576 | ||
+ | 2011-07-09 09:02:46.493 FifoVideoAspectRatio 1.77778 | ||
+ | 2011-07-09 09:02:46.493 FifoVideoFrameRate 25 | ||
+ | 2011-07-09 09:02:46.493 FifoAudioFormat raw | ||
+ | 2011-07-09 09:02:46.493 FifoAudioChannels 2 | ||
+ | 2011-07-09 09:02:46.493 FifoAudioHz 48000 | ||
+ | </pre> | ||
+ | To display the format information without actually performing the transcoding, <code>--fifoinfo</code> can be specified, in place of <code>--fifodir path</code>. An [[Example Script using mythtranscode in fifodir mode|example script]] shows mythtranscode driving ffmpeg with libx264. The script handles progressive and interlaced recordings, either maintaining resolution or downscaling. | ||
= Examples = | = Examples = | ||
== Remove commercials from an MPEG2 recording == | == Remove commercials from an MPEG2 recording == | ||
− | First, | + | First, [[Editing_Recordings|edit the recording]]. Then: |
mythtranscode --chanid 1017 --starttime 2006-12-16-20-00-00 --mpeg2 --honorcutlist | mythtranscode --chanid 1017 --starttime 2006-12-16-20-00-00 --mpeg2 --honorcutlist | ||
This will drop the cut version beside the original, but with an added <tt>.tmp</tt> extension. I'm not exactly sure what it does to the database. It seems to keep the cutpoints and points at the old <tt>.mpg</tt> file, but shortens how long it thinks the movie is to the size of the <tt>.tmp</tt> file. | This will drop the cut version beside the original, but with an added <tt>.tmp</tt> extension. I'm not exactly sure what it does to the database. It seems to keep the cutpoints and points at the old <tt>.mpg</tt> file, but shortens how long it thinks the movie is to the size of the <tt>.tmp</tt> file. | ||
+ | Alternatively, you can add the -o option. This is useful for exporting to a different directory. For example | ||
+ | mythtranscode -c 1003 -s 20090907113000 -m -l -o /myth/video/myvid.mpg | ||
+ | Note that -c is --channel, -s is --starttime, -m is --mpeg2 and -l is --honorcutlist | ||
{{Stub}} | {{Stub}} | ||
− | |||
− | |||
= Troubleshooting = | = Troubleshooting = | ||
Line 72: | Line 139: | ||
{| border="1" | {| border="1" | ||
|- | |- | ||
− | ! | + | ! Code !! Name !! Possible Causes !! References |
|- | |- | ||
− | || | + | | 139 || SIG_SEGV |
+ | | System generated, segfault. Please submit a ticket with the backtrace from your core dump. || | ||
|- | |- | ||
− | || | + | | 227 || TRANSCODE_BUGGY_EXIT_DEADLOCK |
+ | | "Deadlock detected. One buffer is full when the other is empty!" || | ||
|- | |- | ||
− | || | + | | || |
+ | | Cut list contains a cut zone with a beginning but no ending (often at the very end of the recording) || none | ||
|- | |- | ||
− | || | + | | 235 || TRANSCODE_EXIT_STOPPED |
+ | | Transcode was stopped manually by the jobqueue. || | ||
|- | |- | ||
+ | | 236 || TRANSCODE_EXIT_ERROR_CUTLIST_UPDATE | ||
+ | | Transcode failed to clear cutlist. || | ||
+ | |- | ||
+ | | 237 || TRANSCODE_EXIT_REMOTE_FILE | ||
+ | | File is on a remote filesystem. mythtranscode does not yet handle these files. Check if the Job runs on a slave backend. || none | ||
+ | |- | ||
+ | | 238 || TRANSCODE_EXIT_NO_RECORDING_DATA | ||
+ | | Jobqueue entry, or matching recording, could not be found. || | ||
+ | |- | ||
+ | | 247 || TRANSCODE_EXIT_UNKNOWN_ERROR | ||
+ | | See log files for more information. || [http://www.gossamer-threads.com/lists/mythtv/users/248308#248308] [http://www.gossamer-threads.com/lists/mythtv/users/248308#248308] | ||
+ | |- | ||
+ | | 250 || TRANSCODE_EXIT_DB_ERROR | ||
+ | | Database could not be accessed. || | ||
+ | |- | ||
+ | | 252 || TRANSCODE_EXIT_INVALID_CMDLINE | ||
+ | | Invalid command line. The transcoder is being called directly, improperly. || | ||
+ | |- | ||
+ | | 254 || TRANSCODE_EXIT_NO_MYTHCONTEXT | ||
+ | | No MythContext. Could not initialize properly. || | ||
+ | |- | ||
+ | | 255 || UNRECOVERABLE ERROR | ||
+ | | Could be you didn't setup profiles in mythbackend. Try checking mythtranscode.log|| | ||
+ | |- | ||
+ | |} | ||
− | + | == Fixing "Deadlock detected. One buffer is full when the other is empty!" == | |
− | + | If your transcode fails because this error, you can remux the video and try again. Mythtv's keyframe index will be wrong for the remuxed file, so you must also regenerate the index. And then it's sensible to reposition your cut points incase they are off. So the procedure is | |
+ | |||
+ | * Determine the file for the recording in question | ||
+ | * Remux the file: | ||
+ | ffmpeg -i <filename> -acodec copy -vcodec copy <tmpfilename> | ||
+ | rm <filename> | ||
+ | mv <tmpfilename> <filename> | ||
+ | * Regenerate the keyframe index: | ||
+ | mythtranscode --mpeg2 --buildindex --allkeys --showprogress --infile <filename> | ||
+ | * Reposition the cut points | ||
+ | * Try trancoding again | ||
+ | |||
+ | If this does not fix the problem then you can try using [[Mythcutprojectx]] to perform the cutting. | ||
+ | |||
+ | [[Category:MythTV_Software]] |
Latest revision as of 04:41, 20 March 2017
Mythtranscode is the internal process used by the front end to transcode MythTV recordings. For lossless transcodes, calling the program through the command line has been known to work sometimes when the normal method fails.
Contents
Usage
Misc. Options: --chanid Specify chanid of recording to operate on. -i OR --infile Input video for transcoding. -o OR --outfile Optional output file for transcoding. -O OR --override-setting Override a single setting defined by a key=value pair. --override-settings-file Define a file of key=value pairs to be loaded for setting overrides. --queue Add a new transcoding job of the specified recording and profile to the jobqueue. Accepts an optional string to define the hostname. -b OR --buildindex Build new keyframe index. -h OR --help OR --usage Display this help printout, or give detailed information of selected option. --version Display version information. --starttime Specify start time of recording to operate on. --video Specifies video is not a recording. Encoding Options: --allkeys OR -k Specifies the outputfile should be entirely keyframes. --audiotrack Select specific audio track. --avf Generate libavformat output file. --audiobitrate Output Audio Bitrate (Kbits) --bitrate Output Video Bitrate (Kbits) --height Output Video Height --width Output Video Width --hls Generate HTTP Live Stream output. --audiobitrate Output Audio Bitrate (Kbits) --bitrate Output Video Bitrate (Kbits) --height Output Video Height --hlsstreamid Stream ID to process --maxsegments Max HTTP Live Stream segments --noaudioonly Disable Audio-Only HLS Stream --width Output Video Width -m OR --mpeg2 Specifies that a lossless transcode should be used. -e OR --ostream Output stream type: dvd, ts --passthrough Pass through raw, unprocessed audio. -p OR --profile Transcoding profile. -ro OR --recorderOptions Comma separated list of recordingprofile overrides. Frame Server Options: --cleancut Improve quality of cutting by performing it partially by dropping data. Works only in fifodir mode. -f OR --fifodir Directory in which to write fifos to. --fifoinfo Run in fifodir mode, but stop after displaying the fifo data format. --fifosync Enforce fifo sync. Logging Options: --enable-dblog Enable logging to database. --loglevel Set the logging level. All log messages at lower levels will be discarded. In descending order: emerg, alert, crit, err, warning, notice, info, debug defaults to info --logpath Writes logging messages to a file in the directory logpath with filenames in the format: applicationName.date.pid.log. This is typically used in combination with --daemon, and if used in combination with --pidfile, this can be used with log rotators, using the HUP call to inform MythTV to reload the file --nologserver Disable all logging but console. -q OR --quiet Don't log to the console (-q). Don't log anywhere (-q -q) --showprogress Display status info in stdout --syslog Set the syslog logging facility. Set to "none" to disable, defaults to none. -v OR --verbose Specify log filtering. Use '-v help' for level info. Cutlist Options: --inversecut Inverses the cutlist, leaving only the marked off sections. --honorcutlist Specifies whether to use the cutlist. (Takes an optional cutlist as argument when used with -i)
Choosing a Recording
Two methods are available to choose which recording to work on. The first is to specify the channelid and start time,
--chanid 1067 --starttime 20080109223000
The other method is to specify the file,
--infile /MythTV/tv/1856_20060425200000.mpg
When using the --infile
option, mythtranscode will use the filename to lookup the recordings in the recorded table and find the corresponding chanid and start-time. Non-default filenames, such as those renamed with mythrename.pl, prevent mythtranscode from doing so (and it complains of this), but it still proceeds with the transcode anyway, confusing the user. The resulting mythtranscode run is useless because the utility doesn't know what seektable to update with the data it found by scanning through the recording. The only way around this and have the transcoding succeed is:
- First rename the recording back to the default format, or
- Instead of using the more-convenient --infile, manually specify the data mythtranscode needs with -c and -s.
--honorcutlist
Limitation
--honorcutlist
only seems to work (0.19-fixes [9938]) with the "-c -s" switch combo, NOT with a specified input (-i) file, even if that file is in the mythconverg database.
Using the --buildindex
Option
The --buildindex
option can be used for rebuilding/repairing the seektable.
Using the --mpeg2
Option for (Virtually) Lossless MPEG2 Transcode
New in 0.19 is a virtually lossless MPEG2 transcode. What this does is let you select cut points and mythtranscode will only re-encode the frames that need to be, copying the rest directly from the stream. If you are using this to cut commercials and you cut at the black frames of a fade to black (or white of a fade to white), what you get is basically a perfect stream copy of the video with no loss to the frames that matter.
This also has some side benefits,
- Converts the mpeg2 from a TS stream to a PS stream, possibly saving up to 20% of the file size!
- Fixes Audio/Video sync issues in a similar fashion to ProjectX.
Using the --fifodir path
Option
The --fifodir
option causes mythtranscode to perform only the decoding part of transcoding, sending the raw video and raw audio to two pipes. No alteration is made to the original file. The path passed to the --fifodir
option is assumed to refer to a directory. The two pipes will be created in that directory, with names audout and vidout. The intended use is for the raw data output to the pipes to be recompressed by an external program such as ffmpeg (that is how Nuvexport works). If -v general
is also specified then the format of the data that will be output to the pipes is displayed. For example
2011-07-09 09:02:46.493 FifoVideoWidth 720 2011-07-09 09:02:46.493 FifoVideoHeight 576 2011-07-09 09:02:46.493 FifoVideoAspectRatio 1.77778 2011-07-09 09:02:46.493 FifoVideoFrameRate 25 2011-07-09 09:02:46.493 FifoAudioFormat raw 2011-07-09 09:02:46.493 FifoAudioChannels 2 2011-07-09 09:02:46.493 FifoAudioHz 48000
To display the format information without actually performing the transcoding, --fifoinfo
can be specified, in place of --fifodir path
. An example script shows mythtranscode driving ffmpeg with libx264. The script handles progressive and interlaced recordings, either maintaining resolution or downscaling.
Examples
Remove commercials from an MPEG2 recording
First, edit the recording. Then:
mythtranscode --chanid 1017 --starttime 2006-12-16-20-00-00 --mpeg2 --honorcutlist
This will drop the cut version beside the original, but with an added .tmp extension. I'm not exactly sure what it does to the database. It seems to keep the cutpoints and points at the old .mpg file, but shortens how long it thinks the movie is to the size of the .tmp file. Alternatively, you can add the -o option. This is useful for exporting to a different directory. For example
mythtranscode -c 1003 -s 20090907113000 -m -l -o /myth/video/myvid.mpg
Note that -c is --channel, -s is --starttime, -m is --mpeg2 and -l is --honorcutlist
Troubleshooting
Every once in a while, something will happen and transcoding will not be able to complete. When this happens, the Job Queue will indicate the failure by turning the job title red in color. It will also say "Job: Transcode Status: Errored", and will follow with the line "Transcode failed with status: ###"
When this happens, you can often find information in the backend logs.. otherwise you can check this list to see if your error status matches any that others have encountered:
Code | Name | Possible Causes | References |
---|---|---|---|
139 | SIG_SEGV | System generated, segfault. Please submit a ticket with the backtrace from your core dump. | |
227 | TRANSCODE_BUGGY_EXIT_DEADLOCK | "Deadlock detected. One buffer is full when the other is empty!" | |
Cut list contains a cut zone with a beginning but no ending (often at the very end of the recording) | none | ||
235 | TRANSCODE_EXIT_STOPPED | Transcode was stopped manually by the jobqueue. | |
236 | TRANSCODE_EXIT_ERROR_CUTLIST_UPDATE | Transcode failed to clear cutlist. | |
237 | TRANSCODE_EXIT_REMOTE_FILE | File is on a remote filesystem. mythtranscode does not yet handle these files. Check if the Job runs on a slave backend. | none |
238 | TRANSCODE_EXIT_NO_RECORDING_DATA | Jobqueue entry, or matching recording, could not be found. | |
247 | TRANSCODE_EXIT_UNKNOWN_ERROR | See log files for more information. | [1] [2] |
250 | TRANSCODE_EXIT_DB_ERROR | Database could not be accessed. | |
252 | TRANSCODE_EXIT_INVALID_CMDLINE | Invalid command line. The transcoder is being called directly, improperly. | |
254 | TRANSCODE_EXIT_NO_MYTHCONTEXT | No MythContext. Could not initialize properly. | |
255 | UNRECOVERABLE ERROR | Could be you didn't setup profiles in mythbackend. Try checking mythtranscode.log |
Fixing "Deadlock detected. One buffer is full when the other is empty!"
If your transcode fails because this error, you can remux the video and try again. Mythtv's keyframe index will be wrong for the remuxed file, so you must also regenerate the index. And then it's sensible to reposition your cut points incase they are off. So the procedure is
- Determine the file for the recording in question
- Remux the file:
ffmpeg -i <filename> -acodec copy -vcodec copy <tmpfilename> rm <filename> mv <tmpfilename> <filename>
- Regenerate the keyframe index:
mythtranscode --mpeg2 --buildindex --allkeys --showprogress --infile <filename>
- Reposition the cut points
- Try trancoding again
If this does not fix the problem then you can try using Mythcutprojectx to perform the cutting.