View Full Version : exporting edited HD content back to the cam using open source


Scott Frase
October 3rd, 2006, 02:09 AM
Has anyone had any luck in exporting edited HD content back to the cam
by using open source products (ffmpeg/mplex/etc)?
- if so, how did you do it?

I'm having a heck of a time formatting JVC-compatible MPEG2 headers. I
read this thread from years back:
http://www.dvinfo.net/conf/archive/index.php/t-19007.html

but I don't have a Mac to test out the export using DVHSCap. I've
simulated the rest of the steps using the import/export utility, CapDHVS
and DVHSTool, but I get close and the final result is choppy video.
I've also tried MPEG StreamClip/Womble/MPEG2Repair and nothing works.

It irks me that I cannot use open source tools to write out an HDV file
to tape! Any help would be much appreciated.

scott

Jeff Kellam
October 4th, 2006, 03:16 PM
Im not really knowledgeable about those software products.

I use the Vegas family of software.

Vegas 6 is available from B&H for $99.00. Does everything you want and far more.

As long as you are exporting a 720P m2t stream, the GR HD series will accept the stream back to the camera. It won't accept a 1080i m2t stream though.

The capture/export software tool that came with the camera is still the best.

Sorry I couldn't directly answer your question.

Graham Hickling
October 5th, 2006, 01:36 AM
I hate to say this. After much fiddling I was able to achieve writing back to tape .... about 2 years ago. And now I don't remember how I got it working!

I'm fairly sure it was one of the apps from the site that hosts Remuxts.exe. I will try and figure it out and post again if I can.

Scott Frase
October 5th, 2006, 08:18 AM
Jeff - I've heard Vegas is very good. Since I've committed myself to using Cinelerra, the Linux-based NLE, I would really like to stay in the Linux world, with the caveat that I will need to bring the files over to XP to get them back out to the cam.

In regards to the MPEG Studio Pro LE, the editor that comes with the cam, yes, that is a good product. However, it is VERY limited.

My testing trials go something like this:
- export audio as MP2
- export video as MPEG2 from Cinelerra using FFMPEG params based on the above DVinfo article from a few years back
- mux audio/video w/mplex into PS format
- bring over files from Fedora to XP and transcode to MPEGTS using VLC
- test to see if the following programs recognize/can use the file:
MPEG Studio Pro LE/TMPGenc MPEG editor 2.0/Womble
- repeat with slight tweaks to any of the above steps

Results have been:
- MPEG Studio Pro LE never recognizes any of the files I've outputted or its says "File type not supported in this version," leading me to believe that if I bought the full version of the product ("Hello, Japan?") that would resolve the issue. My suspicion is that if I ever get one of my outputted files to load correctly into MPEG Studio Pro LE, then it will export to the cam properly.
- Womble/TMPGenc do recognize the formats, but they either output bad content that the JVC export utility does not recognize (Womble) or give me errors that are not correct, like "Your file is not in the correct YUV color space to be exported as HDV" (TMPGenc)

SO frustrating!! But hopefully I can get a trial of Vegas 6.0 and test with it. I will let you know my results

On a side note for folks on the board, the TMPGenc MPEG 2.0 editor is an easy to use, graphical mux/edit utility in the vein of TMPGenc DVD Author that has good technical details on the different formats of HDV files. The site's spec page is very informative too:
http://tmpgenc.pegasys-inc.com/en/product/tme20_spec.html

Graham - You would be THE MAN if you could help me out on this one. Anything you can remember would be helpful. I will find and test with remuxts.exe. Please keep me posted.

Graham Hickling
October 5th, 2006, 01:14 PM
Scott, the application I used to write .m2t transport streams back to my JVC HD1 was WrtDVHS, which I obtained from here: http://www.yamabe.org/softbody.html

My workflow is described here: http://www.dvinfo.net/conf/showthread.php?t=27152

Scott Frase
October 5th, 2006, 06:43 PM
Hi Graham,
Thanks a lot for your post. I've read through it, but I'm still having trouble. In your post from a couple years back, I read that you exported from Premiere Pro using export to tape:
"So I tried exporting the project to a .ts file on disk, closing Premiere, and then sending the .ts file back to the camera using WRTDVHS.exe (a companion freeware app to CAPDVHS...). That worked 100%!"

However, it seems that my "export to tape" function is greyed out in Premiere. Reading the help of Premiere, the help implies that "Export to Tape" was a function used for DV. Since I'm exporting HDV, I'm wondering did you export true HDV or just DV?

I had a number of TS and PS files laying around from my other experiments, and none of them worked in WrtDVHS. I did play around with RemuxTS as well. So, I'm thinking my problem is my source file. I created the video with ffmpeg using this syntax:
ffmpeg -i mjpeg.mov -f yuv4mpegpipe - | mpeg2enc --verbose 0 --aspect 3 --format 3 --frame-rate 4 --video-bitrate 18300 --nonvideo-bitrate 384 --interlace-mode 0 --force-b-b-p --video-buffer 448 --video-norm n --keep-hf --no-constraints --sequence-header-every-gop --min-gop-size 6 --max-gop-size 6 -o mpeg2.mpv

And then muxed the audio with the video using this syntax:
mplex -f 3 -b 2000 -o programstream.ps audio.mp2 mpeg2.mpv

Once I get this, I drop the PS file into VLC and transcode to MPEGTS.

If you view the properties of a JVC HDV video in MPEG Studio LE, you'll see this output:
* Stream Type : MPEG-2 TS
Bitrate : 19750973 bps

* Video Stream Type : MPEG-2 Video
Picture Size : 1280 x 720
Aspect Ratio : 16:9
Frame Rate : 29.97 frames/sec.
Bitrate : 18300000 bps
VBV Buffer Size : 3670016 bit
Constrained Parameter Flag : Off
Profile and Level : MP@H1440L
Progressive/Interlaced Sequence : Progressive
Chroma Format : 4:2:0
Low Delay Flag : Off
Rate Control : CBR

* Audio Stream Type : MPEG-1 Audio
Layer : LayerII
Error Protection : On
Bitrate : 384000 bps
Sampling Frequency : 48000 Hz
Mode : Stereo
Copyright Flag : Off
Original or Copy : Original
De-emphasis Type : None

Does anybody know of a program that can analyse the parameters of an MPEGTS file to this detail? I'm thinking if I could see how my files are formatted, I could then make adjustments with ffmpeg to match a file that works. Next best thing to knowing what you're doing.. ;)

I will also post to the ffmpeg boards..perhaps they can help.
scott

Graham Hickling
October 5th, 2006, 07:30 PM
Hi again. In the 2004 post, I was exporting to a .ts file on disk (\Export\Movie) .... I was not exporting to a camera tape (\Export\Export to Tape).
The Export to Tape function is greyed out for you because you dont have a camera connected to your PC.

Back then I was using PremierePro5.1 with the Mainconcept HD plugin, and the plugin was doing the job of configuring the mpeg file properly, to JVC-compatible format.

So you are right, there is some tweak needed somewhere in the MPEG format... and unfortunately I can't help with that as I wasn't using ffmpeg.

Procoder 2.0 has HDV1 encoding profiles: might be worth trying the demo of that to see if it will structure your file correctly? I'm not sure if the Mainconcept plugin had a demo.

Scott Frase
October 5th, 2006, 08:56 PM
hey Graham,
That's weird. I start up Premiere Pro v7.0 and don't have an export to .ts option. I looked through all the container formats (avi, MS dv avi, Main Concept, and Quicktime) and codecs with no luck. Must be a difference between 5.1 and 7.0. Premiere & Main Concept also don't seem to like to recognize my cam.

I will try Procoder and continue my ffmpeg explorations.
thanks for the help,
scott

Graham Hickling
October 5th, 2006, 09:00 PM
Transport streams that used to be labelled .ts often seem to be labelled .m2t in recent programs, if that's of any help.

Also, demo versions of Premiere don't have HDV export options that the full versions do ... not sure if that's relevant in your case but I know it has confused people in the past.

Jeff Kellam
October 6th, 2006, 08:53 AM
Scott:

What you are trying to do is really very simple but does require the NLE that you are using either not render the .m2t transport stream to another format, or render it back to .m2t transport stream format.

JVC and all HDV cameras are only looking for a .m2t transport stream. All HDV NLEs have a print to HDV tape function (Cinelerra?). This function converts the file to a HDV .m2t file, through formatting and/or rendering as required.

A simple workflow:
1. Capture using JVC capture software or your HDV NLE
2. Import to NLE timeline and edit.
3. Use print to HDV tape NLE function, connect camera via firewire and you are finished.

The MPEG Studio Pro LE that came with the JVCs is not good. I was saying in the previous post that the import/export capture utility is very good.

Scott Frase
October 6th, 2006, 08:30 PM
Jeff,
Oh yes..I am very familiar with the *wonderful* (cough, cough) HDV version of MPEGTS format. Steve Mullen's original article back in 2003 taught me quite a bit:
http://www.gyhduser.com/article.php?filename=What-is-HDV-

It's not that the format is bad, because it outputs some really wonderful footage. It is just that the GOP construct and the JVC version is complicated and there aren't very many freeware tools out there to help us encode it well. Which was my point in trying this, really. Yes, if I had the extra bucks, I could buy Vegas or Premiere or Lumiere and live in the lap of luxury editing on my XP box. But Cinelerra is very powerful once you get it up and running, kinda of like a combo of Premiere and AfterEffects. The feature set is pretty compelling:
http://heroinewarrior.com/cinelerra.php3

Which is why I wanted to use it. For better or worse, I'm one of the few hardy souls who choose to rough it out in the land of Linux Video. It's wild country out here..especially if you've got an HD cam!

To answer a point you brought up, Cinelerra does output to HDV, but you are only using Cinelerra's GUI on top of freeware tools like ffmpeg or mpeg2enc. So you have to know the right arguments to feed those two programs. Which gets very complicated. Maybe this is good, because it teaches you how an MPEG file is constructed, but it's a time consuming learning process that has taken me literally a year to figure out.

Also, Cinelerra *should* be able to output to tape via the libiec61883 (libraw) library set. You need to update and recompile your kernel in order to utilize it, which I doing as we speak. I'll let you know how that goes. To read more, visit:
http://www.linux1394.org

Lastly, I had a minor bit of success tonight. Eliminating ffmpeg from my rendering chain (explained above) produced a file that loaded into the cam via the JVC utility. However, I got dropouts on the sound. So close!!

Thanks for the input. And you're right, the import/export utility JVC gave us is pretty resilient. Since I've tried WrtDVHS/CapDVHS/DVHSTool, I find JVC's to be more compatible that the others.

scott

Scott Frase
October 10th, 2006, 09:52 PM
With the latest 2.6.18 kernel and latest libiec61883/libraw1394 from www.linux1394.org, I was able to output from an MPEGTS format file direct to the cam IN HD FORMAT! Wahoo!!

Workflow goes like this:
- edit HDV in Cinelerra
- in Cinelerra, render video using mpeg2enc encoding with some special params for HDV format
- in Cinelerra, render audio stream to mp2
- using mplex, multiplex files together to an MPEG program stream
- using VLC, convert MPEGPS to MPEGTS
- for local distribution (ie, your HDTV) use test-mpeg2 (comes with libiec61883) to output file to your video cam in HDV format
- enjoy presentation on your HDTV

I've been at this for a month and almost gave up. This is a workable HDV production flow that I'm very psyched to have figured out. Note that Microsoft is not needed for any of the steps. Yessir.

thanks for the help guys.
scott

Graham Hickling
October 10th, 2006, 10:17 PM
Cool!

What were the "special params", if you don't mind my asking?

Scott Frase
October 11th, 2006, 10:02 AM
Hi Graham,
Yes, there are a number of caveats:
1) install the latest 2.6.18 kernel according to specs on http://www.linux1394.org
2) you'll need the latest libiec61883 and libraw1394 libraries from the same place
3) you'll need to make a change to tsbuffer.c and recompile libiec61883 (don't have it now..email me if you need it).
4) you'll need to recompile mpeg2enc to allow for bitrates larger than 14000. This is referenced in the thread from way back when:
http://www.dvinfo.net/conf/archive/index.php/t-19007.html
--------------------
A kludgy hack allowed me to get bit rates higher than 15Mbs in mpeg2enc I removed the following lines from conform.cc

if (bit_rate> 1.0e6 * maxval->bit_rate)
mjpeg_error_exit1("Bit rate is greater than permitted in specified Level");
---------------------
5) here are the mpeg2enc switches that were successful for me:
mpeg2enc --verbose 0 --aspect 3 --format 3 --frame-rate 4 --video-bitrate 18300 --nonvideo-bitrate 384 --interlace-mode 0 --force-b-b-p --video-buffer 448 --video-norm n --keep-hf --no-constraints --sequence-header-every-gop --min-gop-size 6 --max-gop-size 6 -o mpeg2.mpv

6) mplex params:
mplex -f 3 -b 2000 -o programstream.ps audio.mp2 mpeg2.mpv

7) VLC settings from Paul St. Denis' original instructions that did not work for me (http://www.celt.sunysb.edu/paul/mpeg2enc_HDTV.zip):
------------------
VLC will convert the file to a transport stream in real time.

To do so, start VLC, from the "file" menu select "open file", click on the "Browse..." button and find "programstream.ps", check on the "advanced output" check box and then click on the "Settings.." button.

Make sure the "file" radio button is picked click on the "Browse..." button save the file on your desktop as "transport.ts".

Make sure that the "Encapsulation Method" is MPEG TS, leave everything else blank. Click OK, which brings you back to the other screen click OK again.
------------------

Yes, it's a lot of work. But to be Microsoft free is a great feeling.
scott