LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   help converting tv recordings to mp4 (https://www.linuxquestions.org/questions/linux-software-2/help-converting-tv-recordings-to-mp4-4175469988/)

xmrkite 07-17-2013 04:22 PM

help converting tv recordings to mp4
 
I'm trying to get my mythtv recordings onto my android phone and tablet so I can take some of them on the road. I want to get them to h264 mp4 files.

I threw a few of the video files and tried this script below:


for file in *mpg
do
avconv -i "$file" -vcodec libx264 -pre:v libx264-slow -b:v 1024k -pass 1 -an -f mp4 - &&
avconv -i "$file" -vcodec libx264 -pre:v libx264-slow -b:v 1024k -pass 2 -acodec aac -ab 128k "$file".mp4
done



However, I get the following errors as it tries to process the video:


[mpegts @ 0x82e8260] Continuity check failed for pid 48 expected 7 got 10
[mpegts @ 0x82e8260] Continuity check failed for pid 0 expected 14 got 1
[mpegts @ 0x82e8260] max_analyze_duration reached
[mpegts @ 0x82e8260] PES packet size mismatch


and:
[mp4 @ 0x82efdc0] muxer does not support non seekable output

and lastly:
Could not write header for output file #0 (incorrect codec parameters ?)


Please let me know if you have any idea where I have gone wrong. This happened with two different video files and both play just fine in their native mpg format. They're just huge and would fill my memory cards up quickly.

Thank you

eklavya 07-18-2013 01:49 AM

What is the file format of your tv recordings? Are they wmv files because the error you mentioned, I got it once for wmv files.

You are trying to use input using file, have you tried it using path of the file? Are you getting same error?

Are you sure you want to do this using command line? You can use a GUI application like avidemux or Cinelerra or Kdenlive or LIVES
I think, there should be too many recordings that's why you thought to convert using command line but if you are comfortable you can use GUI, it will not too much time consuming.

But if you want to convert using command like using loops just like you are trying, you can use ffmpeg, it is best converter for command line.

If we talk about your error
Quote:

muxer does not support non seekable output
It appears that the muxer only supports one audio or one video stream, not an audio and a video stream.

propofol 07-18-2013 02:10 AM

If would like to try an alternative: I switched from ffmpeg to using HandBrakeCLI and found it works very well. If you are interested, I can post the script I use to do a batch conversion.

Regards,
Stefan

xmrkite 07-18-2013 06:09 AM

These are recorded to my mythtv via my hdhomerun device. I'm very fine using handbrake and didn't realize they have a cli to use.

I'd prefer to use the command line since I have a lot of recordings, so any scripts you can post will be very appreciated.
I tried ffmpeg but it gave me different errors and actually recommened to use avconv, so that's why i went that route.
--Thanks

H_TeXMeX_H 07-18-2013 08:18 AM

Post the specifications of the input files:
Code:

avconv -i input.mpg
If you need anything specific for the output, then also post that. x264 and aac is noted.

Currently I recommend something like:

Code:

ffmpeg -i input.mkv -vcodec libx264 -vpre special -crf 15 -s 640x272 -aspect 640:272 -r 23.976 -threads 4 -acodec libvo_aacenc -ab 128k -ar 48000 -async 48000 -ac 2 -scodec copy output.mp4
You can use whatever preset you want. Most of this should work with avconv as it is just a fork.

xmrkite 07-18-2013 11:16 AM

H_TeXMeX_H:

avconv version 0.8.6-4:0.8.6-0ubuntu0.12.04.1, Copyright (c) 2000-2013 the Libav developers
built on Apr 2 2013 17:00:59 with gcc 4.6.3
[mpegts @ 0x9c31260] Continuity check failed for pid 48 expected 7 got 10
[mpegts @ 0x9c31260] Continuity check failed for pid 0 expected 14 got 1
[mpegts @ 0x9c31260] max_analyze_duration reached
[mpegts @ 0x9c31260] PES packet size mismatch
Input #0, mpegts, from 'The Outlaw Josey Wales.mpg':
Duration: 03:00:10.80, start: 75202.222522, bitrate: 6354 kb/s
Program 1
Stream #0.0[0x31]: Video: mpeg2video (Main), yuv420p, 1280x720 [PAR 1:1 DAR 16:9], 19392 kb/s, 59.96 fps, 59.94 tbr, 90k tbn, 119.88 tbc
Stream #0.1[0x34]: Audio: ac3, 48000 Hz, stereo, s16, 192 kb/s
At least one output file must be specified




Do you have any scripts to run it with the second pass? I'd like to specify the bitrate.

H_TeXMeX_H 07-18-2013 11:26 AM

I recommend variable bitrate over constant bitrate for better quality. However, if the devices are limited in their capabilities:
Code:

ffmpeg -i input.mpg -vcodec libx264 -b:v 1024k -s 1280x720 -aspect 1280:720 -r 30 -acodec libvo_aacenc -ab 128k -ar 48000 -async 48000 -ac 2 -pass 1 -an -f rawvideo -y /dev/null
ffmpeg -i input.mpg -vcodec libx264 -b:v 1024k -s 1280x720 -aspect 1280:720 -r 30 -acodec libvo_aacenc -ab 128k -ar 48000 -async 48000 -ac 2 -pass 2 output.mp4

Also, is the input interlaced ? In which case it would need de-interlacing to not tear, unless you have some hardware de-interlacing.

xmrkite 07-18-2013 11:35 AM

Thanks Texmex, it is processing right now. Variable is what I prefer, I guess I should have said I want a predetermined file size and that's what the second pass will let me do.

These recordings are HDTV broadcasts...so do i need to deinterlace them? Can I check somehow if the video is interlaced? If so, how would I do that and how would I deinterlace it?
-Thanks

H_TeXMeX_H 07-18-2013 01:31 PM

HDTV can be interlaced. Usually frame rates of 50 or 60 give it away, like it is here. You could try running it in mplayer on the command line, it should say. You can also tell when playing them that they have horizontal lines that tend to tear on non-CRT screens:
http://en.wikipedia.org/wiki/Interla...by_interlacing

You can use the '-deinterlace' option, but check the output, because there may be consequences. I usually use mencoder for deinterlacing, and the results are quite good.

xmrkite 07-18-2013 05:40 PM

Ok, so I tried:

ffmpeg -i input.mpg -vcodec libx264 -b:v 1024k -s 1280x720 -aspect 1280:720 -r 30 -acodec libvo_aacenc -ab 128k -ar 48000 -async 48000 -ac 2 -pass 1 -an -f rawvideo -y /dev/null
ffmpeg -i input.mpg -vcodec libx264 -b:v 1024k -s 1280x720 -aspect 1280:720 -r 30 -acodec libvo_aacenc -ab 128k -ar 48000 -async 48000 -ac 2 -pass 2 output.mp4


And it goes through the first pass just fine, but for the second pass it errors out and says:


[libx264 @ 0x8af0fe0] constant rate-factor is incompatible with 2pass.
Output #0, mp4, to 'test.mp4':
Stream #0.0: Video: libx264, yuv420p, 528x480 [PAR 40:33 DAR 4:3], q=-1--1, pass 2, 90k tbn, 30 tbc
Stream #0.1(eng): Audio: libvo_aacenc, 48000 Hz, stereo, s16, 200 kb/s
Stream mapping:
Stream #0.0 -> #0.0
Stream #0.1 -> #0.1
Error while opening encoder for output stream #0.0 - maybe incorrect parameters such as bit_rate, rate, width or height



Any ideas?

-Thanks

H_TeXMeX_H 07-19-2013 01:57 AM

It doesn't make sense. I know the '-crf' option is not compatible with 2 pass encoding, but you are not using it. Two pass encoding is usually used with mpeg4/xvid not x264, where crf and quantizer based one pass encoding is preferred.

xmrkite 07-19-2013 01:34 PM

Ok I think I got it with this:


for file in *mpg
do

ffmpeg -y -i "$file" -vcodec libx264 -b 1024k -pass 1 -an -f mp4 /dev/null
ffmpeg -y -i "$file" -vcodec libx264 -b 1024k -pass 2 -acodec libvo_aacenc -ab 128k "$file".mp4

done



It's encoding now and seems to work. I will report back when it finishes. it will take a whole day or so as it's a huge file that is being encoded. The key I think was changing the -b:v to simply -b

This new script just leaves the resolution alone which is great because tv recodings come in all different recording sizes. HD has 2 different sizes and SD has about 5-6 different sizes and varies depends on the stations. I think the reason it thought I was doing crf is because I had used a preset. I just dropped the preset and stuck with putting in my bitrate.

xmrkite 07-20-2013 02:13 PM

Ok, this new script works perfectly. The videos look fantastic and I am in the process of converting about 70 recordings over to .mp4.

Thanks again for all help received.


All times are GMT -5. The time now is 04:20 AM.